render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
99cbc7
From c6dcec2dc7cb4060850587a0e5f9f90c4c2b3a95 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <c6dcec2dc7cb4060850587a0e5f9f90c4c2b3a95@dist-git>
99cbc7
From: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Date: Fri, 16 Aug 2019 14:52:34 +0200
99cbc7
Subject: [PATCH] qemu: Pass correct qemuCaps to virDomainDefPostParse
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 virDomainDefPostParse.
99cbc7
99cbc7
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
(cherry picked from commit c90fb5a828a68512095d80c190c0f491e385438e)
99cbc7
99cbc7
Conflicts:
99cbc7
	src/qemu/qemu_driver.c
99cbc7
            - context
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1731783
99cbc7
99cbc7
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Message-Id: <816c373facf7f779dc22d8a8e6e382cadf5cc2b7.1565959866.git.jdenemar@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_driver.c  | 17 ++++++++++-------
99cbc7
 src/qemu/qemu_process.c |  2 +-
99cbc7
 2 files changed, 11 insertions(+), 8 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
99cbc7
index 82371b9a66..cc7210c6f4 100644
99cbc7
--- a/src/qemu/qemu_driver.c
99cbc7
+++ b/src/qemu/qemu_driver.c
99cbc7
@@ -7881,6 +7881,7 @@ static int
99cbc7
 qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
99cbc7
                              virDomainDeviceDefPtr dev,
99cbc7
                              virCapsPtr caps,
99cbc7
+                             virQEMUCapsPtr qemuCaps,
99cbc7
                              unsigned int parse_flags,
99cbc7
                              virDomainXMLOptionPtr xmlopt)
99cbc7
 {
99cbc7
@@ -8070,7 +8071,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
99cbc7
          return -1;
99cbc7
     }
99cbc7
 
99cbc7
-    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
99cbc7
+    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, qemuCaps) < 0)
99cbc7
         return -1;
99cbc7
 
99cbc7
     return 0;
99cbc7
@@ -8081,6 +8082,7 @@ static int
99cbc7
 qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
99cbc7
                              virDomainDeviceDefPtr dev,
99cbc7
                              virCapsPtr caps,
99cbc7
+                             virQEMUCapsPtr qemuCaps,
99cbc7
                              unsigned int parse_flags,
99cbc7
                              virDomainXMLOptionPtr xmlopt)
99cbc7
 {
99cbc7
@@ -8262,7 +8264,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
99cbc7
         return -1;
99cbc7
     }
99cbc7
 
99cbc7
-    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
99cbc7
+    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, qemuCaps) < 0)
99cbc7
         return -1;
99cbc7
 
99cbc7
     return 0;
99cbc7
@@ -8272,6 +8274,7 @@ static int
99cbc7
 qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
99cbc7
                              virDomainDeviceDefPtr dev,
99cbc7
                              virCapsPtr caps,
99cbc7
+                             virQEMUCapsPtr qemuCaps,
99cbc7
                              unsigned int parse_flags,
99cbc7
                              virDomainXMLOptionPtr xmlopt)
99cbc7
 {
99cbc7
@@ -8367,7 +8370,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
99cbc7
         return -1;
99cbc7
     }
99cbc7
 
99cbc7
-    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
99cbc7
+    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, qemuCaps) < 0)
99cbc7
         return -1;
99cbc7
 
99cbc7
     return 0;
99cbc7
@@ -8426,7 +8429,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
99cbc7
                                          VIR_DOMAIN_DEVICE_ACTION_ATTACH,
99cbc7
                                          false) < 0)
99cbc7
             goto cleanup;
99cbc7
-        if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, caps,
99cbc7
+        if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, caps, priv->qemuCaps,
99cbc7
                                                 parse_flags,
99cbc7
                                                 driver->xmlopt)) < 0)
99cbc7
             goto cleanup;
99cbc7
@@ -8585,7 +8588,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
99cbc7
 
99cbc7
         /* virDomainDefCompatibleDevice call is delayed until we know the
99cbc7
          * device we're going to update. */
99cbc7
-        if ((ret = qemuDomainUpdateDeviceConfig(vmdef, dev, caps,
99cbc7
+        if ((ret = qemuDomainUpdateDeviceConfig(vmdef, dev, caps, priv->qemuCaps,
99cbc7
                                                 parse_flags,
99cbc7
                                                 driver->xmlopt)) < 0)
99cbc7
             goto endjob;
99cbc7
@@ -8680,7 +8683,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
99cbc7
         if (!vmdef)
99cbc7
             goto cleanup;
99cbc7
 
99cbc7
-        if (qemuDomainDetachDeviceConfig(vmdef, dev, caps,
99cbc7
+        if (qemuDomainDetachDeviceConfig(vmdef, dev, caps, priv->qemuCaps,
99cbc7
                                          parse_flags,
99cbc7
                                          driver->xmlopt) < 0)
99cbc7
             goto cleanup;
99cbc7
@@ -8766,7 +8769,7 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDriverPtr driver,
99cbc7
         if (virDomainDefFindDevice(vmdef, alias, &dev, true) < 0)
99cbc7
             goto cleanup;
99cbc7
 
99cbc7
-        if (qemuDomainDetachDeviceConfig(vmdef, &dev, caps,
99cbc7
+        if (qemuDomainDetachDeviceConfig(vmdef, &dev, caps, priv->qemuCaps,
99cbc7
                                          parse_flags, driver->xmlopt) < 0)
99cbc7
             goto cleanup;
99cbc7
     }
99cbc7
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
99cbc7
index 08e1d91fcc..307098cd63 100644
99cbc7
--- a/src/qemu/qemu_process.c
99cbc7
+++ b/src/qemu/qemu_process.c
99cbc7
@@ -5350,7 +5350,7 @@ qemuProcessInit(virQEMUDriverPtr driver,
99cbc7
     if (vm->def->postParseFailed) {
99cbc7
         VIR_DEBUG("re-running the post parse callback");
99cbc7
 
99cbc7
-        if (virDomainDefPostParse(vm->def, caps, 0, driver->xmlopt, NULL) < 0)
99cbc7
+        if (virDomainDefPostParse(vm->def, caps, 0, driver->xmlopt, priv->qemuCaps) < 0)
99cbc7
             goto cleanup;
99cbc7
     }
99cbc7
 
99cbc7
-- 
99cbc7
2.22.1
99cbc7