mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
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
This commit is contained in:
parent
ee86d45de3
commit
079832103c
@ -5876,9 +5876,14 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainVcpuValidateConfig(virBitmapPtr map,
|
qemuDomainVcpuValidateConfig(virDomainDefPtr def,
|
||||||
|
virBitmapPtr map,
|
||||||
bool state)
|
bool state)
|
||||||
{
|
{
|
||||||
|
virDomainVcpuDefPtr vcpu;
|
||||||
|
size_t maxvcpus = virDomainDefGetVcpusMax(def);
|
||||||
|
ssize_t next;
|
||||||
|
|
||||||
/* vcpu 0 can't be disabled */
|
/* vcpu 0 can't be disabled */
|
||||||
if (!state && virBitmapIsBitSet(map, 0)) {
|
if (!state && virBitmapIsBitSet(map, 0)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
@ -5886,6 +5891,23 @@ qemuDomainVcpuValidateConfig(virBitmapPtr map,
|
|||||||
return -1;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5925,7 +5947,7 @@ qemuDomainSetVcpuInternal(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
if (qemuDomainVcpuValidateConfig(map, state) < 0)
|
if (qemuDomainVcpuValidateConfig(persistentDef, map, state) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user