99cbc7
From f901375a7380837428cbbc80d24e4bb7b91db427 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <f901375a7380837428cbbc80d24e4bb7b91db427@dist-git>
99cbc7
From: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Date: Fri, 16 Aug 2019 14:52:28 +0200
99cbc7
Subject: [PATCH] qemu: Pass qemuCaps to qemuDomainDefFormatBufInternal
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 qemuDomainDefFormatBufInternal.
99cbc7
99cbc7
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
(cherry picked from commit 900c5952499fb233a9c0d2e6d0a5fde84a99cf72)
99cbc7
99cbc7
Conflicts:
99cbc7
	src/qemu/qemu_driver.c
99cbc7
            - no checkpoint APIs
99cbc7
            - no VIR_AUTOUNREF
99cbc7
            - ProcessAttach and XMLFromNative APIs were removed upstream
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1731783
99cbc7
99cbc7
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Message-Id: <fb9a50220d762c69ee9d8b38c60a03b061b4127b.1565959866.git.jdenemar@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_domain.c           | 37 ++++++++++++++++++++------------
99cbc7
 src/qemu/qemu_domain.h           |  3 +++
99cbc7
 src/qemu/qemu_driver.c           | 22 ++++++++++++-------
99cbc7
 src/qemu/qemu_migration.c        |  6 +++---
99cbc7
 src/qemu/qemu_migration_cookie.c |  9 ++++++--
99cbc7
 src/qemu/qemu_process.c          | 11 +++++-----
99cbc7
 6 files changed, 56 insertions(+), 32 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
