[libvirt] [PATCH 8/8] Implement domain state reason

Eric Blake eblake at redhat.com
Thu May 5 22:18:48 UTC 2011


On 05/04/2011 08:45 AM, Jiri Denemark wrote:
> Only in drivers which use virDomainObj, drivers that query hypervisor
> for domain status need to be updated separately in case their hypervisor
> supports this functionality.
> 
> The reason is also saved into domain state XML so if a domain is not
> running (i.e., no state XML exists) the reason will be lost by libvirtd
> restart. I think this is an acceptable limitation.

> +void
> +virDomainObjSetState(virDomainObjPtr dom, virDomainState state, int reason)
> +{
> +    int last = -1;
> +
> +    switch (state) {
> +    case VIR_DOMAIN_NOSTATE:    last = VIR_DOMAIN_NOSTATE_LAST;     break;
> +    case VIR_DOMAIN_RUNNING:    last = VIR_DOMAIN_RUNNING_LAST;     break;
> +    case VIR_DOMAIN_BLOCKED:    last = VIR_DOMAIN_BLOCKED_LAST;     break;
> +    case VIR_DOMAIN_PAUSED:     last = VIR_DOMAIN_PAUSED_LAST;      break;
> +    case VIR_DOMAIN_SHUTDOWN:   last = VIR_DOMAIN_SHUTDOWN_LAST;    break;
> +    case VIR_DOMAIN_SHUTOFF:    last = VIR_DOMAIN_SHUTOFF_LAST;     break;
> +    case VIR_DOMAIN_CRASHED:    last = VIR_DOMAIN_CRASHED_LAST;     break;
> +    }
> +
> +    if (last < 0) {
> +        VIR_ERROR(_("invalid domain state: %d"), state);
> +        return;
> +    }
> +
> +    dom->state.state = state;
> +    if (reason > 0 || reason < last)

&&, not ||

ACK with that nit fixed.  virDomainObjSetState does not need a flags
parameter, even though the public API has one (a virCheckFlags at each
of the public API is sufficient to be the end of the line for that
argument, and it does not have to propagate into src/conf/domain_conf.c).

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110505/f7f544b2/attachment-0001.sig>


More information about the libvir-list mailing list