]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: process: refactor and rename qemuValidateCpuMax to qemuValidateCpuCount
authorPeter Krempa <pkrempa@redhat.com>
Wed, 6 Jan 2016 15:22:10 +0000 (16:22 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 25 Jan 2016 16:45:09 +0000 (17:45 +0100)
Next patch will add minimum checking, so use a more generic name.
Refactor return values to the commonly used semantics.

src/qemu/qemu_process.c

index d465b4fac6682adbf5a6441bc48370257ee0673c..506979771fc396f0d1de6b854830a1e880b6dcbf 100644 (file)
@@ -3891,22 +3891,19 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
 }
 
 
-static bool
-qemuValidateCpuMax(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
+static int
+qemuValidateCpuCount(virDomainDefPtr def,
+                     virQEMUCapsPtr qemuCaps)
 {
-    unsigned int maxCpus;
-
-    maxCpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, def->os.machine);
-    if (!maxCpus)
-        return true;
+    unsigned int maxCpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, def->os.machine);
 
-    if (virDomainDefGetVcpusMax(def) > maxCpus) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       "%s", _("Maximum CPUs greater than specified machine type limit"));
-        return false;
+    if (maxCpus > 0 && virDomainDefGetVcpusMax(def) > maxCpus) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Maximum CPUs greater than specified machine type limit"));
+        return -1;
     }
 
-    return true;
+    return 0;
 }
 
 
@@ -4697,7 +4694,7 @@ qemuProcessLaunch(virConnectPtr conn,
         }
     }
 
-    if (!qemuValidateCpuMax(vm->def, priv->qemuCaps))
+    if (qemuValidateCpuCount(vm->def, priv->qemuCaps) < 0)
         goto cleanup;
 
     if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)