[libvirt] [PATCH 3/5] add XML parsing for vm status file
Daniel Veillard
veillard at redhat.com
Mon Dec 15 09:25:27 UTC 2008
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.
> + if (!(config_xml = virDomainDefFormat(conn,
> + vm->def,
> + VIR_DOMAIN_XML_SECURE)))
> + goto cleanup;
> +
> + virBufferVSprintf(&buf, "%s", config_xml);
Same thing here.
> + virBufferVSprintf(&buf, "</domstatus>\n");
Overall the patch looks fine to me, +1
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
More information about the libvir-list
mailing list