Re: [libvirt PATCH v3 12/18] qemu: include nbdkit state in private xml

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 20, 2022 at 16:59:03 -0500, Jonathon Jongsma wrote:
> Add xml to the private data for a disk source to represent the nbdkit
> process so that the state can be re-created if the libvirt daemon is
> restarted. Format:
> 
>    <nbdkit>
>      <pidfile>/path/to/nbdkit.pid</pidfile>
>      <socketfile>/path/to/nbdkit.socket</socketfile>
>    </nbdkit>
> 
> Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
> ---
>  src/qemu/qemu_domain.c | 53 ++++++++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_nbdkit.c | 21 +++++++++++++++++
>  src/qemu/qemu_nbdkit.h |  5 ++++
>  3 files changed, 79 insertions(+)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index ace7ae4c61..2ae87392cb 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -1849,6 +1849,34 @@ qemuStorageSourcePrivateDataAssignSecinfo(qemuDomainSecretInfo **secinfo,
>  }
>  
>  
> +static int
> +qemuStorageSourcePrivateDataParseNbdkit(xmlNodePtr node,
> +                                        xmlXPathContextPtr ctxt,
> +                                        virStorageSource *src)
> +{
> +    qemuDomainStorageSourcePrivate *srcpriv = qemuDomainStorageSourcePrivateFetch(src);
> +    g_autofree char *pidfile = NULL;
> +    g_autofree char *socketfile = NULL;
> +    VIR_XPATH_NODE_AUTORESTORE(ctxt);
> +
> +    if (srcpriv->nbdkitProcess)
> +        return 0;
> +
> +    ctxt->node = node;
> +
> +    if (!(pidfile = virXPathString("string(./pidfile)", ctxt)))
> +        return -1;
> +
> +    if (!(socketfile = virXPathString("string(./socketfile)", ctxt)))
> +        return -1;
> +
> +    if (!(srcpriv->nbdkitProcess = qemuNbdkitProcessLoad(src, pidfile, socketfile)))
> +        return -1;

Per implementation below this actually checks that the nbdkit process is
alive. That is not an operation that would be allowed in any parser
code.

Any failure of that results in the status XML file being unparsable and
thus failing to recover state of the VM.

Not even checking existance of the pidfile is allowed in the parser. All
those steps must be moved to the point when we are reconnecting to qemu.

It is obvious once you add test data into qemustatusxml2xmltest:

diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxml2xmldata/modern-in.xml
index 7759034f7a..71b3eb4736 100644
--- a/tests/qemustatusxml2xmldata/modern-in.xml
+++ b/tests/qemustatusxml2xmldata/modern-in.xml
@@ -342,6 +342,10 @@
                 <TLSx509 alias='transport-alias'/>
               </objects>
               <thresholdEvent indexUsed='yes'/>
+              <nbdkit>
+                <pidfile>/path/to/nbdkit.pid</pidfile>
+                <socketfile>/path/to/nbdkit.socket</socketfile>
+              </nbdkit>
             </privateData>
           </source>
           <backingStore/>




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux