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
---
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ad5c382..769bdb7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -673,6 +673,7 @@ virNodeDeviceObjUnlock;
virDomainNumaCheckABIStability;
virDomainNumaEquals;
virDomainNumaFree;
+virDomainNumaGetCPUCountTotal;
virDomainNumaGetMaxCPUID;
virDomainNumaGetMemorySize;
virDomainNumaGetNodeCount;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 542d13c..44ec42d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4898,6 +4898,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 {
--
2.8.1