c480ed
From aa652c60bb88208f8a73b8d5ae87eab7cb24d23c Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <aa652c60bb88208f8a73b8d5ae87eab7cb24d23c@dist-git>
c480ed
From: Pavel Hrdina <phrdina@redhat.com>
c480ed
Date: Mon, 1 Jul 2019 17:07:46 +0200
c480ed
Subject: [PATCH] vircgroup: introduce virCgroupV2(Set|Get)CpuShares
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
(cherry picked from commit b8ca5afc22b4d3af3c8637573f1c3d12887fbb0a)
c480ed
c480ed
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
c480ed
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
Message-Id: <5b6c973caaa4b82333949366f034eccaec24277c.1561993100.git.phrdina@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/util/vircgroupv2.c | 23 +++++++++++++++++++++++
c480ed
 1 file changed, 23 insertions(+)
c480ed
c480ed
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
c480ed
index 8d184bd963..cb9dd3d8e8 100644
c480ed
--- a/src/util/vircgroupv2.c
c480ed
+++ b/src/util/vircgroupv2.c
c480ed
@@ -1305,6 +1305,26 @@ virCgroupV2GetMemSwapUsage(virCgroupPtr group,
c480ed
 }
c480ed
 
c480ed
 
c480ed
+static int
c480ed
+virCgroupV2SetCpuShares(virCgroupPtr group,
c480ed
+                        unsigned long long shares)
c480ed
+{
c480ed
+    return virCgroupSetValueU64(group,
c480ed
+                                VIR_CGROUP_CONTROLLER_CPU,
c480ed
+                                "cpu.weight", shares);
c480ed
+}
c480ed
+
c480ed
+
c480ed
+static int
c480ed
+virCgroupV2GetCpuShares(virCgroupPtr group,
c480ed
+                        unsigned long long *shares)
c480ed
+{
c480ed
+    return virCgroupGetValueU64(group,
c480ed
+                                VIR_CGROUP_CONTROLLER_CPU,
c480ed
+                                "cpu.weight", shares);
c480ed
+}
c480ed
+
c480ed
+
c480ed
 virCgroupBackend virCgroupV2Backend = {
c480ed
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
c480ed
 
c480ed
@@ -1352,6 +1372,9 @@ virCgroupBackend virCgroupV2Backend = {
c480ed
     .setMemSwapHardLimit = virCgroupV2SetMemSwapHardLimit,
c480ed
     .getMemSwapHardLimit = virCgroupV2GetMemSwapHardLimit,
c480ed
     .getMemSwapUsage = virCgroupV2GetMemSwapUsage,
c480ed
+
c480ed
+    .setCpuShares = virCgroupV2SetCpuShares,
c480ed
+    .getCpuShares = virCgroupV2GetCpuShares,
c480ed
 };
c480ed
 
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed