6d3351
From bf20b6cf07e5462c892b5e3c3d76a3c354606ea4 Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <bf20b6cf07e5462c892b5e3c3d76a3c354606ea4@dist-git>
6d3351
From: Jiri Denemark <jdenemar@redhat.com>
6d3351
Date: Wed, 14 Jun 2017 13:43:37 +0200
6d3351
Subject: [PATCH] qemu: Add qemuDomainCheckABIStability
6d3351
6d3351
When making ABI stability checks for an active domain, we need to make
6d3351
sure we use the same migratable definition which virDomainGetXMLDesc
6d3351
with the MIGRATABLE flag provides, otherwise the ABI check will fail.
6d3351
This is implemented in the new qemuDomainCheckABIStability which takes a
6d3351
domain object and generates the right migratable definition from it.
6d3351
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6d3351
(cherry picked from commit 063b2b8788db204d0ac2e1d367fd0c5eb9b81451)
6d3351
6d3351
https://bugzilla.redhat.com/show_bug.cgi?id=1460952
6d3351
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 src/qemu/qemu_domain.c | 41 ++++++++++++++++++++++++++++++++++++-----
6d3351
 src/qemu/qemu_domain.h |  4 ++++
6d3351
 2 files changed, 40 insertions(+), 5 deletions(-)
6d3351
6d3351
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
6d3351
index b3dc2bc3ac..1528c6a137 100644
6d3351
--- a/src/qemu/qemu_domain.c
6d3351
+++ b/src/qemu/qemu_domain.c
6d3351
@@ -5909,6 +5909,10 @@ qemuDomainMigratableDefCheckABIStability(virQEMUDriverPtr driver,
6d3351
 }
6d3351
 
6d3351
 
6d3351
+#define COPY_FLAGS (VIR_DOMAIN_XML_SECURE | \
6d3351
+                    VIR_DOMAIN_XML_UPDATE_CPU | \
6d3351
+                    VIR_DOMAIN_XML_MIGRATABLE)
6d3351
+
6d3351
 bool
6d3351
 qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
6d3351
                                virDomainDefPtr src,
6d3351
@@ -5916,13 +5920,10 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
6d3351
 {
6d3351
     virDomainDefPtr migratableDefSrc = NULL;
6d3351
     virDomainDefPtr migratableDefDst = NULL;
6d3351
-    const unsigned int flags = VIR_DOMAIN_XML_SECURE |
6d3351
-                               VIR_DOMAIN_XML_UPDATE_CPU |
6d3351
-                               VIR_DOMAIN_XML_MIGRATABLE;
6d3351
     bool ret = false;
6d3351
 
6d3351
-    if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, flags)) ||
6d3351
-        !(migratableDefDst = qemuDomainDefCopy(driver, dst, flags)))
6d3351
+    if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, COPY_FLAGS)) ||
6d3351
+        !(migratableDefDst = qemuDomainDefCopy(driver, dst, COPY_FLAGS)))
6d3351
         goto cleanup;
6d3351
 
6d3351
     ret = qemuDomainMigratableDefCheckABIStability(driver,
6d3351
@@ -5935,6 +5936,36 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
6d3351
     return ret;
6d3351
 }
6d3351
 
6d3351
+
6d3351
+bool
6d3351
+qemuDomainCheckABIStability(virQEMUDriverPtr driver,
6d3351
+                            virDomainObjPtr vm,
6d3351
+                            virDomainDefPtr dst)
6d3351
+{
6d3351
+    virDomainDefPtr migratableSrc = NULL;
6d3351
+    virDomainDefPtr migratableDst = NULL;
6d3351
+    char *xml = NULL;
6d3351
+    bool ret = false;
6d3351
+
6d3351
+    if (!(xml = qemuDomainFormatXML(driver, vm, COPY_FLAGS)) ||
6d3351
+        !(migratableSrc = qemuDomainDefFromXML(driver, xml)) ||
6d3351
+        !(migratableDst = qemuDomainDefCopy(driver, dst, COPY_FLAGS)))
6d3351
+        goto cleanup;
6d3351
+
6d3351
+    ret = qemuDomainMigratableDefCheckABIStability(driver,
6d3351
+                                                   vm->def, migratableSrc,
6d3351
+                                                   dst, migratableDst);
6d3351
+
6d3351
+ cleanup:
6d3351
+    VIR_FREE(xml);
6d3351
+    virDomainDefFree(migratableSrc);
6d3351
+    virDomainDefFree(migratableDst);
6d3351
+    return ret;
6d3351
+}
6d3351
+
6d3351
+#undef COPY_FLAGS
6d3351
+
6d3351
+
6d3351
 bool
6d3351
 qemuDomainAgentAvailable(virDomainObjPtr vm,
6d3351
                          bool reportError)
6d3351
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
6d3351
index d635d2995f..7ad34e563e 100644
6d3351
--- a/src/qemu/qemu_domain.h
6d3351
+++ b/src/qemu/qemu_domain.h
6d3351
@@ -668,6 +668,10 @@ bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
6d3351
                                     virDomainDefPtr src,
6d3351
                                     virDomainDefPtr dst);
6d3351
 
6d3351
+bool qemuDomainCheckABIStability(virQEMUDriverPtr driver,
6d3351
+                                 virDomainObjPtr vm,
6d3351
+                                 virDomainDefPtr dst);
6d3351
+
6d3351
 bool qemuDomainAgentAvailable(virDomainObjPtr vm,
6d3351
                               bool reportError);
6d3351
 
6d3351
-- 
6d3351
2.13.1
6d3351