1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

cgroup: use virCgroupSetCpuShares instead of virCgroupSetupCpuShares

Now that we enforce the cpu.shares range kernel will no longer silently
change the value that libvirt configures so there is no need to read
the value back to get the actual configuration.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Pavel Hrdina 2021-03-03 14:26:53 +01:00
parent 1d9d9961ad
commit e95489d813
4 changed files with 7 additions and 31 deletions

View File

@ -39,10 +39,8 @@ static int virLXCCgroupSetupCpuTune(virDomainDefPtr def,
virCgroupPtr cgroup)
{
if (def->cputune.sharesSpecified) {
unsigned long long val;
if (virCgroupSetupCpuShares(cgroup, def->cputune.shares, &val) < 0)
if (virCgroupSetCpuShares(cgroup, def->cputune.shares) < 0)
return -1;
def->cputune.shares = val;
}
return virCgroupSetupCpuPeriodQuota(cgroup, def->cputune.period,

View File

@ -1868,12 +1868,10 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
if (def) {
unsigned long long val;
if (virCgroupSetupCpuShares(priv->cgroup, params[i].value.ul,
&val) < 0)
if (virCgroupSetCpuShares(priv->cgroup, params[i].value.ul) < 0)
goto endjob;
def->cputune.shares = val;
def->cputune.shares = params[i].value.ul;
def->cputune.sharesSpecified = true;
}

View File

@ -880,10 +880,6 @@ static int
qemuSetupCpuCgroup(virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virObjectEventPtr event = NULL;
virTypedParameterPtr eventParams = NULL;
int eventNparams = 0;
int eventMaxparams = 0;
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
if (vm->def->cputune.sharesSpecified) {
@ -896,23 +892,8 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)
}
if (vm->def->cputune.sharesSpecified) {
unsigned long long val;
if (virCgroupSetupCpuShares(priv->cgroup, vm->def->cputune.shares,
&val) < 0)
if (virCgroupSetCpuShares(priv->cgroup, vm->def->cputune.shares) < 0)
return -1;
if (vm->def->cputune.shares != val) {
vm->def->cputune.shares = val;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES,
val) < 0)
return -1;
event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams);
}
virObjectEventStateQueue(priv->driver->domainEventState, event);
}
return 0;

View File

@ -9324,17 +9324,16 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
if (def) {
unsigned long long val;
if (virCgroupSetupCpuShares(priv->cgroup, value_ul, &val) < 0)
if (virCgroupSetCpuShares(priv->cgroup, value_ul) < 0)
goto endjob;
def->cputune.shares = val;
def->cputune.shares = value_ul;
def->cputune.sharesSpecified = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxNparams,
VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES,
val) < 0)
value_ul) < 0)
goto endjob;
}