lib: Don't short circuit around virDomainCgroupSetupVcpuBW()

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>
This commit is contained in:
Michal Privoznik 2022-04-01 13:13:10 +02:00
parent 19a5b054ac
commit cc4542e5d3
3 changed files with 3 additions and 18 deletions

View 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;
}

View 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;

View 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 */