99cbc7
index bf6013d42a..249ec4d259 100644
99cbc7
--- a/src/qemu/qemu_domain.c
99cbc7
+++ b/src/qemu/qemu_domain.c
99cbc7
@@ -7230,7 +7230,7 @@ qemuDomainDefCopy(virQEMUDriverPtr driver,
99cbc7
     virDomainDefPtr ret = NULL;
99cbc7
     char *xml;
99cbc7
 
99cbc7
-    if (!(xml = qemuDomainDefFormatXML(driver, src, flags)))
99cbc7
+    if (!(xml = qemuDomainDefFormatXML(driver, qemuCaps, src, flags)))
99cbc7
         return NULL;
99cbc7
 
99cbc7
     ret = qemuDomainDefFromXML(driver, qemuCaps, xml);
99cbc7
@@ -7242,6 +7242,7 @@ qemuDomainDefCopy(virQEMUDriverPtr driver,
99cbc7
 
99cbc7
 static int
99cbc7
 qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
99cbc7
+                               virQEMUCapsPtr qemuCaps,
99cbc7
                                virDomainDefPtr def,
99cbc7
                                virCPUDefPtr origCPU,
99cbc7
                                unsigned int flags,
99cbc7
@@ -7250,7 +7251,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
99cbc7
     int ret = -1;
99cbc7
     virDomainDefPtr copy = NULL;
99cbc7
     virCapsPtr caps = NULL;
99cbc7
-    virQEMUCapsPtr qemuCaps = NULL;
99cbc7
+    virQEMUCapsPtr qCaps = NULL;
99cbc7
 
99cbc7
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
99cbc7
         goto cleanup;
99cbc7
@@ -7258,7 +7259,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
99cbc7
     if (!(flags & (VIR_DOMAIN_XML_UPDATE_CPU | VIR_DOMAIN_XML_MIGRATABLE)))
99cbc7
         goto format;
99cbc7
 
99cbc7
-    if (!(copy = virDomainDefCopy(def, caps, driver->xmlopt, NULL,
99cbc7
+    if (!(copy = virDomainDefCopy(def, caps, driver->xmlopt, qemuCaps,
99cbc7
                                   flags & VIR_DOMAIN_XML_MIGRATABLE)))
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
@@ -7269,13 +7270,17 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
99cbc7
         def->cpu &&
99cbc7
         (def->cpu->mode != VIR_CPU_MODE_CUSTOM ||
99cbc7
          def->cpu->model)) {
99cbc7
-        if (!(qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
99cbc7
-                                                    def->emulator,
99cbc7
-                                                    def->os.machine)))
99cbc7
-            goto cleanup;
99cbc7
+        if (qemuCaps) {
99cbc7
+            qCaps = virObjectRef(qemuCaps);
99cbc7
+        } else {
99cbc7
+            if (!(qCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
99cbc7
+                                                     def->emulator,
99cbc7
+                                                     def->os.machine)))
99cbc7
+                goto cleanup;
99cbc7
+        }
99cbc7
 
99cbc7
         if (virCPUUpdate(def->os.arch, def->cpu,
99cbc7
-                         virQEMUCapsGetHostModel(qemuCaps, def->virtType,
99cbc7
+                         virQEMUCapsGetHostModel(qCaps, def->virtType,
99cbc7
                                                  VIR_QEMU_CAPS_HOST_CPU_MIGRATABLE)) < 0)
99cbc7
             goto cleanup;
99cbc7
     }
99cbc7
@@ -7424,30 +7429,32 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
99cbc7
  cleanup:
99cbc7
     virDomainDefFree(copy);
99cbc7
     virObjectUnref(caps);
99cbc7
-    virObjectUnref(qemuCaps);
99cbc7
+    virObjectUnref(qCaps);
99cbc7
     return ret;
99cbc7
 }
99cbc7
 
99cbc7
 
99cbc7
 int
99cbc7
 qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
99cbc7
+                       virQEMUCapsPtr qemuCaps,
99cbc7
                        virDomainDefPtr def,
99cbc7
                        unsigned int flags,
99cbc7
                        virBufferPtr buf)
99cbc7
 {
99cbc7
-    return qemuDomainDefFormatBufInternal(driver, def, NULL, flags, buf);
99cbc7
+    return qemuDomainDefFormatBufInternal(driver, qemuCaps, def, NULL, flags, buf);
99cbc7
 }
99cbc7
 
99cbc7
 
99cbc7
 static char *
99cbc7
 qemuDomainDefFormatXMLInternal(virQEMUDriverPtr driver,
99cbc7
+                               virQEMUCapsPtr qemuCaps,
99cbc7
                                virDomainDefPtr def,
99cbc7
                                virCPUDefPtr origCPU,
99cbc7
                                unsigned int flags)
99cbc7
 {
99cbc7
     virBuffer buf = VIR_BUFFER_INITIALIZER;
99cbc7
 
99cbc7
-    if (qemuDomainDefFormatBufInternal(driver, def, origCPU, flags, &buf) < 0)
99cbc7
+    if (qemuDomainDefFormatBufInternal(driver, qemuCaps, def, origCPU, flags, &buf) < 0)
99cbc7
         return NULL;
99cbc7
 
99cbc7
     return virBufferContentAndReset(&buf;;
99cbc7
@@ -7456,10 +7463,11 @@ qemuDomainDefFormatXMLInternal(virQEMUDriverPtr driver,
99cbc7
 
99cbc7
 char *
99cbc7
 qemuDomainDefFormatXML(virQEMUDriverPtr driver,
99cbc7
+                       virQEMUCapsPtr qemuCaps,
99cbc7
                        virDomainDefPtr def,
99cbc7
                        unsigned int flags)
99cbc7
 {
99cbc7
-    return qemuDomainDefFormatXMLInternal(driver, def, NULL, flags);
99cbc7
+    return qemuDomainDefFormatXMLInternal(driver, qemuCaps, def, NULL, flags);
99cbc7
 }
99cbc7
 
99cbc7
 
99cbc7
@@ -7478,11 +7486,12 @@ char *qemuDomainFormatXML(virQEMUDriverPtr driver,
99cbc7
         origCPU = priv->origCPU;
99cbc7
     }
99cbc7
 
99cbc7
-    return qemuDomainDefFormatXMLInternal(driver, def, origCPU, flags);
99cbc7
+    return qemuDomainDefFormatXMLInternal(driver, priv->qemuCaps, def, origCPU, flags);
99cbc7
 }
99cbc7
 
99cbc7
 char *
99cbc7
 qemuDomainDefFormatLive(virQEMUDriverPtr driver,
99cbc7
+                        virQEMUCapsPtr qemuCaps,
99cbc7
                         virDomainDefPtr def,
99cbc7
                         virCPUDefPtr origCPU,
99cbc7
                         bool inactive,
99cbc7
@@ -7495,7 +7504,7 @@ qemuDomainDefFormatLive(virQEMUDriverPtr driver,
99cbc7
     if (compatible)
99cbc7
         flags |= VIR_DOMAIN_XML_MIGRATABLE;
99cbc7
 
99cbc7
-    return qemuDomainDefFormatXMLInternal(driver, def, origCPU, flags);
99cbc7
+    return qemuDomainDefFormatXMLInternal(driver, qemuCaps, def, origCPU, flags);
99cbc7
 }
99cbc7
 
99cbc7
 
99cbc7
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
99cbc7
index 29283105cb..9546216f30 100644
99cbc7
--- a/src/qemu/qemu_domain.h
99cbc7
+++ b/src/qemu/qemu_domain.h
99cbc7
@@ -599,11 +599,13 @@ virDomainDefPtr qemuDomainDefCopy(virQEMUDriverPtr driver,
99cbc7
                                   unsigned int flags);
99cbc7
 
99cbc7
 int qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
99cbc7
+                           virQEMUCapsPtr qemuCaps,
99cbc7
                            virDomainDefPtr vm,
99cbc7
                            unsigned int flags,
99cbc7
                            virBuffer *buf);
99cbc7
 
99cbc7
 char *qemuDomainDefFormatXML(virQEMUDriverPtr driver,
99cbc7
+                             virQEMUCapsPtr qemuCaps,
99cbc7
                              virDomainDefPtr vm,
99cbc7
                              unsigned int flags);
99cbc7
 
99cbc7
@@ -612,6 +614,7 @@ char *qemuDomainFormatXML(virQEMUDriverPtr driver,
99cbc7
                           unsigned int flags);
99cbc7
 
99cbc7
 char *qemuDomainDefFormatLive(virQEMUDriverPtr driver,
99cbc7
+                              virQEMUCapsPtr qemuCaps,
99cbc7
                               virDomainDefPtr def,
99cbc7
                               virCPUDefPtr origCPU,
99cbc7
                               bool inactive,
99cbc7
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
99cbc7
index a486c66a5f..7d87215904 100644
99cbc7
--- a/src/qemu/qemu_driver.c
99cbc7
+++ b/src/qemu/qemu_driver.c
99cbc7
@@ -3316,9 +3316,10 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver,
99cbc7
             virDomainDefFree(def);
99cbc7
             goto endjob;
99cbc7
         }
99cbc7
-        xml = qemuDomainDefFormatLive(driver, def, NULL, true, true);
99cbc7
+        xml = qemuDomainDefFormatLive(driver, priv->qemuCaps, def, NULL, true, true);
99cbc7
     } else {
99cbc7
-        xml = qemuDomainDefFormatLive(driver, vm->def, priv->origCPU, true, true);
99cbc7
+        xml = qemuDomainDefFormatLive(driver, priv->qemuCaps, vm->def,
99cbc7
+                                      priv->origCPU, true, true);
99cbc7
     }
99cbc7
     if (!xml) {
99cbc7
         virReportError(VIR_ERR_OPERATION_FAILED,
99cbc7
@@ -6787,7 +6788,7 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
99cbc7
     if (virDomainSaveImageGetXMLDescEnsureACL(conn, def) < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
-    ret = qemuDomainDefFormatXML(driver, def, flags);
99cbc7
+    ret = qemuDomainDefFormatXML(driver, NULL, def, flags);
99cbc7
 
99cbc7
  cleanup:
99cbc7
     virQEMUSaveDataFree(data);
99cbc7
@@ -6840,7 +6841,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
99cbc7
 
99cbc7
     VIR_FREE(data->xml);
99cbc7
 
99cbc7
-    if (!(data->xml = qemuDomainDefFormatXML(driver, newdef,
99cbc7
+    if (!(data->xml = qemuDomainDefFormatXML(driver, NULL, newdef,
99cbc7
                                              VIR_DOMAIN_XML_INACTIVE |
99cbc7
                                              VIR_DOMAIN_XML_SECURE |
99cbc7
                                              VIR_DOMAIN_XML_MIGRATABLE)))
99cbc7
@@ -6879,6 +6880,7 @@ qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, unsigned int flags)
99cbc7
     virDomainDefPtr def = NULL;
99cbc7
     int fd = -1;
99cbc7
     virQEMUSaveDataPtr data = NULL;
99cbc7
+    qemuDomainObjPrivatePtr priv;
99cbc7
 
99cbc7
     /* We only take subset of virDomainDefFormat flags.  */
99cbc7
     virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
99cbc7
@@ -6886,6 +6888,8 @@ qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, unsigned int flags)
99cbc7
     if (!(vm = qemuDomObjFromDomain(dom)))
99cbc7
         return ret;
99cbc7
 
99cbc7
+    priv = vm->privateData;
99cbc7
+
99cbc7
     if (virDomainManagedSaveGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
@@ -6902,7 +6906,7 @@ qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, unsigned int flags)
99cbc7
                                       false, NULL, false, false)) < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
-    ret = qemuDomainDefFormatXML(driver, def, flags);
99cbc7
+    ret = qemuDomainDefFormatXML(driver, priv->qemuCaps, def, flags);
99cbc7
 
99cbc7
  cleanup:
99cbc7
     virQEMUSaveDataFree(data);
99cbc7
@@ -7097,7 +7101,7 @@ static char *qemuConnectDomainXMLFromNative(virConnectPtr conn,
99cbc7
     if (!def->name && VIR_STRDUP(def->name, "unnamed") < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
-    xml = qemuDomainDefFormatXML(driver, def, VIR_DOMAIN_XML_INACTIVE);
99cbc7
+    xml = qemuDomainDefFormatXML(driver, NULL, def, VIR_DOMAIN_XML_INACTIVE);
99cbc7
 
99cbc7
  cleanup:
99cbc7
     virDomainDefFree(def);
99cbc7
@@ -15151,7 +15155,8 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDriverPtr driver,
99cbc7
                                                     "snapshot", false)) < 0)
99cbc7
             goto cleanup;
99cbc7
 
99cbc7
-        if (!(xml = qemuDomainDefFormatLive(driver, vm->def, priv->origCPU,
99cbc7
+        if (!(xml = qemuDomainDefFormatLive(driver, priv->qemuCaps,
99cbc7
+                                            vm->def, priv->origCPU,
99cbc7
                                             true, true)) ||
99cbc7
             !(snap->def->cookie = (virObjectPtr) qemuDomainSaveCookieNew(vm)))
99cbc7
             goto cleanup;
99cbc7
@@ -15395,7 +15400,8 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
99cbc7
     } else {
99cbc7
         /* Easiest way to clone inactive portion of vm->def is via
99cbc7
          * conversion in and back out of xml.  */
99cbc7
-        if (!(xml = qemuDomainDefFormatLive(driver, vm->def, priv->origCPU,
99cbc7
+        if (!(xml = qemuDomainDefFormatLive(driver, priv->qemuCaps,
99cbc7
+                                            vm->def, priv->origCPU,
99cbc7
                                             true, true)) ||
99cbc7
             !(def->dom = virDomainDefParseString(xml, caps, driver->xmlopt, NULL,
99cbc7
                                                  VIR_DOMAIN_DEF_PARSE_INACTIVE |
99cbc7
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
99cbc7
index 4af105b997..111038b971 100644
99cbc7
--- a/src/qemu/qemu_migration.c
99cbc7
+++ b/src/qemu/qemu_migration.c
99cbc7
@@ -2081,9 +2081,9 @@ qemuMigrationSrcBeginPhase(virQEMUDriverPtr driver,
99cbc7
         if (!qemuDomainCheckABIStability(driver, vm, def))
99cbc7
             goto cleanup;
99cbc7
 
99cbc7
-        rv = qemuDomainDefFormatLive(driver, def, NULL, false, true);
99cbc7
+        rv = qemuDomainDefFormatLive(driver, priv->qemuCaps, def, NULL, false, true);
99cbc7
     } else {
99cbc7
-        rv = qemuDomainDefFormatLive(driver, vm->def, priv->origCPU,
99cbc7
+        rv = qemuDomainDefFormatLive(driver, priv->qemuCaps, vm->def, priv->origCPU,
99cbc7
                                      false, true);
99cbc7
     }
99cbc7
 
99cbc7
@@ -2352,7 +2352,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
99cbc7
         char *xml;
99cbc7
         int hookret;
99cbc7
 
99cbc7
-        if (!(xml = qemuDomainDefFormatXML(driver, *def,
99cbc7
+        if (!(xml = qemuDomainDefFormatXML(driver, NULL, *def,
99cbc7
                                            VIR_DOMAIN_XML_SECURE |
99cbc7
                                            VIR_DOMAIN_XML_MIGRATABLE)))
99cbc7
             goto cleanup;
99cbc7
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
99cbc7
index 60df449d53..901b1ae9ac 100644
99cbc7
--- a/src/qemu/qemu_migration_cookie.c
99cbc7
+++ b/src/qemu/qemu_migration_cookie.c
99cbc7
@@ -777,6 +777,7 @@ qemuMigrationCookieCapsXMLFormat(virBufferPtr buf,
99cbc7
 
99cbc7
 static int
99cbc7
 qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver,
99cbc7
+                             virQEMUCapsPtr qemuCaps,
99cbc7
                              virBufferPtr buf,
99cbc7
                              qemuMigrationCookiePtr mig)
99cbc7
 {
99cbc7
@@ -818,6 +819,7 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver,
99cbc7
     if ((mig->flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
99cbc7
         mig->persistent) {
99cbc7
         if (qemuDomainDefFormatBuf(driver,
99cbc7
+                                   qemuCaps,
99cbc7
                                    mig->persistent,
99cbc7
                                    VIR_DOMAIN_XML_INACTIVE |
99cbc7
                                    VIR_DOMAIN_XML_SECURE |
99cbc7
@@ -869,11 +871,12 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver,
99cbc7
 
99cbc7
 static char *
99cbc7
 qemuMigrationCookieXMLFormatStr(virQEMUDriverPtr driver,
99cbc7
+                                virQEMUCapsPtr qemuCaps,
99cbc7
                                 qemuMigrationCookiePtr mig)
99cbc7
 {
99cbc7
     virBuffer buf = VIR_BUFFER_INITIALIZER;
99cbc7
 
99cbc7
-    if (qemuMigrationCookieXMLFormat(driver, &buf, mig) < 0) {
99cbc7
+    if (qemuMigrationCookieXMLFormat(driver, qemuCaps, &buf, mig) < 0) {
99cbc7
         virBufferFreeAndReset(&buf;;
99cbc7
         return NULL;
99cbc7
     }
99cbc7
@@ -1416,6 +1419,8 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
99cbc7
                         int *cookieoutlen,
99cbc7
                         unsigned int flags)
99cbc7
 {
99cbc7
+    qemuDomainObjPrivatePtr priv = dom->privateData;
99cbc7
+
99cbc7
     if (!cookieout || !cookieoutlen)
99cbc7
         return 0;
99cbc7
 
99cbc7
@@ -1459,7 +1464,7 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
99cbc7
         qemuMigrationCookieAddCaps(mig, dom, party) < 0)
99cbc7
         return -1;
99cbc7
 
99cbc7
-    if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
99cbc7
+    if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, priv->qemuCaps, mig)))
99cbc7
         return -1;
99cbc7
 
99cbc7
     *cookieoutlen = strlen(*cookieout) + 1;
99cbc7
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
99cbc7
index 9e6e6528e2..34686b4d92 100644
99cbc7
--- a/src/qemu/qemu_process.c
99cbc7
+++ b/src/qemu/qemu_process.c
99cbc7
@@ -4434,13 +4434,14 @@ qemuProcessStartHook(virQEMUDriverPtr driver,
99cbc7
                      virHookQemuOpType op,
99cbc7
                      virHookSubopType subop)
99cbc7
 {
99cbc7
+    qemuDomainObjPrivatePtr priv = vm->privateData;
99cbc7
     char *xml;
99cbc7
     int ret;
99cbc7
 
99cbc7
     if (!virHookPresent(VIR_HOOK_DRIVER_QEMU))
99cbc7
         return 0;
99cbc7
 
99cbc7
-    if (!(xml = qemuDomainDefFormatXML(driver, vm->def, 0)))
99cbc7
+    if (!(xml = qemuDomainDefFormatXML(driver, priv->qemuCaps, vm->def, 0)))
99cbc7
         return -1;
99cbc7
 
99cbc7
     ret = virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name, op, subop,
99cbc7
@@ -7091,7 +7092,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
99cbc7
 
99cbc7
     /* now that we know it's stopped call the hook if present */
99cbc7
     if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
99cbc7
-        char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
99cbc7
+        char *xml = qemuDomainDefFormatXML(driver, NULL, vm->def, 0);
99cbc7
 
99cbc7
         /* we can't stop the operation even if the script raised an error */
99cbc7
         ignore_value(virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
99cbc7
@@ -7249,7 +7250,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
99cbc7
 
99cbc7
     /* The "release" hook cleans up additional resources */
99cbc7
     if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
99cbc7
-        char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
99cbc7
+        char *xml = qemuDomainDefFormatXML(driver, NULL, vm->def, 0);
99cbc7
 
99cbc7
         /* we can't stop the operation even if the script raised an error */
99cbc7
         virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
99cbc7
@@ -7473,7 +7474,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
99cbc7
 
99cbc7
     /* Run an hook to allow admins to do some magic */
99cbc7
     if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
99cbc7
-        char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
99cbc7
+        char *xml = qemuDomainDefFormatXML(driver, priv->qemuCaps, vm->def, 0);
99cbc7
         int hookret;
99cbc7
 
99cbc7
         hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
99cbc7
@@ -7934,7 +7935,7 @@ qemuProcessReconnect(void *opaque)
99cbc7
 
99cbc7
     /* Run an hook to allow admins to do some magic */
99cbc7
     if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
99cbc7
-        char *xml = qemuDomainDefFormatXML(driver, obj->def, 0);
99cbc7
+        char *xml = qemuDomainDefFormatXML(driver, priv->qemuCaps, obj->def, 0);
99cbc7
         int hookret;
99cbc7
 
99cbc7
         hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, obj->def->name,
99cbc7
-- 
99cbc7
2.22.1
99cbc7