[PATCH] qemu: allow restore with non-migratable XML input

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Convert input XML to migratable before using it in
qemuDomainSaveImageOpen.

XML in the save image is migratable, i.e. doesn't contain implicit
controllers. If these controllers were in a non-default order in the
input XML, the ABI check would fail. Removing and re-adding these
controllers fixes it.

https://bugzilla.redhat.com/show_bug.cgi?id=834196
---
 src/qemu/qemu_domain.c | 29 +++++++++++++++++++++++++++++
 src/qemu/qemu_domain.h |  4 ++++
 src/qemu/qemu_driver.c | 13 ++++++++++---
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index fdcf7bc..8d79066 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1275,6 +1275,35 @@ void qemuDomainObjExitRemote(virDomainObjPtr obj)
 }
 
 
+virDomainDefPtr
+qemuDomainDefCopy(virQEMUDriverPtr driver,
+                  virDomainDefPtr src,
+                  unsigned int flags)
+{
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    virDomainDefPtr ret = NULL;
+    virCapsPtr caps = NULL;
+    const char *xml = NULL;
+
+    if (qemuDomainDefFormatBuf(driver, src, flags, &buf) < 0)
+        goto cleanup;
+
+    xml = virBufferContentAndReset(&buf);
+
+    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
+        goto cleanup;
+
+    if (!(ret = virDomainDefParseString(xml, caps, driver->xmlopt,
+                                        QEMU_EXPECTED_VIRT_TYPES,
+                                        VIR_DOMAIN_XML_INACTIVE)))
+        goto cleanup;
+
+cleanup:
+    VIR_FREE(xml);
+    virObjectUnref(caps);
+    return ret;
+}
+
 int
 qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
                        virDomainDefPtr def,
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index f241296..068a4c3 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -241,6 +241,10 @@ void qemuDomainObjEnterRemote(virDomainObjPtr obj)
 void qemuDomainObjExitRemote(virDomainObjPtr obj)
     ATTRIBUTE_NONNULL(1);
 
+virDomainDefPtr qemuDomainDefCopy(virQEMUDriverPtr driver,
+                                  virDomainDefPtr src,
+                                  unsigned int flags);
+
 int qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
                            virDomainDefPtr vm,
                            unsigned int flags,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c886378..93c7d14 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4877,17 +4877,24 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
         goto error;
     if (xmlin) {
         virDomainDefPtr def2 = NULL;
+        virDomainDefPtr newdef = NULL;
 
         if (!(def2 = virDomainDefParseString(xmlin, caps, driver->xmlopt,
                                              QEMU_EXPECTED_VIRT_TYPES,
                                              VIR_DOMAIN_XML_INACTIVE)))
             goto error;
-        if (!virDomainDefCheckABIStability(def, def2)) {
-            virDomainDefFree(def2);
+
+        newdef = qemuDomainDefCopy(driver, def2, VIR_DOMAIN_XML_MIGRATABLE);
+        virDomainDefFree(def2);
+        if (!newdef)
+            goto error;
+
+        if (!virDomainDefCheckABIStability(def, newdef)) {
+            virDomainDefFree(newdef);
             goto error;
         }
         virDomainDefFree(def);
-        def = def2;
+        def = newdef;
     }
 
     VIR_FREE(xml);
-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]