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",
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;
}
}
if (persistentDef) {
- if (qemuDomainVcpuValidateConfig(map, state) < 0)
+ if (qemuDomainVcpuValidateConfig(persistentDef, map, state) < 0)
goto cleanup;
}