From b527e7c8e2e13c194cf32fee76d3be3d89365524 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 27 Apr 2016 16:39:41 +0200 Subject: [PATCH] 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 --- 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 0de35efb25..5030ec3a15 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -674,6 +674,7 @@ virNodeDeviceObjUnlock; virDomainNumaCheckABIStability; virDomainNumaEquals; virDomainNumaFree; +virDomainNumaGetCPUCountTotal; virDomainNumaGetMaxCPUID; virDomainNumaGetMemorySize; virDomainNumaGetNodeCount; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5992492ebd..e5badf637a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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 exceeds the desired " + "maximum vcpu count")); + goto endjob; + } + if (virDomainDefSetVcpusMax(persistentDef, nvcpus) < 0) goto endjob; } else {