[libvirt] [PATCH] Fix loosing the pidfile string of struct _qemuDomainObjPrivate after libvirtd service restarted.

Jiri Denemark jdenemar at redhat.com
Mon Aug 26 10:50:39 UTC 2013


On Sat, Aug 24, 2013 at 09:17:16 +0000, Wangyufei (A) wrote:
> *src/qemu/qemu_domain.c (qemuDomainObjPrivateXMLFormat): Add codes of saving pidfile string to vm'state file.
> *src/qemu/qemu_domain.c (qemuDomainObjPrivateXMLParse): Add codes of loading pidfile path saved in vm's state file to the pidfile string.
> 
> Signed-off-by: Xu Chao <xuchao1 at huawei.com>
> ---
> src/qemu/qemu_domain.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 7f4d17d..3c792ab 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -294,6 +294,7 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
>                            virDomainChrTypeToString(priv->monConfig->type));
>      }
> +    virBufferEscapeString(buf, "  <pidfile path='%s'/>\n", priv->pidfile);
>      if (priv->nvcpupids) {
>          size_t i;
> @@ -398,6 +399,13 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
>          goto error;
>      }
> +    if (!(priv->pidfile =
> +          virXPathString("string(./pid[1]/@path)", ctxt))) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       "%s", _("no pidfile path"));
> +        goto error;
> +    }
> +

This won't work as you use pidfile element when writing the status XML
and pid element when reading it. Also this is not backward compatible
since you must not fail when the pidfile path is not present. Otherwise
you'd lose all running domains after upgrading libvirt across this
patch. And finally, I don't think this is needed at all. What problems
do you see and what are you trying to solve with this patch? Ah, I see,
the pidfile is not removed when you start a domain, restart libvirtd,
and destroy the domain, right? In any case, we don't need to store the
path as we can reconstruct it. Just add a call to virPidFileBuildPath in
qemuProcessReconnect.

Jirka




More information about the libvir-list mailing list