From cc4542e5d348f5943626ea5d7b2d922c992eeb1c Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Fri, 1 Apr 2022 13:13:10 +0200 Subject: [PATCH] lib: Don't short circuit around virDomainCgroupSetupVcpuBW() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- 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 26647a9ae3..1eac27366a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f63fc3389d..b1c506a552 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -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 */