7b4659
From 54ca487f3777497fb419884d187bf2be00ed60f1 Mon Sep 17 00:00:00 2001
7b4659
Message-Id: <54ca487f3777497fb419884d187bf2be00ed60f1@dist-git>
7b4659
From: Jiri Denemark <jdenemar@redhat.com>
7b4659
Date: Fri, 16 Aug 2019 14:52:30 +0200
7b4659
Subject: [PATCH] qemu: Pass qemuCaps to qemuMigrationAnyPrepareDef
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 qemuMigrationAnyPrepareDef.
7b4659
7b4659
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7b4659
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
7b4659
(cherry picked from commit b900f7387fca1cf3567935c81136579d6bee95ca)
7b4659
7b4659
https://bugzilla.redhat.com/show_bug.cgi?id=1731783
7b4659
https://bugzilla.redhat.com/show_bug.cgi?id=1742023
7b4659
7b4659
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7b4659
Message-Id: <9c8ee8580063e52b001b969a2fbb1f1cc3ebfc37.1565959866.git.jdenemar@redhat.com>
7b4659
Reviewed-by: Ján Tomko <jtomko@redhat.com>
7b4659
---
7b4659
 src/qemu/qemu_driver.c    | 12 ++++++------
7b4659
 src/qemu/qemu_migration.c |  8 ++++++--
7b4659
 src/qemu/qemu_migration.h |  1 +
7b4659
 3 files changed, 13 insertions(+), 8 deletions(-)
7b4659
7b4659
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
7b4659
index 04915798ab..590596a421 100644
7b4659
--- a/src/qemu/qemu_driver.c
7b4659
+++ b/src/qemu/qemu_driver.c
7b4659
@@ -12184,7 +12184,7 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
7b4659
         goto cleanup;
7b4659
     }
7b4659
 
7b4659
-    if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname)))
7b4659
+    if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
7b4659
         goto cleanup;
7b4659
 
7b4659
     if (virDomainMigratePrepareTunnelEnsureACL(dconn, def) < 0)
7b4659
@@ -12245,7 +12245,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
7b4659
         goto cleanup;
7b4659
     }
7b4659
 
7b4659
-    if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname)))
7b4659
+    if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
7b4659
         goto cleanup;
7b4659
 
7b4659
     if (virDomainMigratePrepare2EnsureACL(dconn, def) < 0)
7b4659
@@ -12487,7 +12487,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
7b4659
                                                    QEMU_MIGRATION_DESTINATION)))
7b4659
         goto cleanup;
7b4659
 
7b4659
-    if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname)))
7b4659
+    if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
7b4659
         goto cleanup;
7b4659
 
7b4659
     if (virDomainMigratePrepare3EnsureACL(dconn, def) < 0)
7b4659
@@ -12574,7 +12574,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
7b4659
         goto cleanup;
7b4659
     }
7b4659
 
7b4659
-    if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname)))
7b4659
+    if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
7b4659
         goto cleanup;
7b4659
 
7b4659
     if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0)
7b4659
@@ -12628,7 +12628,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
7b4659
                                                    QEMU_MIGRATION_DESTINATION)))
7b4659
         goto cleanup;
7b4659
 
7b4659
-    if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname)))
7b4659
+    if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
7b4659
         goto cleanup;
7b4659
 
7b4659
     if (virDomainMigratePrepareTunnel3EnsureACL(dconn, def) < 0)
7b4659
@@ -12687,7 +12687,7 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
7b4659
                                                    QEMU_MIGRATION_DESTINATION)))
7b4659
         goto cleanup;
7b4659
 
7b4659
-    if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname)))
7b4659
+    if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
7b4659
         goto cleanup;
7b4659
 
7b4659
     if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0)
7b4659
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
7b4659
index 111038b971..f5d77d2508 100644
7b4659
--- a/src/qemu/qemu_migration.c
7b4659
+++ b/src/qemu/qemu_migration.c
7b4659
@@ -2852,6 +2852,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver,
7b4659
 
7b4659
 virDomainDefPtr
7b4659
 qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver,
7b4659
+                           virQEMUCapsPtr qemuCaps,
7b4659
                            const char *dom_xml,
7b4659
                            const char *dname,
7b4659
                            char **origname)
7b4659
@@ -2869,7 +2870,8 @@ qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver,
7b4659
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
7b4659
         return NULL;
7b4659
 
7b4659
-    if (!(def = virDomainDefParseString(dom_xml, caps, driver->xmlopt, NULL,
7b4659
+    if (!(def = virDomainDefParseString(dom_xml, caps, driver->xmlopt,
7b4659
+                                        qemuCaps,
7b4659
                                         VIR_DOMAIN_DEF_PARSE_INACTIVE |
7b4659
                                         VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
7b4659
         goto cleanup;
7b4659
@@ -3412,7 +3414,9 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
7b4659
 
7b4659
     if (flags & VIR_MIGRATE_PERSIST_DEST) {
7b4659
         if (persist_xml) {
7b4659
-            if (!(persistDef = qemuMigrationAnyPrepareDef(driver, persist_xml,
7b4659
+            if (!(persistDef = qemuMigrationAnyPrepareDef(driver,
7b4659
+                                                          priv->qemuCaps,
7b4659
+                                                          persist_xml,
7b4659
                                                           NULL, NULL)))
7b4659
                 goto error;
7b4659
         } else {
7b4659
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
7b4659
index e12b6972db..b9feffaf93 100644
7b4659
--- a/src/qemu/qemu_migration.h
7b4659
+++ b/src/qemu/qemu_migration.h
7b4659
@@ -115,6 +115,7 @@ qemuMigrationSrcBegin(virConnectPtr conn,
7b4659
 
7b4659
 virDomainDefPtr
7b4659
 qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver,
7b4659
+                           virQEMUCapsPtr qemuCaps,
7b4659
                            const char *dom_xml,
7b4659
                            const char *dname,
7b4659
                            char **origname);
7b4659
-- 
7b4659
2.22.1
7b4659