]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Error out if setting vcpu count would lead to invalid config
authorPeter Krempa <pkrempa@redhat.com>
Wed, 27 Apr 2016 14:39:41 +0000 (16:39 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 28 Apr 2016 07:25:32 +0000 (09:25 +0200)
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
src/qemu/qemu_driver.c

index 0de35efb258528984e3792114091ef2e09708063..5030ec3a1521930f15111918843d33e767848ec5 100644 (file)
@@ -674,6 +674,7 @@ virNodeDeviceObjUnlock;
 virDomainNumaCheckABIStability;
 virDomainNumaEquals;
 virDomainNumaFree;
+virDomainNumaGetCPUCountTotal;
 virDomainNumaGetMaxCPUID;
 virDomainNumaGetMemorySize;
 virDomainNumaGetNodeCount;
index 5992492ebddc747d9fb72d9e714026e23fb0f027..e5badf637af641a75d073bc0657789cc5da38721 100644 (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 {