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