render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
3e5111
From f33ea433e58c5fbd356d4085446a64f8a67496e5 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <f33ea433e58c5fbd356d4085446a64f8a67496e5@dist-git>
3e5111
From: Jiri Denemark <jdenemar@redhat.com>
3e5111
Date: Fri, 26 May 2017 17:06:56 +0200
3e5111
Subject: [PATCH] qemu: Send updated CPU in migration cookie
3e5111
3e5111
Since the domain XML send during migration uses the original guest CPU
3e5111
definition but we still want the destination to enforce ABI if it is new
3e5111
enough, we send the live updated CPU definition in a migration cookie.
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3e5111
(cherry picked from commit 48bc3053b8f2bfa3adc93d3c316d48d0f482cde4)
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1441662
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_migration.c        |  6 +++++-
3e5111
 src/qemu/qemu_migration_cookie.c | 31 ++++++++++++++++++++++++++++++-
3e5111
 src/qemu/qemu_migration_cookie.h |  5 +++++
3e5111
 3 files changed, 40 insertions(+), 2 deletions(-)
3e5111
3e5111
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
3e5111
index a7c90a09e8..c03f1be575 100644
3e5111
--- a/src/qemu/qemu_migration.c
3e5111
+++ b/src/qemu/qemu_migration.c
3e5111
@@ -1989,6 +1989,9 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
3e5111
          vm->newDef && !qemuDomainVcpuHotplugIsInOrder(vm->newDef)))
3e5111
         cookieFlags |= QEMU_MIGRATION_COOKIE_CPU_HOTPLUG;
3e5111
 
3e5111
+    if (priv->origCPU)
3e5111
+        cookieFlags |= QEMU_MIGRATION_COOKIE_CPU;
3e5111
+
3e5111
     if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0)))
3e5111
         goto cleanup;
3e5111
 
3e5111
@@ -2613,7 +2616,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
3e5111
                                        QEMU_MIGRATION_COOKIE_LOCKSTATE |
3e5111
                                        QEMU_MIGRATION_COOKIE_NBD |
3e5111
                                        QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG |
3e5111
-                                       QEMU_MIGRATION_COOKIE_CPU_HOTPLUG)))
3e5111
+                                       QEMU_MIGRATION_COOKIE_CPU_HOTPLUG |
3e5111
+                                       QEMU_MIGRATION_COOKIE_CPU)))
3e5111
         goto cleanup;
3e5111
 
3e5111
     if (STREQ_NULLABLE(protocol, "rdma") &&
3e5111
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
3e5111
index 559b1f0c15..af0ac03418 100644
3e5111
--- a/src/qemu/qemu_migration_cookie.c
3e5111
+++ b/src/qemu/qemu_migration_cookie.c
3e5111
@@ -48,7 +48,8 @@ VIR_ENUM_IMPL(qemuMigrationCookieFlag,
3e5111
               "nbd",
3e5111
               "statistics",
3e5111
               "memory-hotplug",
3e5111
-              "cpu-hotplug");
3e5111
+              "cpu-hotplug",
3e5111
+              "cpu");
3e5111
 
3e5111
 
3e5111
 static void
3e5111
@@ -109,6 +110,7 @@ qemuMigrationCookieFree(qemuMigrationCookiePtr mig)
3e5111
     VIR_FREE(mig->lockState);
3e5111
     VIR_FREE(mig->lockDriver);
3e5111
     VIR_FREE(mig->jobInfo);
3e5111
+    virCPUDefFree(mig->cpu);
3e5111
     VIR_FREE(mig);
3e5111
 }
3e5111
 
3e5111
@@ -519,6 +521,22 @@ qemuMigrationCookieAddStatistics(qemuMigrationCookiePtr mig,
3e5111
 }
3e5111
 
3e5111
 
3e5111
+static int
3e5111
+qemuMigrationCookieAddCPU(qemuMigrationCookiePtr mig,
3e5111
+                          virDomainObjPtr vm)
3e5111
+{
3e5111
+    if (mig->cpu)
3e5111
+        return 0;
3e5111
+
3e5111
+    if (!(mig->cpu = virCPUDefCopy(vm->def->cpu)))
3e5111
+        return -1;
3e5111
+
3e5111
+    mig->flags |= QEMU_MIGRATION_COOKIE_CPU;
3e5111
+
3e5111
+    return 0;
3e5111
+}
3e5111
+
3e5111
+
3e5111
 static void
