[libvirt] Monitoring guest state (xen hvms)

From: Matthew Donovan <matthew atc-nycorp com>

To: libvir-list redhat com

Subject: [libvirt] Monitoring guest state (xen hvms)

Date: Tue, 23 Sep 2008 14:28:38 -0400

I would like to be able to monitor the state of a Xen guest OS via
virDomainGetInfo (and Domain.getInfo() in the Java bindings.)
When I start, pause, and resume the guest via the libvirt API, it works as
expected. However, if I shutdown the guest vm by opening a VNC window and
actually selecting "shutdown" via the OS's favorite mechanism (e.g. Start ->
Shutdown in Windows), I lose the state. In other words, virDomainGetInfo()
returns NOSTATE.
There was some conversation on this list a while ago about
virDomainGetInfo() returning NOSTATE so I added some code and recompiled
libvirt to print the value of the domain_flags returned from the xen
hypervisor. _When_ it printed this value, it was always zero. I stress the
"when" part because after the OS completely shuts down, the value of
domain_flags is no longer printed.
I started virsh and did a list of VMs and the guest is gone. However, if I
look at "xm list", the domain is still there.
Is there a reliable way to monitor the guest state when the guest is
shutdown internally (i.e. via the guest OS itself)?
Thanks
-matthew