[libvirt] domain.info() sometimes returns state zero for running machines

Daniel P. Berrange berrange at redhat.com
Wed Jun 17 20:42:12 UTC 2009


On Wed, Jun 17, 2009 at 04:04:20PM +0100, Andreas Sommer wrote:
> I'm using Xen-3.2-1 on Debian 5.0.1-lenny and retrieve information about 
> running domains using
> 
> domain.info()[0]
> 
> The domain object is retrieved via connection.lookupByUUIDString(...) 
> and stored as a variable called "domain". Usually the running domains 
> have the state 1 (VIR_DOMAIN_RUNNING) or 2 (VIR_DOMAIN_BLOCKED), but 
> sometimes it happens that 0 (VIR_DOMAIN_NOSTATE) is returned.
> Why does that happen? I don't think it is an error because then it 
> would've raised an exception...

I think it is most likely a bug in our handling of the state info
from the hypervisor with certain Xen version. I'm fairly sure we 
should never get NO_STATE  for any active domain

If you want to try and troubleshoot the code, then this handled in the
xenHypervisorGetDomInfo() method in src/xen_internal.c.

It currently does this:

    domain_flags = XEN_GETDOMAININFO_FLAGS(dominfo);
    domain_flags &= ~DOMFLAGS_HVM; /* Mask out HVM flags */
    domain_state = domain_flags & 0xFF; /* Mask out high bits */
    switch (domain_state) {
     ....
    }
.
Given that you see NO_STATE, I expect that none of the 'case' inside
the 'switch' are being matched. I'd be interested to know what the
'domain_state' value is immediately after its fetched from the HV.
So you might try changing it to 

    domain_flags = XEN_GETDOMAININFO_FLAGS(dominfo);
    DEBUG("Raw HV state flag %x", domain_flags);
    domain_flags &= ~DOMFLAGS_HVM; /* Mask out HVM flags */
    domain_state = domain_flags & 0xFF; /* Mask out high bits */
    DEBUG("Masked HV state flag %x", domain_flags);
    switch (domain_state) {
     ....
    }
    DEBUG("libvirt state flag %x", info->state);

And then running 'LIBVIRT_DEBUG=1 virsh dominfo GUEST' and 
capturing the output when it reports 'nostate'

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list