|
|
c480ed |
From 9697d24cc223028555629af325af8607de350d06 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <9697d24cc223028555629af325af8607de350d06@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:07:39 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: introduce virCgroupV2SetMemory
|
|
|
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 63bd23a6ad17331cdc31bc07fd8b21a96d4b2eb0)
|
|
|
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: <d2076f596f9e8b58571e19334f23e295f72a2ee5.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroupv2.c | 29 +++++++++++++++++++++++++++++
|
|
|
c480ed |
1 file changed, 29 insertions(+)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
|
c480ed |
index 52d31925c2..1b7215d98b 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv2.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv2.c
|
|
|
c480ed |
@@ -1015,6 +1015,33 @@ virCgroupV2GetBlkioDeviceWriteBps(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV2SetMemory(virCgroupPtr group,
|
|
|
c480ed |
+ unsigned long long kb)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ unsigned long long maxkb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (kb > maxkb) {
|
|
|
c480ed |
+ virReportError(VIR_ERR_INVALID_ARG,
|
|
|
c480ed |
+ _("Memory '%llu' must be less than %llu"),
|
|
|
c480ed |
+ kb, maxkb);
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (kb == maxkb) {
|
|
|
c480ed |
+ return virCgroupSetValueStr(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ "memory.max",
|
|
|
c480ed |
+ "max");
|
|
|
c480ed |
+ } else {
|
|
|
c480ed |
+ return virCgroupSetValueU64(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ "memory.max",
|
|
|
c480ed |
+ kb << 10);
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1051,6 +1078,8 @@ virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.getBlkioDeviceReadBps = virCgroupV2GetBlkioDeviceReadBps,
|
|
|
c480ed |
.setBlkioDeviceWriteBps = virCgroupV2SetBlkioDeviceWriteBps,
|
|
|
c480ed |
.getBlkioDeviceWriteBps = virCgroupV2GetBlkioDeviceWriteBps,
|
|
|
c480ed |
+
|
|
|
c480ed |
+ .setMemory = virCgroupV2SetMemory,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|