[PATCH v2 03/27] 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 6a77964..99a789b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1434,6 +1434,9 @@ int
 virDomainDefSetVcpusMax(virDomainDefPtr def,
                         unsigned int maxvcpus)
 {
+    if (maxvcpus < def->vcpus)
+        def->vcpus = maxvcpus;
+
     def->maxvcpus = maxvcpus;

     return 0;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index dbc2b78..17d7736 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 5dc7243..6b59687 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 6bf41d7..f579e0e 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 d465576..bf8306a 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]