|
|
8c03ec |
From 8d08db00d403ddd17cb51d972842c6d13a122d57 Mon Sep 17 00:00:00 2001
|
|
|
8c03ec |
Message-Id: <8d08db00d403ddd17cb51d972842c6d13a122d57@dist-git>
|
|
|
8c03ec |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
8c03ec |
Date: Thu, 4 Mar 2021 12:57:58 +0100
|
|
|
8c03ec |
Subject: [PATCH] cgroup: use virCgroupSetCpuShares instead of
|
|
|
8c03ec |
virCgroupSetupCpuShares
|
|
|
8c03ec |
MIME-Version: 1.0
|
|
|
8c03ec |
Content-Type: text/plain; charset=UTF-8
|
|
|
8c03ec |
Content-Transfer-Encoding: 8bit
|
|
|
8c03ec |
|
|
|
8c03ec |
Now that we enforce the cpu.shares range kernel will no longer silently
|
|
|
8c03ec |
change the value that libvirt configures so there is no need to read
|
|
|
8c03ec |
the value back to get the actual configuration.
|
|
|
8c03ec |
|
|
|
8c03ec |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
8c03ec |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
8c03ec |
(cherry picked from commit e95489d813cb7cc68b02905ce3ec059bc395b465)
|
|
|
8c03ec |
|
|
|
8c03ec |
Conflicts:
|
|
|
8c03ec |
src/lxc/lxc_cgroup.c
|
|
|
8c03ec |
src/lxc/lxc_driver.c
|
|
|
8c03ec |
src/qemu/qemu_cgroup.c
|
|
|
8c03ec |
src/qemu/qemu_driver.c
|
|
|
8c03ec |
- downstream doesn't have virCgroupSetupCpuShares() function
|
|
|
8c03ec |
so we just remove usage of virCgroupGetCpuShares()
|
|
|
8c03ec |
|
|
|
8c03ec |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1798463
|
|
|
8c03ec |
|
|
|
8c03ec |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
8c03ec |
Message-Id: <a7f8e3c0ce4bc22eccbaa25a434d5e72e74d8a65.1614858616.git.phrdina@redhat.com>
|
|
|
8c03ec |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
8c03ec |
---
|
|
|
8c03ec |
src/lxc/lxc_cgroup.c | 5 -----
|
|
|
8c03ec |
src/lxc/lxc_driver.c | 6 +-----
|
|
|
8c03ec |
src/qemu/qemu_cgroup.c | 20 --------------------
|
|
|
8c03ec |
src/qemu/qemu_driver.c | 8 ++------
|
|
|
8c03ec |
4 files changed, 3 insertions(+), 36 deletions(-)
|
|
|
8c03ec |
|
|
|
8c03ec |
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
|
|
|
8c03ec |
index 7f3701593a..f785f50754 100644
|
|
|
8c03ec |
--- a/src/lxc/lxc_cgroup.c
|
|
|
8c03ec |
+++ b/src/lxc/lxc_cgroup.c
|
|
|
8c03ec |
@@ -38,13 +38,8 @@ static int virLXCCgroupSetupCpuTune(virDomainDefPtr def,
|
|
|
8c03ec |
virCgroupPtr cgroup)
|
|
|
8c03ec |
{
|
|
|
8c03ec |
if (def->cputune.sharesSpecified) {
|
|
|
8c03ec |
- unsigned long long val;
|
|
|
8c03ec |
if (virCgroupSetCpuShares(cgroup, def->cputune.shares) < 0)
|
|
|
8c03ec |
return -1;
|
|
|
8c03ec |
-
|
|
|
8c03ec |
- if (virCgroupGetCpuShares(cgroup, &val) < 0)
|
|
|
8c03ec |
- return -1;
|
|
|
8c03ec |
- def->cputune.shares = val;
|
|
|
8c03ec |
}
|
|
|
8c03ec |
|
|
|
8c03ec |
if (def->cputune.quota != 0 &&
|
|
|
8c03ec |
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
|
|
|
8c03ec |
index a8c93dd228..853ddac8b9 100644
|
|
|
8c03ec |
--- a/src/lxc/lxc_driver.c
|
|
|
8c03ec |
+++ b/src/lxc/lxc_driver.c
|
|
|
8c03ec |
@@ -1909,14 +1909,10 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|
|
8c03ec |
|
|
|
8c03ec |
if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
|
|
|
8c03ec |
if (def) {
|
|
|
8c03ec |
- unsigned long long val;
|
|
|
8c03ec |
if (virCgroupSetCpuShares(priv->cgroup, params[i].value.ul) < 0)
|
|
|
8c03ec |
goto endjob;
|
|
|
8c03ec |
|
|
|
8c03ec |
- if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
|
|
|
8c03ec |
- goto endjob;
|
|
|
8c03ec |
-
|
|
|
8c03ec |
- def->cputune.shares = val;
|
|
|
8c03ec |
+ def->cputune.shares = params[i].value.ul;
|
|
|
8c03ec |
def->cputune.sharesSpecified = true;
|
|
|
8c03ec |
}
|
|
|
8c03ec |
|
|
|
8c03ec |
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
|
|
|
8c03ec |
index 3a62b4ac15..95ea5bed74 100644
|
|
|
8c03ec |
--- a/src/qemu/qemu_cgroup.c
|
|
|
8c03ec |
+++ b/src/qemu/qemu_cgroup.c
|
|
|
8c03ec |
@@ -933,10 +933,6 @@ static int
|
|
|
8c03ec |
qemuSetupCpuCgroup(virDomainObjPtr vm)
|
|
|
8c03ec |
{
|
|
|
8c03ec |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
8c03ec |
- virObjectEventPtr event = NULL;
|
|
|
8c03ec |
- virTypedParameterPtr eventParams = NULL;
|
|
|
8c03ec |
- int eventNparams = 0;
|
|
|
8c03ec |
- int eventMaxparams = 0;
|
|
|
8c03ec |
|
|
|
8c03ec |
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
|
|
|
8c03ec |
if (vm->def->cputune.sharesSpecified) {
|
|
|
8c03ec |
@@ -949,24 +945,8 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)
|
|
|
8c03ec |
}
|
|
|
8c03ec |
|
|
|
8c03ec |
if (vm->def->cputune.sharesSpecified) {
|
|
|
8c03ec |
- unsigned long long val;
|
|
|
8c03ec |
if (virCgroupSetCpuShares(priv->cgroup, vm->def->cputune.shares) < 0)
|
|
|
8c03ec |
return -1;
|
|
|
8c03ec |
-
|
|
|
8c03ec |
- if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
|
|
|
8c03ec |
- return -1;
|
|
|
8c03ec |
- if (vm->def->cputune.shares != val) {
|
|
|
8c03ec |
- vm->def->cputune.shares = val;
|
|
|
8c03ec |
- if (virTypedParamsAddULLong(&eventParams, &eventNparams,
|
|
|
8c03ec |
- &eventMaxparams,
|
|
|
8c03ec |
- VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES,
|
|
|
8c03ec |
- val) < 0)
|
|
|
8c03ec |
- return -1;
|
|
|
8c03ec |
-
|
|
|
8c03ec |
- event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams);
|
|
|
8c03ec |
- }
|
|
|
8c03ec |
-
|
|
|
8c03ec |
- virObjectEventStateQueue(priv->driver->domainEventState, event);
|
|
|
8c03ec |
}
|
|
|
8c03ec |
|
|
|
8c03ec |
return 0;
|
|
|
8c03ec |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
8c03ec |
index a1103a96dd..3914d3ff68 100644
|
|
|
8c03ec |
--- a/src/qemu/qemu_driver.c
|
|
|
8c03ec |
+++ b/src/qemu/qemu_driver.c
|
|
|
8c03ec |
@@ -10625,20 +10625,16 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|
|
8c03ec |
|
|
|
8c03ec |
if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
|
|
|
8c03ec |
if (def) {
|
|
|
8c03ec |
- unsigned long long val;
|
|
|
8c03ec |
if (virCgroupSetCpuShares(priv->cgroup, value_ul) < 0)
|
|
|
8c03ec |
goto endjob;
|
|
|
8c03ec |
|
|
|
8c03ec |
- if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
|
|
|
8c03ec |
- goto endjob;
|
|
|
8c03ec |
-
|
|
|
8c03ec |
- def->cputune.shares = val;
|
|
|
8c03ec |
+ def->cputune.shares = value_ul;
|
|
|
8c03ec |
def->cputune.sharesSpecified = true;
|
|
|
8c03ec |
|
|
|
8c03ec |
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
|
|
|
8c03ec |
&eventMaxNparams,
|
|
|
8c03ec |
VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES,
|
|
|
8c03ec |
- val) < 0)
|
|
|
8c03ec |
+ value_ul) < 0)
|
|
|
8c03ec |
goto endjob;
|
|
|
8c03ec |
}
|
|
|
8c03ec |
|
|
|
8c03ec |
--
|
|
|
8c03ec |
2.30.0
|
|
|
8c03ec |
|