]> xenbits.xensource.com Git - libvirt.git/commitdiff
lib: Don't short circuit around virDomainCgroupSetupVcpuBW()
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 1 Apr 2022 11:13:10 +0000 (13:13 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 7 Apr 2022 10:11:50 +0000 (12:11 +0200)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/hypervisor/domain_cgroup.c
src/qemu/qemu_driver.c
src/qemu/qemu_process.c

index fc0ad284c8033dc86fad69c10c565e82522fc356..920ec8c895b94330d835b2b62c3c7d7e24e870a6 100644 (file)
@@ -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;
 }
index 26647a9ae393d996404ac2d5ec719468c78f1a91..1eac27366acfa55e0ed6037c4d7f3f6a39f4a63d 100644 (file)
@@ -8929,9 +8929,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;
 
@@ -9110,9 +9107,6 @@ qemuSetVcpusBWLive(virDomainObj *vm, virCgroup *cgroup,
 {
     size_t i;
 
-    if (period == 0 && quota == 0)
-        return 0;
-
     if (!qemuDomainHasVcpuPids(vm))
         return 0;
 
@@ -9141,9 +9135,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;
@@ -9161,9 +9152,6 @@ qemuSetIOThreadsBWLive(virDomainObj *vm, virCgroup *cgroup,
 {
     size_t i;
 
-    if (period == 0 && quota == 0)
-        return 0;
-
     if (!vm->def->niothreadids)
         return 0;
 
index f63fc3389d170d6b91d8cf17a65ce0b1469f08fa..b1c506a552885f04529c0dd34019a9f8a2d067e1 100644 (file)
@@ -2695,8 +2695,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 */