render / rpms / libvirt

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