[PATCH v2 28/53] [ACKED] vircgroup: introduce virCgroupV2SetMemory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/util/vircgroupv2.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index cf0cac1a5b..2255bbbef5 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1023,6 +1023,33 @@ virCgroupV2GetBlkioDeviceWriteBps(virCgroupPtr group,
 }
 
 
+static int
+virCgroupV2SetMemory(virCgroupPtr group,
+                     unsigned long long kb)
+{
+    unsigned long long maxkb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
+
+    if (kb > maxkb) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("Memory '%llu' must be less than %llu"),
+                       kb, maxkb);
+        return -1;
+    }
+
+    if (kb == maxkb) {
+        return virCgroupSetValueStr(group,
+                                    VIR_CGROUP_CONTROLLER_MEMORY,
+                                    "memory.max",
+                                    "max");
+    } else {
+        return virCgroupSetValueU64(group,
+                                    VIR_CGROUP_CONTROLLER_MEMORY,
+                                    "memory.max",
+                                    kb << 10);
+    }
+}
+
+
 virCgroupBackend virCgroupV2Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
 
@@ -1059,6 +1086,8 @@ virCgroupBackend virCgroupV2Backend = {
     .getBlkioDeviceReadBps = virCgroupV2GetBlkioDeviceReadBps,
     .setBlkioDeviceWriteBps = virCgroupV2SetBlkioDeviceWriteBps,
     .getBlkioDeviceWriteBps = virCgroupV2GetBlkioDeviceWriteBps,
+
+    .setMemory = virCgroupV2SetMemory,
 };
 
 
-- 
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux