> Is it possible you could isolate whether the problem is with libvirt > or with the Java bindings? One way would be to shell out to 'virsh' > just to see if virsh fails to change the state (ie. a libvirt/C) or if > the problem is in the Java bindings. > > Pausing/resuming Xen domains is a very common and well-tested > operation so I would be surprised if it's a libvirt problem, but you > never know ... Using following C code does not work. The domain starts but does not suspend. When I call virConnGetLastError() error->code is 0 and error->message is NULL. I ran my code with LIBVIRT_DEBUG=1. The output is below the C code. I was able to suspend the guest with virsh. The guest was started with my C code below. You should be able to suspend the guest at any point, correct? virsh # suspend 65 DEBUG: libvirt.c: virDomainLookupByID (conn=0x882f208, id=65) DEBUG: hash.c: __virGetDomain (New hash entry 0x8846808) DEBUG: libvirt.c: virDomainSuspend (domain=0x8846808) Domain 65 suspended DEBUG: libvirt.c: virDomainFree (domain=0x8846808) DEBUG: hash.c: virUnrefDomain (unref domain 0x8846808 Linux2 1) DEBUG: hash.c: virReleaseDomain (release domain 0x8846808 Linux2) DEBUG: hash.c: virReleaseDomain (unref connection 0x882f208 xen:/// 2) Thanks -matthew #include <stdio.h> #include <unistd.h> #include <libvirt/libvirt.h> #include <libvirt/virterror.h> const char* xml = "<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>"; int main (int argc, char** argv) { virConnectPtr conn; virDomainPtr dom; if (virInitialize () < 0) { printf ("virInitialize() failed\n"); return -1; } conn = virConnectOpen ("xen:///"); if (!conn) { printf ("virConnectOpen() failed\n"); return -1; } dom = virDomainDefineXML (conn, xml); if (!dom) { printf ("virDomainDefineXML() failed\n"); return -1; } if (virDomainCreate (dom) < 0) { printf ("virDomainCreate() failed\n"); return -1; } sleep (30); if (virDomainSuspend (dom) < 0) { virErrorPtr error = virConnGetLastError (conn); printf ("virDomainSuspend() failed: %d\n", error->code); } sleep (60); if (virDomainResume (dom) < 0) { printf ("virDomainResume() failed\n"); } return 0; } [root@grape tmp]$ ./a.out DEBUG: libvirt.c: virInitialize (register drivers) DEBUG: xen_internal.c: xenHypervisorInit (Using new hypervisor call: 30001 ) DEBUG: xen_internal.c: xenHypervisorInit (Using hypervisor call v2, sys ver3 dom ver5 ) DEBUG: libvirt.c: virConnectOpen (name=xen:///) DEBUG: libvirt.c: do_open (name "xen:///" to URI components: scheme xen opaque (null) authority (null) server (null) user (null) port 0 path / ) DEBUG: libvirt.c: do_open (trying driver 0 (Test) ...) DEBUG: libvirt.c: do_open (driver 0 Test returned DECLINED) DEBUG: libvirt.c: do_open (trying driver 1 (Xen) ...) DEBUG: xen_unified.c: xenUnifiedOpen (Trying hypervisor sub-driver) DEBUG: xen_unified.c: xenUnifiedOpen (Activated hypervisor sub-driver) DEBUG: xen_unified.c: xenUnifiedOpen (Trying XenD sub-driver) DEBUG: xen_unified.c: xenUnifiedOpen (Activated XenD sub-driver) DEBUG: xen_unified.c: xenUnifiedOpen (Trying XS sub-driver) DEBUG: xen_unified.c: xenUnifiedOpen (Activated XS sub-driver) DEBUG: libvirt.c: do_open (driver 1 Xen returned SUCCESS) DEBUG: libvirt.c: do_open (network driver 0 Test returned DECLINED) DEBUG: libvirt.c: do_open (network driver 1 QEMU returned DECLINED) DEBUG: remote_internal.c: doRemoteOpen (proceeding with name = xen:///) DEBUG: libvirt.c: do_open (network driver 2 remote returned SUCCESS) DEBUG: libvirt.c: do_open (storage driver 0 Test returned DECLINED) DEBUG: libvirt.c: do_open (storage driver 1 storage returned DECLINED) DEBUG: libvirt.c: do_open (storage driver 2 remote returned SUCCESS) DEBUG: libvirt.c: virDomainDefineXML (conn=0x92ae478, xml=<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</o n_shutdown><on_reboot>restart</on_reboot><on_crash>restart</on_crash><featur es><pae/><acpi/><apic/></features><devices><emulator>/usr/lib/xen/bin/qemu-d m</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>) DEBUG: xend_internal.c: xenDaemonDomainDefineXML (Defining w/ sexpr: (vm (name 'Linux2')(memory 488)(maxmem 488)(vcpus 1)(uuid '5d9f6df2-6930-b2b8-4f71-db8575faa3ae')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(vcpus 1)(boot c)(acpi 1)(apic 1)(pae 1)(usb 1)(usbdevice tablet)(parallel none)(serial pty)(device_model '/usr/lib/xen/bin/qemu-dm')))(device (vbd (dev 'hda:disk')(uname 'phy:/dev/vgvms/Linux2')(mode 'w')))(device (vif (mac 'd6:5f:df:05:45:bb')(bridge 'Bridge2')(script 'vif-bridge')))(device (vkbd))(device (vfb (type vnc)(vncunused 1)(vnclisten '192.168.1.226'))))) DEBUG: libvirt.c: virDomainLookupByName (conn=0x92ae478, name=Linux2) DEBUG: hash.c: __virGetDomain (New hash entry 0x92bd1e0) DEBUG: libvirt.c: virDomainCreate (domain=0x92bd1e0) DEBUG: libvirt.c: virDomainSuspend (domain=0x92bd1e0) virDomainSuspend() failed: 0 > -----Original Message----- > From: Richard W.M. Jones [mailto:rjones@xxxxxxxxxx] > Sent: Friday, September 19, 2008 2:21 PM > To: Matthew Donovan > Cc: libvir-list@xxxxxxxxxx > Subject: Re: [libvirt] pausing / unpausing guests with libvirt > > On Fri, Sep 19, 2008 at 09:23:52AM -0400, Matthew Donovan wrote: > > 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. > > Is it possible you could isolate whether the problem is with libvirt > or with the Java bindings? One way would be to shell out to 'virsh' > just to see if virsh fails to change the state (ie. a libvirt/C) or if > the problem is in the Java bindings. > > Pausing/resuming Xen domains is a very common and well-tested > operation so I would be surprised if it's a libvirt problem, but you > never know ... > > Rich. > > > -- > Richard Jones, Emerging Technologies, Red Hat > http://et.redhat.com/~rjones > virt-df lists disk usage of guests without needing to install any > software inside the virtual machine. Supports Linux and Windows. > http://et.redhat.com/~rjones/virt-df/ > -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list