]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: domain: Store fdset ID for disks passed to qemu via FD
authorPeter Krempa <pkrempa@redhat.com>
Tue, 31 Jan 2023 14:30:51 +0000 (15:30 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 1 Feb 2023 08:17:41 +0000 (09:17 +0100)
To ensure that we can hot-unplug the disk including the associated fdset
we need to store the fdset ID in the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_domain.c
tests/qemustatusxml2xmldata/modern-in.xml

index 112d4fb90ee3d07c36c4d95645898939a6106f3c..1757a6aaada58beca71a37bddc12bcdb2951f81c 100644 (file)
@@ -1941,6 +1941,8 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
     g_autofree char *httpcookiealias = NULL;
     g_autofree char *tlskeyalias = NULL;
     g_autofree char *thresholdEventWithIndex = NULL;
+    bool fdsetPresent = false;
+    unsigned int fdSetID;
 
     src->nodestorage = virXPathString("string(./nodenames/nodename[@type='storage']/@name)", ctxt);
     src->nodeformat = virXPathString("string(./nodenames/nodename[@type='format']/@name)", ctxt);
@@ -1957,7 +1959,9 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
     httpcookiealias = virXPathString("string(./objects/secret[@type='httpcookie']/@alias)", ctxt);
     tlskeyalias = virXPathString("string(./objects/secret[@type='tlskey']/@alias)", ctxt);
 
-    if (authalias || encalias || httpcookiealias || tlskeyalias) {
+    fdsetPresent = virXPathUInt("string(./fdsets/fdset[@type='storage']/@id)", ctxt, &fdSetID) == 0;
+
+    if (authalias || encalias || httpcookiealias || tlskeyalias || fdsetPresent) {
         if (!src->privateData &&
             !(src->privateData = qemuDomainStorageSourcePrivateNew()))
             return -1;
@@ -1975,6 +1979,9 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
 
         if (qemuStorageSourcePrivateDataAssignSecinfo(&priv->tlsKeySecret, &tlskeyalias) < 0)
             return -1;
+
+        if (fdsetPresent)
+            priv->fdpass = qemuFDPassNewPassed(fdSetID);
     }
 
     if (virStorageSourcePrivateDataParseRelPath(ctxt, src) < 0)
@@ -2008,6 +2015,7 @@ qemuStorageSourcePrivateDataFormat(virStorageSource *src,
     qemuDomainStorageSourcePrivate *srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
     g_auto(virBuffer) nodenamesChildBuf = VIR_BUFFER_INIT_CHILD(buf);
     g_auto(virBuffer) objectsChildBuf = VIR_BUFFER_INIT_CHILD(buf);
+    g_auto(virBuffer) fdsetsChildBuf = VIR_BUFFER_INIT_CHILD(buf);
 
     virBufferEscapeString(&nodenamesChildBuf, "<nodename type='storage' name='%s'/>\n", src->nodestorage);
     virBufferEscapeString(&nodenamesChildBuf, "<nodename type='format' name='%s'/>\n", src->nodeformat);
@@ -2025,10 +2033,15 @@ qemuStorageSourcePrivateDataFormat(virStorageSource *src,
         return -1;
 
     if (srcPriv) {
+        unsigned int fdSetID;
+
         qemuStorageSourcePrivateDataFormatSecinfo(&objectsChildBuf, srcPriv->secinfo, "auth");
         qemuStorageSourcePrivateDataFormatSecinfo(&objectsChildBuf, srcPriv->encinfo, "encryption");
         qemuStorageSourcePrivateDataFormatSecinfo(&objectsChildBuf, srcPriv->httpcookie, "httpcookie");
         qemuStorageSourcePrivateDataFormatSecinfo(&objectsChildBuf, srcPriv->tlsKeySecret, "tlskey");
+
+        if (qemuFDPassIsPassed(srcPriv->fdpass, &fdSetID))
+            virBufferAsprintf(&fdsetsChildBuf, "<fdset type='storage' id='%u'/>\n", fdSetID);
     }
 
     if (src->tlsAlias)
@@ -2036,6 +2049,8 @@ qemuStorageSourcePrivateDataFormat(virStorageSource *src,
 
     virXMLFormatElement(buf, "objects", NULL, &objectsChildBuf);
 
+    virXMLFormatElement(buf, "fdsets", NULL, &fdsetsChildBuf);
+
     if (src->thresholdEventWithIndex)
         virBufferAddLit(buf, "<thresholdEvent indexUsed='yes'/>\n");
 
index 7759034f7a636637122a99d9d0f4bf3684a23b51..f5beab722b265219fea1f8d7eec61c822db38758 100644 (file)
                 <secret type='tlskey' alias='tls-certificate-key-alias'/>
                 <TLSx509 alias='transport-alias'/>
               </objects>
+              <fdsets>
+                <fdset type='storage' id='1337'/>
+              </fdsets>
               <thresholdEvent indexUsed='yes'/>
             </privateData>
           </source>