3e5111
From 82a4218a06697ee5beaa6ba76704b0156b1a806c Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <82a4218a06697ee5beaa6ba76704b0156b1a806c@dist-git>
3e5111
From: Jiri Denemark <jdenemar@redhat.com>
3e5111
Date: Tue, 2 May 2017 18:56:06 +0200
3e5111
Subject: [PATCH] qemu: Fix persistent migration of transient domains
3e5111
3e5111
While fixing a bug with incorrectly freed memory in commit
3e5111
v3.1.0-399-g5498aa29a, I accidentally broke persistent migration of
3e5111
transient domains. Before adding qemuDomainDefCopy in the path, the code
3e5111
just took NULL from vm->newDef and used it as the persistent def, which
3e5111
resulted in no persistent XML being sent in the migration cookie. This
3e5111
scenario is perfectly valid and the destination correctly handles it by
3e5111
using the incoming live definition and storing it as the persistent one.
3e5111
3e5111
After the mentioned commit libvirtd would just segfault in the described
3e5111
scenario.
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1446205
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
(cherry picked from commit 59307fade86fb74db1f8f572433962233f7ac123)
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_migration.c | 16 ++++++++--------
3e5111
 1 file changed, 8 insertions(+), 8 deletions(-)
3e5111
3e5111
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
3e5111
index ac7e27319..5bf9bd10f 100644
3e5111
--- a/src/qemu/qemu_migration.c
3e5111
+++ b/src/qemu/qemu_migration.c
3e5111
@@ -3609,15 +3609,15 @@ qemuMigrationRun(virQEMUDriverPtr driver,
3e5111
 
3e5111
     if (flags & VIR_MIGRATE_PERSIST_DEST) {
3e5111
         if (persist_xml) {
3e5111
-            persistDef = qemuMigrationPrepareDef(driver, persist_xml,
3e5111
-                                                 NULL, NULL);
3e5111
-        } else {
3e5111
-            persistDef = qemuDomainDefCopy(driver, vm->newDef,
3e5111
-                                           VIR_DOMAIN_XML_SECURE |
3e5111
-                                           VIR_DOMAIN_XML_MIGRATABLE);
3e5111
+            if (!(persistDef = qemuMigrationPrepareDef(driver, persist_xml,
3e5111
+                                                       NULL, NULL)))
3e5111
+                goto cleanup;
3e5111
+        } else if (vm->newDef) {
3e5111
+            if (!(persistDef = qemuDomainDefCopy(driver, vm->newDef,
3e5111
+                                                 VIR_DOMAIN_XML_SECURE |
3e5111
+                                                 VIR_DOMAIN_XML_MIGRATABLE)))
3e5111
+                goto cleanup;
3e5111
         }
3e5111
-        if (!persistDef)
3e5111
-            goto cleanup;
3e5111
     }
3e5111
 
3e5111
     mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
3e5111
-- 
3e5111
2.12.2
3e5111