render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
acda74
From 0fe11b92a8278ffab202033a61340649b0296368 Mon Sep 17 00:00:00 2001
acda74
Message-Id: <0fe11b92a8278ffab202033a61340649b0296368@dist-git>
acda74
From: Peter Krempa <pkrempa@redhat.com>
acda74
Date: Tue, 31 Jan 2023 15:30:51 +0100
acda74
Subject: [PATCH] qemu: domain: Store fdset ID for disks passed to qemu via FD
acda74
acda74
To ensure that we can hot-unplug the disk including the associated fdset
acda74
we need to store the fdset ID in the status XML.
acda74
acda74
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
acda74
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
acda74
(cherry picked from commit f730b1e4f203cbabe363aab246d8a1679063f756)
acda74
acda74
https://bugzilla.redhat.com/show_bug.cgi?id=2040272
acda74
---
acda74
 src/qemu/qemu_domain.c                    | 17 ++++++++++++++++-
acda74
 tests/qemustatusxml2xmldata/modern-in.xml |  3 +++
acda74
 2 files changed, 19 insertions(+), 1 deletion(-)
acda74
acda74
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
acda74
index 226d4d6dc1..247134672b 100644
acda74
--- a/src/qemu/qemu_domain.c
acda74
+++ b/src/qemu/qemu_domain.c
acda74
@@ -1941,6 +1941,8 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
acda74
     g_autofree char *httpcookiealias = NULL;
acda74
     g_autofree char *tlskeyalias = NULL;
acda74
     g_autofree char *thresholdEventWithIndex = NULL;
acda74
+    bool fdsetPresent = false;
acda74
+    unsigned int fdSetID;
acda74
 
acda74
     src->nodestorage = virXPathString("string(./nodenames/nodename[@type='storage']/@name)", ctxt);
acda74
     src->nodeformat = virXPathString("string(./nodenames/nodename[@type='format']/@name)", ctxt);
acda74
@@ -1957,7 +1959,9 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
acda74
     httpcookiealias = virXPathString("string(./objects/secret[@type='httpcookie']/@alias)", ctxt);
acda74
     tlskeyalias = virXPathString("string(./objects/secret[@type='tlskey']/@alias)", ctxt);
acda74
 
acda74
-    if (authalias || encalias || httpcookiealias || tlskeyalias) {
acda74
+    fdsetPresent = virXPathUInt("string(./fdsets/fdset[@type='storage']/@id)", ctxt, &fdSetID) == 0;
acda74
+
acda74
+    if (authalias || encalias || httpcookiealias || tlskeyalias || fdsetPresent) {
acda74
         if (!src->privateData &&
acda74
             !(src->privateData = qemuDomainStorageSourcePrivateNew()))
acda74
             return -1;
acda74
@@ -1975,6 +1979,9 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
acda74
 
acda74
         if (qemuStorageSourcePrivateDataAssignSecinfo(&priv->tlsKeySecret, &tlskeyalias) < 0)
acda74
             return -1;
acda74
+
acda74
+        if (fdsetPresent)
acda74
+            priv->fdpass = qemuFDPassNewPassed(fdSetID);
acda74
     }
acda74
 
acda74
     if (virStorageSourcePrivateDataParseRelPath(ctxt, src) < 0)
acda74
@@ -2008,6 +2015,7 @@ qemuStorageSourcePrivateDataFormat(virStorageSource *src,
acda74
     qemuDomainStorageSourcePrivate *srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
acda74
     g_auto(virBuffer) nodenamesChildBuf = VIR_BUFFER_INIT_CHILD(buf);
acda74
     g_auto(virBuffer) objectsChildBuf = VIR_BUFFER_INIT_CHILD(buf);
acda74
+    g_auto(virBuffer) fdsetsChildBuf = VIR_BUFFER_INIT_CHILD(buf);
acda74
 
acda74
     virBufferEscapeString(&nodenamesChildBuf, "<nodename type='storage' name='%s'/>\n", src->nodestorage);
acda74
     virBufferEscapeString(&nodenamesChildBuf, "<nodename type='format' name='%s'/>\n", src->nodeformat);
acda74
@@ -2025,10 +2033,15 @@ qemuStorageSourcePrivateDataFormat(virStorageSource *src,
acda74
         return -1;
acda74
 
acda74
     if (srcPriv) {
acda74
+        unsigned int fdSetID;
acda74
+
acda74
         qemuStorageSourcePrivateDataFormatSecinfo(&objectsChildBuf, srcPriv->secinfo, "auth");
acda74
         qemuStorageSourcePrivateDataFormatSecinfo(&objectsChildBuf, srcPriv->encinfo, "encryption");
acda74
         qemuStorageSourcePrivateDataFormatSecinfo(&objectsChildBuf, srcPriv->httpcookie, "httpcookie");
acda74
         qemuStorageSourcePrivateDataFormatSecinfo(&objectsChildBuf, srcPriv->tlsKeySecret, "tlskey");
acda74
+
acda74
+        if (qemuFDPassIsPassed(srcPriv->fdpass, &fdSetID))
acda74
+            virBufferAsprintf(&fdsetsChildBuf, "<fdset type='storage' id='%u'/>\n", fdSetID);
acda74
     }
acda74
 
acda74
     if (src->tlsAlias)
acda74
@@ -2036,6 +2049,8 @@ qemuStorageSourcePrivateDataFormat(virStorageSource *src,
acda74
 
acda74
     virXMLFormatElement(buf, "objects", NULL, &objectsChildBuf);
acda74
 
acda74
+    virXMLFormatElement(buf, "fdsets", NULL, &fdsetsChildBuf);
acda74
+
acda74
     if (src->thresholdEventWithIndex)
acda74
         virBufferAddLit(buf, "<thresholdEvent indexUsed='yes'/>\n");
acda74
 
acda74
diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxml2xmldata/modern-in.xml
acda74
index 7759034f7a..f5beab722b 100644
acda74
--- a/tests/qemustatusxml2xmldata/modern-in.xml
acda74
+++ b/tests/qemustatusxml2xmldata/modern-in.xml
acda74
@@ -341,6 +341,9 @@
acda74
                 <secret type='tlskey' alias='tls-certificate-key-alias'/>
acda74
                 <TLSx509 alias='transport-alias'/>
acda74
               </objects>
acda74
+              <fdsets>
acda74
+                <fdset type='storage' id='1337'/>
acda74
+              </fdsets>
acda74
               <thresholdEvent indexUsed='yes'/>
acda74
             </privateData>
acda74
           </source>
acda74
-- 
acda74
2.39.1
acda74