[libvirt] [PATCH 3/5] add XML parsing for vm status file

Guido Günther agx at sigxcpu.org
Thu Dec 18 09:34:03 UTC 2008


On Mon, Dec 15, 2008 at 10:25:27AM +0100, Daniel Veillard wrote:
> On Fri, Dec 12, 2008 at 07:26:51PM +0100, Guido Günther wrote:
> > Functions to read and write vm status in $(statedir)/qemu/<domain>.xml.
> > Keeps the necessary to reconnect to a running domain state within
> > <domstate>...</domstate>. I kept most of the code in qemu_config.c for
> > now. We can easily move it should another hypervisor need to do
> > something similar.
> [...]
> > +static char*
> > +qemudDomainStatusFormat(virConnectPtr conn,
> > +                        virDomainObjPtr vm)
> > +{
> > +    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, "  <monitor path='%s'/>\n", vm->monitorpath);
> 
>   I would use virBufferEscapeString here, even if by default the path
> should not contain characters needing escaping, I think it's safer.
O.k. done.
> 
> > +    if (!(config_xml = virDomainDefFormat(conn,
> > +                                          vm->def,
> > +                                          VIR_DOMAIN_XML_SECURE)))
> > +        goto cleanup;
> > +
> > +    virBufferVSprintf(&buf, "%s", config_xml);
> 
>   Same thing here.
This one comes straight out of virDomainDefFormat so it should have
everything escaped nicely so shouldn't virBufferVSprintf be safe here?
O.k. to apply the attached version?
Cheers,
 -- Guido
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-add-XML-parsing-for-vm-status-file.patch
Type: text/x-diff
Size: 11410 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20081218/42b0ab91/attachment-0001.bin>


More information about the libvir-list mailing list