]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: Extract update of vcpu count if maxvcpus is decreased
authorPeter Krempa <pkrempa@redhat.com>
Mon, 19 Oct 2015 11:36:08 +0000 (13:36 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 9 Dec 2015 13:57:12 +0000 (14:57 +0100)
The code can be unified into the new accessor rather than being
scattered accross the drivers.

src/conf/domain_conf.c
src/libxl/libxl_driver.c
src/qemu/qemu_driver.c
src/test/test_driver.c
src/xen/xm_internal.c

index 91b045d04a1e8aae4bec303158c6f258306945f0..5370a089f11f67676d57118f96e566c4c3d970a3 100644 (file)
@@ -1288,6 +1288,9 @@ int
 virDomainDefSetVcpusMax(virDomainDefPtr def,
                         unsigned int maxvcpus)
 {
+    if (maxvcpus < def->vcpus)
+        def->vcpus = maxvcpus;
+
     def->maxvcpus = maxvcpus;
 
     return 0;
index 80f5907375ba31447e7236b13914abdaff2ae8c6..f65cfb221a2def7cdd1c27b17149f70f158b38c6 100644 (file)
@@ -2188,9 +2188,6 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
     case VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_CONFIG:
         if (virDomainDefSetVcpusMax(def, nvcpus) < 0)
             goto cleanup;
-
-        if (nvcpus < def->vcpus)
-            def->vcpus = nvcpus;
         break;
 
     case VIR_DOMAIN_VCPU_CONFIG:
index 5dc72436b57c46d8b60175b0f48d76408c644d94..6b59687f714dd71918addbc287761848778be96f 100644 (file)
@@ -4981,9 +4981,6 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
             if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
                 if (virDomainDefSetVcpusMax(persistentDef, nvcpus) < 0)
                     goto endjob;
-
-                if (nvcpus < persistentDef->vcpus)
-                    persistentDef->vcpus = nvcpus;
             } else {
                 persistentDef->vcpus = nvcpus;
             }
index de0043adf298b724818ddb7771325625952fd4e9..d4d8e56840fd768a7bd6179ef56e903a70122e80 100644 (file)
@@ -2379,9 +2379,6 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
         if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
             if (virDomainDefSetVcpusMax(persistentDef, nrCpus) < 0)
                 goto cleanup;
-
-            if (nrCpus < persistentDef->vcpus)
-                persistentDef->vcpus = nrCpus;
         } else {
             persistentDef->vcpus = nrCpus;
         }
index 7b0c30518b72171fc954b4440d1fb4d7daba53cd..c324fdc2c4a67f48c7707c881abda31ddf05007f 100644 (file)
@@ -706,9 +706,6 @@ xenXMDomainSetVcpusFlags(virConnectPtr conn,
     if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
         if (virDomainDefSetVcpusMax(entry->def, vcpus) < 0)
             goto cleanup;
-
-        if (entry->def->vcpus > vcpus)
-            entry->def->vcpus = vcpus;
     } else {
         entry->def->vcpus = vcpus;
     }