d759b5
From c6dcec2dc7cb4060850587a0e5f9f90c4c2b3a95 Mon Sep 17 00:00:00 2001
d759b5
Message-Id: <c6dcec2dc7cb4060850587a0e5f9f90c4c2b3a95@dist-git>
7b4659
From: Jiri Denemark <jdenemar@redhat.com>
7b4659
Date: Fri, 16 Aug 2019 14:52:34 +0200
7b4659
Subject: [PATCH] qemu: Pass correct qemuCaps to virDomainDefPostParse
7b4659
MIME-Version: 1.0
7b4659
Content-Type: text/plain; charset=UTF-8
7b4659
Content-Transfer-Encoding: 8bit
7b4659
7b4659
Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
7b4659
sure it gets the capabilities stored in the domain's private data if the
7b4659
domain is running. Passing NULL may cause QEMU capabilities probing to
7b4659
be triggered in case QEMU binary changed in the meantime. When this
7b4659
happens while a running domain object is locked, QMP event delivered to
7b4659
the domain before QEMU capabilities probing finishes will deadlock the
7b4659
event loop.
7b4659
7b4659
This patch fixes all paths leading to virDomainDefPostParse.
7b4659
7b4659
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7b4659
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
7b4659
(cherry picked from commit c90fb5a828a68512095d80c190c0f491e385438e)
7b4659
7b4659
Conflicts:
7b4659
	src/qemu/qemu_driver.c
7b4659
            - context
7b4659
7b4659
https://bugzilla.redhat.com/show_bug.cgi?id=1731783
7b4659
7b4659
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7b4659
Message-Id: <816c373facf7f779dc22d8a8e6e382cadf5cc2b7.1565959866.git.jdenemar@redhat.com>
7b4659
Reviewed-by: Ján Tomko <jtomko@redhat.com>
7b4659
---
7b4659
 src/qemu/qemu_driver.c  | 17 ++++++++++-------
7b4659
 src/qemu/qemu_process.c |  2 +-
7b4659
 2 files changed, 11 insertions(+), 8 deletions(-)
7b4659
7b4659
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
7b4659
index 82371b9a66..cc7210c6f4 100644
7b4659
--- a/src/qemu/qemu_driver.c
7b4659
+++ b/src/qemu/qemu_driver.c
7b4659
@@ -7881,6 +7881,7 @@ static int
7b4659
 qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
7b4659
                              virDomainDeviceDefPtr dev,
7b4659
                              virCapsPtr caps,
7b4659
+                             virQEMUCapsPtr qemuCaps,
7b4659
                              unsigned int parse_flags,
7b4659
                              virDomainXMLOptionPtr xmlopt)
7b4659
 {
7b4659
@@ -8070,7 +8071,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
7b4659
          return -1;
7b4659
     }
7b4659
 
7b4659
-    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
7b4659
+    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, qemuCaps) < 0)
7b4659
         return -1;
7b4659
 
7b4659
     return 0;
7b4659
@@ -8081,6 +8082,7 @@ static int
7b4659
 qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
7b4659
                              virDomainDeviceDefPtr dev,
7b4659
                              virCapsPtr caps,
7b4659
+                             virQEMUCapsPtr qemuCaps,
7b4659
                              unsigned int parse_flags,
7b4659
                              virDomainXMLOptionPtr xmlopt)
7b4659
 {
7b4659
@@ -8262,7 +8264,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
7b4659
         return -1;
7b4659
     }
7b4659
 
7b4659
-    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
7b4659
+    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, qemuCaps) < 0)
7b4659
         return -1;
7b4659
 
7b4659
     return 0;
7b4659
@@ -8272,6 +8274,7 @@ static int
7b4659
 qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
7b4659
                              virDomainDeviceDefPtr dev,
7b4659
                              virCapsPtr caps,
7b4659
+                             virQEMUCapsPtr qemuCaps,
7b4659
                              unsigned int parse_flags,
7b4659
                              virDomainXMLOptionPtr xmlopt)
7b4659
 {
7b4659
@@ -8367,7 +8370,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
7b4659
         return -1;
7b4659
     }
7b4659
 
7b4659
-    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
7b4659
+    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, qemuCaps) < 0)
7b4659
         return -1;
7b4659
 
7b4659
     return 0;
7b4659
@@ -8426,7 +8429,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
7b4659
                                          VIR_DOMAIN_DEVICE_ACTION_ATTACH,
7b4659
                                          false) < 0)
7b4659
             goto cleanup;
7b4659
-        if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, caps,
7b4659
+        if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, caps, priv->qemuCaps,
7b4659
                                                 parse_flags,
7b4659
                                                 driver->xmlopt)) < 0)
7b4659
             goto cleanup;
7b4659
@@ -8585,7 +8588,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
7b4659
 
7b4659
         /* virDomainDefCompatibleDevice call is delayed until we know the
7b4659
          * device we're going to update. */
7b4659
-        if ((ret = qemuDomainUpdateDeviceConfig(vmdef, dev, caps,
7b4659
+        if ((ret = qemuDomainUpdateDeviceConfig(vmdef, dev, caps, priv->qemuCaps,
7b4659
                                                 parse_flags,
7b4659
                                                 driver->xmlopt)) < 0)
7b4659
             goto endjob;
7b4659
@@ -8680,7 +8683,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
7b4659
         if (!vmdef)
7b4659
             goto cleanup;
7b4659
 
7b4659
-        if (qemuDomainDetachDeviceConfig(vmdef, dev, caps,
7b4659
+        if (qemuDomainDetachDeviceConfig(vmdef, dev, caps, priv->qemuCaps,
7b4659
                                          parse_flags,
7b4659
                                          driver->xmlopt) < 0)
7b4659
             goto cleanup;
7b4659
@@ -8766,7 +8769,7 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDriverPtr driver,
7b4659
         if (virDomainDefFindDevice(vmdef, alias, &dev, true) < 0)
7b4659
             goto cleanup;
7b4659
 
7b4659
-        if (qemuDomainDetachDeviceConfig(vmdef, &dev, caps,
7b4659
+        if (qemuDomainDetachDeviceConfig(vmdef, &dev, caps, priv->qemuCaps,
7b4659
                                          parse_flags, driver->xmlopt) < 0)
7b4659
             goto cleanup;
7b4659
     }
7b4659
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
7b4659
index 08e1d91fcc..307098cd63 100644
7b4659
--- a/src/qemu/qemu_process.c
7b4659
+++ b/src/qemu/qemu_process.c
7b4659
@@ -5350,7 +5350,7 @@ qemuProcessInit(virQEMUDriverPtr driver,
7b4659
     if (vm->def->postParseFailed) {
7b4659
         VIR_DEBUG("re-running the post parse callback");
7b4659
 
7b4659
-        if (virDomainDefPostParse(vm->def, caps, 0, driver->xmlopt, NULL) < 0)
7b4659
+        if (virDomainDefPostParse(vm->def, caps, 0, driver->xmlopt, priv->qemuCaps) < 0)
7b4659
             goto cleanup;
7b4659
     }
7b4659
 
7b4659
-- 
7b4659
2.22.1
7b4659