|
|
3e5111 |
From b6f6759fcada504563b4c439975bee66fd611162 Mon Sep 17 00:00:00 2001
|
|
|
3e5111 |
Message-Id: <b6f6759fcada504563b4c439975bee66fd611162@dist-git>
|
|
|
3e5111 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
3e5111 |
Date: Tue, 4 Apr 2017 09:31:24 +0200
|
|
|
3e5111 |
Subject: [PATCH] qemu: hotplug: Validate that vcpu-hotplug does not break
|
|
|
3e5111 |
config
|
|
|
3e5111 |
|
|
|
3e5111 |
Make sure that non-hotpluggable vcpus stay clustered at the beginning
|
|
|
3e5111 |
after modifying persistent definition.
|
|
|
3e5111 |
|
|
|
3e5111 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1437010
|
|
|
3e5111 |
(cherry picked from commit 079832103c3b7883e36db90705631cc55cac9dcc)
|
|
|
3e5111 |
---
|
|
|
3e5111 |
src/qemu/qemu_hotplug.c | 26 ++++++++++++++++++++++++--
|
|
|
3e5111 |
1 file changed, 24 insertions(+), 2 deletions(-)
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
3e5111 |
index 999c8b804..a6dac6f09 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
3e5111 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
3e5111 |
@@ -5876,9 +5876,14 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
|
|
|
3e5111 |
|
|
|
3e5111 |
|
|
|
3e5111 |
static int
|
|
|
3e5111 |
-qemuDomainVcpuValidateConfig(virBitmapPtr map,
|
|
|
3e5111 |
+qemuDomainVcpuValidateConfig(virDomainDefPtr def,
|
|
|
3e5111 |
+ virBitmapPtr map,
|
|
|
3e5111 |
bool state)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
+ virDomainVcpuDefPtr vcpu;
|
|
|
3e5111 |
+ size_t maxvcpus = virDomainDefGetVcpusMax(def);
|
|
|
3e5111 |
+ ssize_t next;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
/* vcpu 0 can't be disabled */
|
|
|
3e5111 |
if (!state && virBitmapIsBitSet(map, 0)) {
|
|
|
3e5111 |
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
|
|
3e5111 |
@@ -5886,6 +5891,23 @@ qemuDomainVcpuValidateConfig(virBitmapPtr map,
|
|
|
3e5111 |
return -1;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
+ /* non-hotpluggable vcpus need to stay clustered starting from vcpu 0 */
|
|
|
3e5111 |
+ for (next = virBitmapNextSetBit(map, -1) + 1; next < maxvcpus; next++) {
|
|
|
3e5111 |
+ if (!(vcpu = virDomainDefGetVcpu(def, next)))
|
|
|
3e5111 |
+ continue;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ /* skip vcpus being modified */
|
|
|
3e5111 |
+ if (virBitmapIsBitSet(map, next))
|
|
|
3e5111 |
+ continue;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ if (vcpu->online && vcpu->hotpluggable == VIR_TRISTATE_BOOL_NO) {
|
|
|
3e5111 |
+ virReportError(VIR_ERR_INVALID_ARG,
|
|
|
3e5111 |
+ _("vcpu '%zd' can't be modified as it is followed "
|
|
|
3e5111 |
+ "by non-hotpluggable online vcpus"), next);
|
|
|
3e5111 |
+ return -1;
|
|
|
3e5111 |
+ }
|
|
|
3e5111 |
+ }
|
|
|
3e5111 |
+
|
|
|
3e5111 |
return 0;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -5925,7 +5947,7 @@ qemuDomainSetVcpuInternal(virQEMUDriverPtr driver,
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
if (persistentDef) {
|
|
|
3e5111 |
- if (qemuDomainVcpuValidateConfig(map, state) < 0)
|
|
|
3e5111 |
+ if (qemuDomainVcpuValidateConfig(persistentDef, map, state) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
--
|
|
|
3e5111 |
2.12.2
|
|
|
3e5111 |
|