]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: Move vcpu count check into helper
authorPeter Krempa <pkrempa@redhat.com>
Thu, 22 Oct 2015 09:05:36 +0000 (11:05 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 9 Dec 2015 13:57:12 +0000 (14:57 +0100)
src/conf/domain_conf.c

index 181820f02a74542581456a5bbf98ba9d38c27a48..45347e14b7c7f259fe1c6d9242dbe1e588927051 100644 (file)
@@ -1315,6 +1315,13 @@ int
 virDomainDefSetVcpus(virDomainDefPtr def,
                      unsigned int vcpus)
 {
+    if (vcpus > def->maxvcpus) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("maxvcpus must not be less than current vcpus (%u < %u)"),
+                       vcpus, def->maxvcpus);
+        return -1;
+    }
+
     def->vcpus = vcpus;
 
     return 0;
@@ -14441,13 +14448,6 @@ virDomainVcpuParse(virDomainDefPtr def,
     if (virDomainDefSetVcpus(def, vcpus) < 0)
         goto cleanup;
 
-    if (maxvcpus < def->vcpus) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("maxvcpus must not be less than current vcpus "
-                         "(%u < %u)"), maxvcpus, def->vcpus);
-        goto cleanup;
-    }
-
     tmp = virXPathString("string(./vcpu[1]/@placement)", ctxt);
     if (tmp) {
         if ((def->placement_mode =