|
|
c480ed |
From d9dca0b3b1ad64bcde8d96b05538d4656ca93af3 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <d9dca0b3b1ad64bcde8d96b05538d4656ca93af3@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:07:42 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: introduce virCgroupV2(Set|Get)MemoryHardLimit
|
|
|
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 2aa5385c58d50270d7084f8d11a22ac993275dc0)
|
|
|
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: <dc9320d118699dc39071dc1f15b1094112cf5a04.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroupv2.c | 43 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
c480ed |
1 file changed, 43 insertions(+)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
|
c480ed |
index 87d357b0a7..81a577d28f 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv2.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv2.c
|
|
|
c480ed |
@@ -1130,6 +1130,47 @@ virCgroupV2GetMemoryUsage(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV2SetMemoryHardLimit(virCgroupPtr group,
|
|
|
c480ed |
+ unsigned long long kb)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ return virCgroupV2SetMemory(group, kb);
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV2GetMemoryHardLimit(virCgroupPtr group,
|
|
|
c480ed |
+ unsigned long long *kb)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) value = NULL;
|
|
|
c480ed |
+ unsigned long long max;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virCgroupGetValueStr(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ "memory.max", &value) < 0) {
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (STREQ(value, "max")) {
|
|
|
c480ed |
+ *kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virStrToLong_ull(value, NULL, 10, &max) < 0) {
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
+ _("Failed to parse value '%s' as number."),
|
|
|
c480ed |
+ value);
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ *kb = max >> 10;
|
|
|
c480ed |
+ if (*kb >= VIR_DOMAIN_MEMORY_PARAM_UNLIMITED)
|
|
|
c480ed |
+ *kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1170,6 +1211,8 @@ virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.setMemory = virCgroupV2SetMemory,
|
|
|
c480ed |
.getMemoryStat = virCgroupV2GetMemoryStat,
|
|
|
c480ed |
.getMemoryUsage = virCgroupV2GetMemoryUsage,
|
|
|
c480ed |
+ .setMemoryHardLimit = virCgroupV2SetMemoryHardLimit,
|
|
|
c480ed |
+ .getMemoryHardLimit = virCgroupV2GetMemoryHardLimit,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|