Blame SOURCES/libvirt-qemu-Reject-migration-with-memory-hotplug-if-destination-doesn-t-support-it.patch

7a3408
From 5f602085f03840e9cef0b53d01ab6e9eaf126382 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <5f602085f03840e9cef0b53d01ab6e9eaf126382@dist-git>
7a3408
From: Peter Krempa <pkrempa@redhat.com>
7a3408
Date: Fri, 31 Jul 2015 15:19:26 +0200
7a3408
Subject: [PATCH] qemu: Reject migration with memory-hotplug if destination
7a3408
 doesn't support it
7a3408
7a3408
If destination libvirt doesn't support memory hotplug since all the
7a3408
support was introduced by adding new elements the destination would
7a3408
attempt to start qemu with an invalid configuration. The worse part is
7a3408
that qemu might hang in such situation.
7a3408
7a3408
Fix this by sending a required migration feature called 'memory-hotplug'
7a3408
to the destination. If the destination doesn't recognize it it will fail
7a3408
the migration.
7a3408
7a3408
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1248350
7a3408
(cherry picked from commit 136f3de4112c75af0b38fc1946f44e3658ed1890)
7a3408
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/qemu/qemu_migration.c | 13 ++++++++++++-
7a3408
 1 file changed, 12 insertions(+), 1 deletion(-)
7a3408
7a3408
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
7a3408
index d789110..6386744 100644
7a3408
--- a/src/qemu/qemu_migration.c
7a3408
+++ b/src/qemu/qemu_migration.c
7a3408
@@ -86,6 +86,7 @@ enum qemuMigrationCookieFlags {
7a3408
     QEMU_MIGRATION_COOKIE_FLAG_NETWORK,
7a3408
     QEMU_MIGRATION_COOKIE_FLAG_NBD,
7a3408
     QEMU_MIGRATION_COOKIE_FLAG_STATS,
7a3408
+    QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG,
7a3408
 
7a3408
     QEMU_MIGRATION_COOKIE_FLAG_LAST
7a3408
 };
7a3408
@@ -98,7 +99,8 @@ VIR_ENUM_IMPL(qemuMigrationCookieFlag,
7a3408
               "persistent",
7a3408
               "network",
7a3408
               "nbd",
7a3408
-              "statistics");
7a3408
+              "statistics",
7a3408
+              "memory-hotplug");
7a3408
 
7a3408
 enum qemuMigrationCookieFeatures {
7a3408
     QEMU_MIGRATION_COOKIE_GRAPHICS  = (1 << QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS),
7a3408
@@ -107,6 +109,7 @@ enum qemuMigrationCookieFeatures {
7a3408
     QEMU_MIGRATION_COOKIE_NETWORK = (1 << QEMU_MIGRATION_COOKIE_FLAG_NETWORK),
7a3408
     QEMU_MIGRATION_COOKIE_NBD = (1 << QEMU_MIGRATION_COOKIE_FLAG_NBD),
7a3408
     QEMU_MIGRATION_COOKIE_STATS = (1 << QEMU_MIGRATION_COOKIE_FLAG_STATS),
7a3408
+    QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG = (1 << QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG),
7a3408
 };
7a3408
 
7a3408
 typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
7a3408
@@ -1352,6 +1355,9 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
7a3408
         qemuMigrationCookieAddStatistics(mig, dom) < 0)
7a3408
         return -1;
7a3408
 
7a3408
+    if (flags & QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG)
7a3408
+        mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG;
7a3408
+
7a3408
     if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
7a3408
         return -1;
7a3408
 
7a3408
@@ -2974,6 +2980,11 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
7a3408
         }
7a3408
     }
7a3408
 
7a3408
+    if (vm->def->mem.max_memory ||
7a3408
+        (vm->newDef &&
7a3408
+         vm->newDef->mem.max_memory))
7a3408
+        cookieFlags |= QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG;
7a3408
+
7a3408
     if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0)))
7a3408
         goto cleanup;
7a3408
 
7a3408
-- 
7a3408
2.5.0
7a3408