[libvirt] [PATCH] qemu: Fix persistent migration of transient domains

Jiri Denemark posted 1 patch 6 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/abc71ee8867a850e8aca35d220742b8f16d62aa5.1493742739.git.jdenemar@redhat.com
src/qemu/qemu_migration.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
[libvirt] [PATCH] qemu: Fix persistent migration of transient domains
Posted by Jiri Denemark 6 years, 11 months ago
While fixing a bug with incorrectly freed memory in commit
v3.1.0-399-g5498aa29a, I accidentally broke persistent migration of
transient domains. Before adding qemuDomainDefCopy in the path, the code
just took NULL from vm->newDef and used it as the persistent def, which
resulted in no persistent XML being sent in the migration cookie. This
scenario is perfectly valid and the destination correctly handles it by
using the incoming live definition and storing it as the persistent one.

After the mentioned commit libvirtd would just segfault in the described
scenario.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_migration.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 30f98da1e..3c0d7e957 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3640,15 +3640,15 @@ qemuMigrationRun(virQEMUDriverPtr driver,
 
     if (flags & VIR_MIGRATE_PERSIST_DEST) {
         if (persist_xml) {
-            persistDef = qemuMigrationPrepareDef(driver, persist_xml,
-                                                 NULL, NULL);
-        } else {
-            persistDef = qemuDomainDefCopy(driver, vm->newDef,
-                                           VIR_DOMAIN_XML_SECURE |
-                                           VIR_DOMAIN_XML_MIGRATABLE);
+            if (!(persistDef = qemuMigrationPrepareDef(driver, persist_xml,
+                                                       NULL, NULL)))
+                goto cleanup;
+        } else if (vm->newDef) {
+            if (!(persistDef = qemuDomainDefCopy(driver, vm->newDef,
+                                                 VIR_DOMAIN_XML_SECURE |
+                                                 VIR_DOMAIN_XML_MIGRATABLE)))
+                goto cleanup;
         }
-        if (!persistDef)
-            goto cleanup;
     }
 
     mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
-- 
2.12.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Fix persistent migration of transient domains
Posted by Pavel Hrdina 6 years, 11 months ago
On Tue, May 02, 2017 at 06:32:19PM +0200, Jiri Denemark wrote:
> While fixing a bug with incorrectly freed memory in commit
> v3.1.0-399-g5498aa29a, I accidentally broke persistent migration of
> transient domains. Before adding qemuDomainDefCopy in the path, the code
> just took NULL from vm->newDef and used it as the persistent def, which
> resulted in no persistent XML being sent in the migration cookie. This
> scenario is perfectly valid and the destination correctly handles it by
> using the incoming live definition and storing it as the persistent one.
> 
> After the mentioned commit libvirtd would just segfault in the described
> scenario.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1446205
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/qemu/qemu_migration.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list