提交 07983210 编写于 作者: P Peter Krempa

qemu: hotplug: Validate that vcpu-hotplug does not break config

Make sure that non-hotpluggable vcpus stay clustered at the beginning
after modifying persistent definition.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1437010
上级 ee86d45d
......@@ -5876,9 +5876,14 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
static int
qemuDomainVcpuValidateConfig(virBitmapPtr map,
qemuDomainVcpuValidateConfig(virDomainDefPtr def,
virBitmapPtr map,
bool state)
{
virDomainVcpuDefPtr vcpu;
size_t maxvcpus = virDomainDefGetVcpusMax(def);
ssize_t next;
/* vcpu 0 can't be disabled */
if (!state && virBitmapIsBitSet(map, 0)) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
......@@ -5886,6 +5891,23 @@ qemuDomainVcpuValidateConfig(virBitmapPtr map,
return -1;
}
/* non-hotpluggable vcpus need to stay clustered starting from vcpu 0 */
for (next = virBitmapNextSetBit(map, -1) + 1; next < maxvcpus; next++) {
if (!(vcpu = virDomainDefGetVcpu(def, next)))
continue;
/* skip vcpus being modified */
if (virBitmapIsBitSet(map, next))
continue;
if (vcpu->online && vcpu->hotpluggable == VIR_TRISTATE_BOOL_NO) {
virReportError(VIR_ERR_INVALID_ARG,
_("vcpu '%zd' can't be modified as it is followed "
"by non-hotpluggable online vcpus"), next);
return -1;
}
}
return 0;
}
......@@ -5925,7 +5947,7 @@ qemuDomainSetVcpuInternal(virQEMUDriverPtr driver,
}
if (persistentDef) {
if (qemuDomainVcpuValidateConfig(map, state) < 0)
if (qemuDomainVcpuValidateConfig(persistentDef, map, state) < 0)
goto cleanup;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册