[PATCH 08/34] conf: Extract update of vcpu count if maxvcpus is decreased

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The code can be unified into the new accessor rather than being
scattered accross the drivers.
---
 src/conf/domain_conf.c   | 3 +++
 src/libxl/libxl_driver.c | 3 ---
 src/qemu/qemu_driver.c   | 3 ---
 src/test/test_driver.c   | 3 ---
 src/xen/xm_internal.c    | 3 ---
 5 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e0fc09c..6bed826 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1428,6 +1428,9 @@ int
 virDomainDefSetVCpusMax(virDomainDefPtr def,
                         unsigned int vcpus)
 {
+    if (vcpus < def->vcpus)
+        def->vcpus = vcpus;
+
     def->maxvcpus = vcpus;

     return 0;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 5ef0784..e85874a 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -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:
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8ab3209..f879060 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -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;
             }
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 53d9338..cfd7bdc 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2378,9 +2378,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;
         }
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 7321b9f..2838525 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -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;
     }
-- 
2.6.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]