[libvirt] [PATCH] save state as string

Guido Günther agx at sigxcpu.org
Tue Jan 6 15:38:50 UTC 2009


On Tue, Jan 06, 2009 at 03:27:52PM +0100, Daniel Veillard wrote:
> On Mon, Dec 29, 2008 at 03:44:54PM +0100, Guido Günther wrote:
> > Hi,
> > current domstatus code saves the domain as number, attached patch safes
> > it as string which looks a bit nicer.
> [...]
> > @@ -1414,7 +1416,9 @@ qemudDomainStatusFormat(virConnectPtr conn,
> >      char *config_xml = NULL, *xml = NULL;
> >      virBuffer buf = VIR_BUFFER_INITIALIZER;
> >  
> > -    virBufferVSprintf(&buf, "<domstatus state='%d' pid='%d'>\n", vm->state, vm->pid);
> > +    virBufferVSprintf(&buf, "<domstatus state='%s' pid='%d'>\n",
> > +                      virDomainStateTypeToString(vm->state),
> > +                      vm->pid);
> >      virBufferEscapeString(&buf, "  <monitor path='%s'/>\n", vm->monitorpath);
> >  
> >      if (!(config_xml = virDomainDefFormat(conn,
> 
>   Hum, I have 2 objections to this patch:
>     - seems we keep a string value internally in the structure, I don't
>       see the benefit, or maybe I misunderstood.
Currently we have state='1' for running, with this patch this reads
state='running' which is better readable.

>     - second more important is that we change the XML interface, that we
>       can't do, maybe we can extend it to provide a stateinfo="%s"
>       along the state='%d', but we can't just break code which may rely
>       on the existing format.
The file we write is /var/run/libvirt/qemu/*.xml where we keep the
internal state of a running vm. We can change this at at any time.
Cheers,
 -- Guido




More information about the libvir-list mailing list