|
|
6ae9ed |
From 6e1a906b835301aef822702b62b11969ae4d0f26 Mon Sep 17 00:00:00 2001
|
|
|
6ae9ed |
Message-Id: <6e1a906b835301aef822702b62b11969ae4d0f26@dist-git>
|
|
|
6ae9ed |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
6ae9ed |
Date: Wed, 24 Aug 2016 16:11:34 -0400
|
|
|
6ae9ed |
Subject: [PATCH] qemu: migration: Prepare for non-contiguous vcpu
|
|
|
6ae9ed |
configurations
|
|
|
6ae9ed |
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1097930
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1224341
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Introduce a new migration cookie flag that will be used for any
|
|
|
6ae9ed |
configurations that are not compatible with libvirt that would not
|
|
|
6ae9ed |
support the specific vcpu hotplug approach. This will make sure that old
|
|
|
6ae9ed |
libvirt does not fail to reproduce the configuration correctly.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
(cherry picked from commit 48e3d42889dcf3f7cec24c0bf4fd55c8da5f324b)
|
|
|
6ae9ed |
---
|
|
|
6ae9ed |
src/qemu/qemu_domain.c | 35 +++++++++++++++++++++++++++++++++++
|
|
|
6ae9ed |
src/qemu/qemu_domain.h | 3 +++
|
|
|
6ae9ed |
src/qemu/qemu_migration.c | 16 ++++++++++++++--
|
|
|
6ae9ed |
3 files changed, 52 insertions(+), 2 deletions(-)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
6ae9ed |
index 7a71bfb..07c42a0 100644
|
|
|
6ae9ed |
--- a/src/qemu/qemu_domain.c
|
|
|
6ae9ed |
+++ b/src/qemu/qemu_domain.c
|
|
|
6ae9ed |
@@ -5914,3 +5914,38 @@ qemuDomainPrepareChannel(virDomainChrDefPtr channel,
|
|
|
6ae9ed |
|
|
|
6ae9ed |
return 0;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+/**
|
|
|
6ae9ed |
+ * qemuDomainVcpuHotplugIsInOrder:
|
|
|
6ae9ed |
+ * @def: domain definition
|
|
|
6ae9ed |
+ *
|
|
|
6ae9ed |
+ * Returns true if online vcpus were added in order (clustered behind vcpu0
|
|
|
6ae9ed |
+ * with increasing order).
|
|
|
6ae9ed |
+ */
|
|
|
6ae9ed |
+bool
|
|
|
6ae9ed |
+qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
|
|
|
6ae9ed |
+{
|
|
|
6ae9ed |
+ size_t maxvcpus = virDomainDefGetVcpusMax(def);
|
|
|
6ae9ed |
+ virDomainVcpuDefPtr vcpu;
|
|
|
6ae9ed |
+ unsigned int prevorder = 0;
|
|
|
6ae9ed |
+ size_t seenonlinevcpus = 0;
|
|
|
6ae9ed |
+ size_t i;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ for (i = 0; i < maxvcpus; i++) {
|
|
|
6ae9ed |
+ vcpu = virDomainDefGetVcpu(def, i);
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (!vcpu->online)
|
|
|
6ae9ed |
+ break;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (vcpu->order < prevorder)
|
|
|
6ae9ed |
+ break;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (vcpu->order > prevorder)
|
|
|
6ae9ed |
+ prevorder = vcpu->order;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ seenonlinevcpus++;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ return seenonlinevcpus == virDomainDefGetVcpus(def);
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
|
|
6ae9ed |
index 76b6904..3a80769 100644
|
|
|
6ae9ed |
--- a/src/qemu/qemu_domain.h
|
|
|
6ae9ed |
+++ b/src/qemu/qemu_domain.h
|
|
|
6ae9ed |
@@ -724,4 +724,7 @@ int qemuDomainPrepareChannel(virDomainChrDefPtr chr,
|
|
|
6ae9ed |
const char *domainChannelTargetDir)
|
|
|
6ae9ed |
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
|
|
|
6ae9ed |
+ ATTRIBUTE_NONNULL(1);
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
#endif /* __QEMU_DOMAIN_H__ */
|
|
|
6ae9ed |
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
|
|
|
6ae9ed |
index 463e624..ae70f2a 100644
|
|
|
6ae9ed |
--- a/src/qemu/qemu_migration.c
|
|
|
6ae9ed |
+++ b/src/qemu/qemu_migration.c
|
|
|
6ae9ed |
@@ -92,6 +92,7 @@ enum qemuMigrationCookieFlags {
|
|
|
6ae9ed |
QEMU_MIGRATION_COOKIE_FLAG_NBD,
|
|
|
6ae9ed |
QEMU_MIGRATION_COOKIE_FLAG_STATS,
|
|
|
6ae9ed |
QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG,
|
|
|
6ae9ed |
+ QEMU_MIGRATION_COOKIE_FLAG_CPU_HOTPLUG,
|
|
|
6ae9ed |
|
|
|
6ae9ed |
QEMU_MIGRATION_COOKIE_FLAG_LAST
|
|
|
6ae9ed |
};
|
|
|
6ae9ed |
@@ -105,7 +106,8 @@ VIR_ENUM_IMPL(qemuMigrationCookieFlag,
|
|
|
6ae9ed |
"network",
|
|
|
6ae9ed |
"nbd",
|
|
|
6ae9ed |
"statistics",
|
|
|
6ae9ed |
- "memory-hotplug");
|
|
|
6ae9ed |
+ "memory-hotplug",
|
|
|
6ae9ed |
+ "cpu-hotplug");
|
|
|
6ae9ed |
|
|
|
6ae9ed |
enum qemuMigrationCookieFeatures {
|
|
|
6ae9ed |
QEMU_MIGRATION_COOKIE_GRAPHICS = (1 << QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS),
|
|
|
6ae9ed |
@@ -115,6 +117,7 @@ enum qemuMigrationCookieFeatures {
|
|
|
6ae9ed |
QEMU_MIGRATION_COOKIE_NBD = (1 << QEMU_MIGRATION_COOKIE_FLAG_NBD),
|
|
|
6ae9ed |
QEMU_MIGRATION_COOKIE_STATS = (1 << QEMU_MIGRATION_COOKIE_FLAG_STATS),
|
|
|
6ae9ed |
QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG = (1 << QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG),
|
|
|
6ae9ed |
+ QEMU_MIGRATION_COOKIE_CPU_HOTPLUG = (1 << QEMU_MIGRATION_COOKIE_FLAG_CPU_HOTPLUG),
|
|
|
6ae9ed |
};
|
|
|
6ae9ed |
|
|
|
6ae9ed |
typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
|
|
|
6ae9ed |
@@ -1408,6 +1411,9 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
|
|
|
6ae9ed |
if (flags & QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG)
|
|
|
6ae9ed |
mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+ if (flags & QEMU_MIGRATION_COOKIE_CPU_HOTPLUG)
|
|
|
6ae9ed |
+ mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_CPU_HOTPLUG;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
|
|
|
6ae9ed |
return -1;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
@@ -3195,6 +3201,11 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
vm->newDef && virDomainDefHasMemoryHotplug(vm->newDef)))
|
|
|
6ae9ed |
cookieFlags |= QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+ if (!qemuDomainVcpuHotplugIsInOrder(vm->def) ||
|
|
|
6ae9ed |
+ ((flags & VIR_MIGRATE_PERSIST_DEST) &&
|
|
|
6ae9ed |
+ vm->newDef && !qemuDomainVcpuHotplugIsInOrder(vm->newDef)))
|
|
|
6ae9ed |
+ cookieFlags |= QEMU_MIGRATION_COOKIE_CPU_HOTPLUG;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0)))
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
@@ -3690,7 +3701,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
|
|
|
6ae9ed |
QEMU_MIGRATION_COOKIE_LOCKSTATE |
|
|
|
6ae9ed |
QEMU_MIGRATION_COOKIE_NBD |
|
|
|
6ae9ed |
- QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG)))
|
|
|
6ae9ed |
+ QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG |
|
|
|
6ae9ed |
+ QEMU_MIGRATION_COOKIE_CPU_HOTPLUG)))
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
if (STREQ_NULLABLE(protocol, "rdma") &&
|
|
|
6ae9ed |
--
|
|
|
6ae9ed |
2.10.0
|
|
|
6ae9ed |
|