render / rpms / libvirt

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