qemu: Error out if setting vcpu count would lead to invalid config

When the domain definition describes a machine with NUMA, setting the
maximum vCPU count via the API might lead to an invalid config.

Add a check that will forbid this until we add more advanced cpu config
capabilities.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1327499
This commit is contained in:
Peter Krempa 2016-04-27 16:39:41 +02:00
parent 63e2b766a5
commit b527e7c8e2
2 changed files with 8 additions and 0 deletions

View File

@ -674,6 +674,7 @@ virNodeDeviceObjUnlock;
virDomainNumaCheckABIStability;
virDomainNumaEquals;
virDomainNumaFree;
virDomainNumaGetCPUCountTotal;
virDomainNumaGetMaxCPUID;
virDomainNumaGetMemorySize;
virDomainNumaGetNodeCount;

View File

@ -4903,6 +4903,13 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
if (persistentDef) {
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
if (virDomainNumaGetCPUCountTotal(persistentDef->numa) > nvcpus) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Number of CPUs in <numa> exceeds the desired "
"maximum vcpu count"));
goto endjob;
}
if (virDomainDefSetVcpusMax(persistentDef, nvcpus) < 0)
goto endjob;
} else {