[PATCH 1/4] lib: Don't short circuit around virDomainCgroupSetupVcpuBW()

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

 



The virDomainCgroupSetupVcpuBW() is a NOP if both period and
quota to set are zero. There's no need to check in all the
callers for this special case.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/hypervisor/domain_cgroup.c |  6 ++----
 src/qemu/qemu_driver.c         | 12 ------------
 src/qemu/qemu_process.c        |  3 +--
 3 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/src/hypervisor/domain_cgroup.c b/src/hypervisor/domain_cgroup.c
index fc0ad284c8..920ec8c895 100644
--- a/src/hypervisor/domain_cgroup.c
+++ b/src/hypervisor/domain_cgroup.c
@@ -603,10 +603,8 @@ virDomainCgroupSetupGlobalCpuCgroup(virDomainObj *vm,
                                             autoNodeset, &mem_mask, -1) < 0)
         return -1;
 
-    if (period || quota) {
-        if (virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0)
-            return -1;
-    }
+    if (virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0)
+        return -1;
 
     return 0;
 }
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 77012eb527..547af4384f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8923,9 +8923,6 @@ static int
 qemuSetGlobalBWLive(virCgroup *cgroup, unsigned long long period,
                     long long quota)
 {
-    if (period == 0 && quota == 0)
-        return 0;
-
     if (virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0)
         return -1;
 
@@ -9104,9 +9101,6 @@ qemuSetVcpusBWLive(virDomainObj *vm, virCgroup *cgroup,
 {
     size_t i;
 
-    if (period == 0 && quota == 0)
-        return 0;
-
     if (!qemuDomainHasVcpuPids(vm))
         return 0;
 
@@ -9135,9 +9129,6 @@ qemuSetEmulatorBandwidthLive(virCgroup *cgroup,
 {
     g_autoptr(virCgroup) cgroup_emulator = NULL;
 
-    if (period == 0 && quota == 0)
-        return 0;
-
     if (virCgroupNewThread(cgroup, VIR_CGROUP_THREAD_EMULATOR, 0,
                            false, &cgroup_emulator) < 0)
         return -1;
@@ -9155,9 +9146,6 @@ qemuSetIOThreadsBWLive(virDomainObj *vm, virCgroup *cgroup,
 {
     size_t i;
 
-    if (period == 0 && quota == 0)
-        return 0;
-
     if (!vm->def->niothreadids)
         return 0;
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index f110e4f3dd..f3eb742406 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2699,8 +2699,7 @@ qemuProcessSetupPid(virDomainObj *vm,
 
         }
 
-        if ((period || quota) &&
-            virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0)
+        if (virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0)
             goto cleanup;
 
         /* Move the thread to the sub dir */
-- 
2.35.1




[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]

  Powered by Linux