3e5111
 qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf,
3e5111
                                      qemuMigrationCookieGraphicsPtr grap)
3e5111
@@ -755,6 +773,9 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver,
3e5111
     if (mig->flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo)
3e5111
         qemuMigrationCookieStatisticsXMLFormat(buf, mig->jobInfo);
3e5111
 
3e5111
+    if (mig->flags & QEMU_MIGRATION_COOKIE_CPU && mig->cpu)
3e5111
+        virCPUDefFormatBufFull(buf, mig->cpu, NULL, false);
3e5111
+
3e5111
     virBufferAdjustIndent(buf, -2);
3e5111
     virBufferAddLit(buf, "</qemu-migration>\n");
3e5111
     return 0;
3e5111
@@ -1198,6 +1219,10 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
3e5111
         (!(mig->jobInfo = qemuMigrationCookieStatisticsXMLParse(ctxt))))
3e5111
         goto error;
3e5111
 
3e5111
+    if (flags & QEMU_MIGRATION_COOKIE_CPU &&
3e5111
+        virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &mig->cpu) < 0)
3e5111
+        goto error;
3e5111
+
3e5111
     virObjectUnref(caps);
3e5111
     return 0;
3e5111
 
3e5111
@@ -1274,6 +1299,10 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
3e5111
     if (flags & QEMU_MIGRATION_COOKIE_CPU_HOTPLUG)
3e5111
         mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_CPU_HOTPLUG;
3e5111
 
3e5111
+    if (flags & QEMU_MIGRATION_COOKIE_CPU &&
3e5111
+        qemuMigrationCookieAddCPU(mig, dom) < 0)
3e5111
+        return -1;
3e5111
+
3e5111
     if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
3e5111
         return -1;
3e5111
 
3e5111
diff --git a/src/qemu/qemu_migration_cookie.h b/src/qemu/qemu_migration_cookie.h
3e5111
index b009d5bf5d..e5f3d75a95 100644
3e5111
--- a/src/qemu/qemu_migration_cookie.h
3e5111
+++ b/src/qemu/qemu_migration_cookie.h
3e5111
@@ -28,6 +28,7 @@ typedef enum {
3e5111
     QEMU_MIGRATION_COOKIE_FLAG_STATS,
3e5111
     QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG,
3e5111
     QEMU_MIGRATION_COOKIE_FLAG_CPU_HOTPLUG,
3e5111
+    QEMU_MIGRATION_COOKIE_FLAG_CPU,
3e5111
 
3e5111
     QEMU_MIGRATION_COOKIE_FLAG_LAST
3e5111
 } qemuMigrationCookieFlags;
3e5111
@@ -43,6 +44,7 @@ typedef enum {
3e5111
     QEMU_MIGRATION_COOKIE_STATS = (1 << QEMU_MIGRATION_COOKIE_FLAG_STATS),
3e5111
     QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG = (1 << QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG),
3e5111
     QEMU_MIGRATION_COOKIE_CPU_HOTPLUG = (1 << QEMU_MIGRATION_COOKIE_FLAG_CPU_HOTPLUG),
3e5111
+    QEMU_MIGRATION_COOKIE_CPU = (1 << QEMU_MIGRATION_COOKIE_FLAG_CPU),
3e5111
 } qemuMigrationCookieFeatures;
3e5111
 
3e5111
 typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
3e5111
@@ -122,6 +124,9 @@ struct _qemuMigrationCookie {
3e5111
 
3e5111
     /* If (flags & QEMU_MIGRATION_COOKIE_STATS) */
3e5111
     qemuDomainJobInfoPtr jobInfo;
3e5111
+
3e5111
+    /* If flags & QEMU_MIGRATION_COOKIE_CPU */
3e5111
+    virCPUDefPtr cpu;
3e5111
 };
3e5111
 
3e5111
 
3e5111
-- 
3e5111
2.13.1
3e5111