render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
99cbc7
From a6af039d4a7810cbc4f00018acc7a7fa0b8d304e Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <a6af039d4a7810cbc4f00018acc7a7fa0b8d304e@dist-git>
99cbc7
From: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Date: Fri, 16 Aug 2019 14:52:29 +0200
99cbc7
Subject: [PATCH] qemu: Pass qemuCaps to qemuDomainSaveImageOpen
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
99cbc7
sure it gets the capabilities stored in the domain's private data if the
99cbc7
domain is running. Passing NULL may cause QEMU capabilities probing to
99cbc7
be triggered in case QEMU binary changed in the meantime. When this
99cbc7
happens while a running domain object is locked, QMP event delivered to
99cbc7
the domain before QEMU capabilities probing finishes will deadlock the
99cbc7
event loop.
99cbc7
99cbc7
This patch fixes all paths leading to qemuDomainSaveImageOpen.
99cbc7
99cbc7
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
(cherry picked from commit fd60aefec7f49d1053efdd5119db494bb474aeec)
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1731783
99cbc7
99cbc7
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Message-Id: <6206f14c127037e0822fb6c1e04e8f2d8e6069ce.1565959866.git.jdenemar@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_driver.c | 14 ++++++++------
99cbc7
 1 file changed, 8 insertions(+), 6 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
99cbc7
index 7d87215904..04915798ab 100644
99cbc7
--- a/src/qemu/qemu_driver.c
99cbc7
+++ b/src/qemu/qemu_driver.c
99cbc7
@@ -6368,6 +6368,7 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver,
99cbc7
 /**
99cbc7
  * qemuDomainSaveImageOpen:
99cbc7
  * @driver: qemu driver data
99cbc7
+ * @qemuCaps: pointer to qemuCaps if the domain is running or NULL
99cbc7
  * @path: path of the save image
99cbc7
  * @ret_def: returns domain definition created from the XML stored in the image
99cbc7
  * @ret_data: returns structure filled with data from the image header
99cbc7
@@ -6382,6 +6383,7 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver,
99cbc7
  */
99cbc7
 static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
99cbc7
 qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
99cbc7
+                        virQEMUCapsPtr qemuCaps,
99cbc7
                         const char *path,
99cbc7
                         virDomainDefPtr *ret_def,
99cbc7
                         virQEMUSaveDataPtr *ret_data,
99cbc7
@@ -6506,7 +6508,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
99cbc7
     }
99cbc7
 
99cbc7
     /* Create a domain from this XML */
99cbc7
-    if (!(def = virDomainDefParseString(data->xml, caps, driver->xmlopt, NULL,
99cbc7
+    if (!(def = virDomainDefParseString(data->xml, caps, driver->xmlopt, qemuCaps,
99cbc7
                                         VIR_DOMAIN_DEF_PARSE_INACTIVE |
99cbc7
                                         VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
99cbc7
         goto error;
99cbc7
@@ -6681,7 +6683,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
99cbc7
 
99cbc7
     virNWFilterReadLockFilterUpdates();
99cbc7
 
99cbc7
-    fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
99cbc7
+    fd = qemuDomainSaveImageOpen(driver, NULL, path, &def, &data,
99cbc7
                                  (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) != 0,
99cbc7
                                  &wrapperFd, false, false);
99cbc7
     if (fd < 0)
99cbc7
@@ -6779,7 +6781,7 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
99cbc7
     /* We only take subset of virDomainDefFormat flags.  */
99cbc7
     virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
99cbc7
 
99cbc7
-    fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
99cbc7
+    fd = qemuDomainSaveImageOpen(driver, NULL, path, &def, &data,
99cbc7
                                  false, NULL, false, false);
99cbc7
 
99cbc7
     if (fd < 0)
99cbc7
@@ -6817,7 +6819,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
99cbc7
     else if (flags & VIR_DOMAIN_SAVE_PAUSED)
99cbc7
         state = 0;
99cbc7
 
99cbc7
-    fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
99cbc7
+    fd = qemuDomainSaveImageOpen(driver, NULL, path, &def, &data,
99cbc7
                                  false, NULL, true, false);
99cbc7
 
99cbc7
     if (fd < 0)
99cbc7
@@ -6902,7 +6904,7 @@ qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, unsigned int flags)
99cbc7
         goto cleanup;
99cbc7
     }
99cbc7
 
99cbc7
-    if ((fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
99cbc7
+    if ((fd = qemuDomainSaveImageOpen(driver, priv->qemuCaps, path, &def, &data,
99cbc7
                                       false, NULL, false, false)) < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
@@ -6969,7 +6971,7 @@ qemuDomainObjRestore(virConnectPtr conn,
99cbc7
     virQEMUSaveDataPtr data = NULL;
99cbc7
     virFileWrapperFdPtr wrapperFd = NULL;
99cbc7
 
99cbc7
-    fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
99cbc7
+    fd = qemuDomainSaveImageOpen(driver, NULL, path, &def, &data,
99cbc7
                                  bypass_cache, &wrapperFd, false, true);
99cbc7
     if (fd < 0) {
99cbc7
         if (fd == -3)
99cbc7
-- 
99cbc7
2.22.1
99cbc7