[libvirt] pausing / unpausing guests with libvirt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm working on a management application that will control Xen guest vms
(HVMs) with libvirt Java bindings.  I want to be able to pause and unpause
the VMs but doing so through the libvirt functions does not seem to actually
pause the VM.  The suspend function returns true and doesn't throw any
exceptions, however, the guest VM is still running and responsive.

Any pointers are greatly appreciated.

Thanks
-matthew

I'm using:

libvirt 0.4.5 
libvirt-java 0.2.1 
Xen 3.1.2

The guest I'm working with is a Fedora Core 6 HVM (though I'd like it to
work with any guest.)
The host is Fedora Core 8.

Code to define and create the domain:

       try {
            con = new Connect ("xen:///");
            String xml = buildXMLConfig(config);	// config is a
string of XML shown below
            domain = con.domainDefineXML(xml);
            domain.create ();
            
        } catch (LibvirtException ex) {
            logger.error ("Error starting VM", ex);
            return false;
        }


Code to pause the VM:

	public boolean pause() throws RemoteException {
        logger.info ("Pause operation in progress.  domain = "+domain);
        if (domain == null)
            return false;
        
        try {
            synchronized (domain) {
                domain.suspend ();	// using suspend() because there is
no pause() function.
            }
            
        } catch (LibvirtException ex) {
            logger.error ("Could not suspend "+vm.getName(), ex);
            return false;
        }
        raiseComponentChangeEvent(new
ComponentStateChangeEvent(State.PAUSED));
        return true;
	}

(The synchronized() statement is because I was running a second thread
watching the state of the VM and I thought maybe that might be contributing
to the problem.  The VM is still not paused when there is only one thread
running.)


XML for the domain:

<domain type='xen'>
<name>Linux2</name>
<os>
	<type>hvm</type>
	<loader>/usr/lib/xen/boot/hvmloader</loader>
	<boot dev='hd'/>
</os>
<memory>500000</memory>
<vcpu>1</vcpu>
<on_shutdown>shutdown</on_shutdown>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<features>
	<pae/>
	<acpi/>
	<apic/>
</features>
<devices>
	<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
	<input type='tablet' bus='usb'/>
	<graphics type='vnc' autoport='yes' listen='192.168.1.226'/>
	<serial type='pty'/>
	<disk type='block'>
		<source dev='/dev/vgvms/Linux2'/>
		<target dev='hda'/>
	</disk>
	<interface type='bridge'>
		<mac address='D6:5F:DF:05:45:BB'/>
		<source bridge='Bridge2'/>
	</interface>
</devices>
</domain>

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]