File libvirt-qemu-Fix-checking-of-ABI-stability-when-restoring-external-checkpoints.patch of Package libvirt

From 04c122d8f6fc7e57e6a91228095541d72a5075c5 Mon Sep 17 00:00:00 2001
Message-Id: <04c122d8f6fc7e57e6a91228095541d72a5075c5@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 5 Jan 2015 17:33:35 +0100
Subject: [PATCH] qemu: Fix checking of ABI stability when restoring external
 checkpoints
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

https://bugzilla.redhat.com/show_bug.cgi?id=834196

External checkpoints have a bug in the implementation where they use the
normal definition instead of the "migratable" one. This causes errors
when the snapshot is being reverted using the workaround method via
qemuDomainRestoreFlags() with a custom XML. This issue was introduced
when commit 07966f6a8b5ccb5bb4c716b25deb8ba2e572cc67 changed the code to
compare "migratable" XMLs from the user as we should have used
migratable in the image too.

This patch adds a compatibility layer, so that fixing the snapshot code
won't make existing snapshots fail to load.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1008340
(cherry picked from commit 59898a88ce8431bd3ea249b8789edc2ef9985827)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_driver.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index df2e8f9..8d62869 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5450,14 +5450,31 @@ qemuDomainSaveImageOpen(struct qemud_driver *driver,
             goto error;
 
         newdef = qemuDomainDefCopy(driver, def2, VIR_DOMAIN_XML_MIGRATABLE);
-        virDomainDefFree(def2);
-        if (!newdef)
+        if (!newdef) {
+            virDomainDefFree(def2);
             goto error;
+        }
 
         if (!virDomainDefCheckABIStability(def, newdef)) {
             virDomainDefFree(newdef);
-            goto error;
+            virResetLastError();
+
+            /* Due to a bug in older version of external snapshot creation
+             * code, the XML saved in the save image was not a migratable
+             * XML. To ensure backwards compatibility with the change of the
+             * saved XML type, we need to check the ABI compatibility against
+             * the user provided XML if the check against the migratable XML
+             * fails. Snapshots created prior to v1.1.3 have this issue. */
+            if (!virDomainDefCheckABIStability(def, def2)) {
+                virDomainDefFree(def2);
+                goto error;
+            }
+
+            /* use the user provided XML */
+            newdef = def2;
+            def2 = NULL;
         }
+
         virDomainDefFree(def);
         def = newdef;
     }
-- 
2.2.2

openSUSE Build Service is sponsored by