libvirt/SOURCES/libvirt-cgroup-use-virCgroupSetCpuShares-instead-of-virCgroupSetupCpuShares.patch

147 lines
5.3 KiB
Diff

From 8d08db00d403ddd17cb51d972842c6d13a122d57 Mon Sep 17 00:00:00 2001
Message-Id: <8d08db00d403ddd17cb51d972842c6d13a122d57@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Thu, 4 Mar 2021 12:57:58 +0100
Subject: [PATCH] cgroup: use virCgroupSetCpuShares instead of
virCgroupSetupCpuShares
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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>
(cherry picked from commit e95489d813cb7cc68b02905ce3ec059bc395b465)
Conflicts:
src/lxc/lxc_cgroup.c
src/lxc/lxc_driver.c
src/qemu/qemu_cgroup.c
src/qemu/qemu_driver.c
- downstream doesn't have virCgroupSetupCpuShares() function
so we just remove usage of virCgroupGetCpuShares()
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1798463
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <a7f8e3c0ce4bc22eccbaa25a434d5e72e74d8a65.1614858616.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/lxc/lxc_cgroup.c | 5 -----
src/lxc/lxc_driver.c | 6 +-----
src/qemu/qemu_cgroup.c | 20 --------------------
src/qemu/qemu_driver.c | 8 ++------
4 files changed, 3 insertions(+), 36 deletions(-)
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index 7f3701593a..f785f50754 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -38,13 +38,8 @@ static int virLXCCgroupSetupCpuTune(virDomainDefPtr def,
virCgroupPtr cgroup)
{
if (def->cputune.sharesSpecified) {
- unsigned long long val;
if (virCgroupSetCpuShares(cgroup, def->cputune.shares) < 0)
return -1;
-
- if (virCgroupGetCpuShares(cgroup, &val) < 0)
- return -1;
- def->cputune.shares = val;
}
if (def->cputune.quota != 0 &&
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index a8c93dd228..853ddac8b9 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1909,14 +1909,10 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
if (def) {
- unsigned long long val;
if (virCgroupSetCpuShares(priv->cgroup, params[i].value.ul) < 0)
goto endjob;
- if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
- goto endjob;
-
- def->cputune.shares = val;
+ def->cputune.shares = params[i].value.ul;
def->cputune.sharesSpecified = true;
}
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 3a62b4ac15..95ea5bed74 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -933,10 +933,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) {
@@ -949,24 +945,8 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)
}
if (vm->def->cputune.sharesSpecified) {
- unsigned long long val;
if (virCgroupSetCpuShares(priv->cgroup, vm->def->cputune.shares) < 0)
return -1;
-
- if (virCgroupGetCpuShares(priv->cgroup, &val) < 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;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a1103a96dd..3914d3ff68 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10625,20 +10625,16 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
if (def) {
- unsigned long long val;
if (virCgroupSetCpuShares(priv->cgroup, value_ul) < 0)
goto endjob;
- if (virCgroupGetCpuShares(priv->cgroup, &val) < 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;
}
--
2.30.0