99cbc7
From 67d392063da158ac25b350fa5f7c4d17c1ea7c79 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <67d392063da158ac25b350fa5f7c4d17c1ea7c79@dist-git>
99cbc7
From: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Date: Fri, 16 Aug 2019 14:52:32 +0200
99cbc7
Subject: [PATCH] qemu: Pass qemuCaps to qemuMigrationCookieXMLParse
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 qemuMigrationCookieXMLParse.
99cbc7
99cbc7
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
(cherry picked from commit bf15b145ec473c0ca5bfe8aee2bf0eb1691b6f1c)
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1731783
99cbc7
99cbc7
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Message-Id: <bb8b9769eaec4dcbbaef5e5acc84d1a28d6e82a0.1565959866.git.jdenemar@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_migration_cookie.c | 7 +++++--
99cbc7
 1 file changed, 5 insertions(+), 2 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
99cbc7
index 901b1ae9ac..b9933b9e04 100644
99cbc7
--- a/src/qemu/qemu_migration_cookie.c
99cbc7
+++ b/src/qemu/qemu_migration_cookie.c
99cbc7
@@ -1194,6 +1194,7 @@ qemuMigrationCookieCapsXMLParse(xmlXPathContextPtr ctxt)
99cbc7
 static int
99cbc7
 qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
99cbc7
                             virQEMUDriverPtr driver,
99cbc7
+                            virQEMUCapsPtr qemuCaps,
99cbc7
                             xmlDocPtr doc,
99cbc7
                             xmlXPathContextPtr ctxt,
99cbc7
                             unsigned int flags)
99cbc7
@@ -1335,7 +1336,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
99cbc7
             goto error;
99cbc7
         }
99cbc7
         mig->persistent = virDomainDefParseNode(doc, nodes[0],
99cbc7
-                                                caps, driver->xmlopt, NULL,
99cbc7
+                                                caps, driver->xmlopt, qemuCaps,
99cbc7
                                                 VIR_DOMAIN_DEF_PARSE_INACTIVE |
99cbc7
                                                 VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION |
99cbc7
                                                 VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
99cbc7
@@ -1388,6 +1389,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
99cbc7
 static int
99cbc7
 qemuMigrationCookieXMLParseStr(qemuMigrationCookiePtr mig,
99cbc7
                                virQEMUDriverPtr driver,
99cbc7
+                               virQEMUCapsPtr qemuCaps,
99cbc7
                                const char *xml,
99cbc7
                                unsigned int flags)
99cbc7
 {
99cbc7
@@ -1400,7 +1402,7 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookiePtr mig,
99cbc7
     if (!(doc = virXMLParseStringCtxt(xml, _("(qemu_migration_cookie)"), &ctxt)))
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
-    ret = qemuMigrationCookieXMLParse(mig, driver, doc, ctxt, flags);
99cbc7
+    ret = qemuMigrationCookieXMLParse(mig, driver, qemuCaps, doc, ctxt, flags);
99cbc7
 
99cbc7
  cleanup:
99cbc7
     xmlXPathFreeContext(ctxt);
99cbc7
@@ -1501,6 +1503,7 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
99cbc7
     if (cookiein && cookieinlen &&
99cbc7
         qemuMigrationCookieXMLParseStr(mig,
99cbc7
                                        driver,
99cbc7
+                                       priv->qemuCaps,
99cbc7
                                        cookiein,
99cbc7
                                        flags) < 0)
99cbc7
         goto error;
99cbc7
-- 
99cbc7
2.22.1
99cbc7