Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/vircgroupv2.c | 43 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 9f37ff5be5..06522498f2 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1132,6 +1132,47 @@ virCgroupV2GetMemoryUsage(virCgroupPtr group,
}
+static int
+virCgroupV2SetMemoryHardLimit(virCgroupPtr group,
+ unsigned long long kb)
+{
+ return virCgroupV2SetMemory(group, kb);
+}
+
+
+static int
+virCgroupV2GetMemoryHardLimit(virCgroupPtr group,
+ unsigned long long *kb)
+{
+ VIR_AUTOFREE(char *) value = NULL;
+ unsigned long long max;
+
+ if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_MEMORY,
+ "memory.max", &value) < 0) {
+ return -1;
+ }
+
+ if (STREQ(value, "max")) {
+ *kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
+ return 0;
+ }
+
+ if (virStrToLong_ull(value, NULL, 10, &max) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to parse value '%s' as number."),
+ value);
+ return -1;
+ }
+
+ *kb = max >> 10;
+ if (*kb >= VIR_DOMAIN_MEMORY_PARAM_UNLIMITED)
+ *kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
+
+ return 0;
+}
+
+
virCgroupBackend virCgroupV2Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V2,
@@ -1172,6 +1213,8 @@ virCgroupBackend virCgroupV2Backend = {
.setMemory = virCgroupV2SetMemory,
.getMemoryStat = virCgroupV2GetMemoryStat,
.getMemoryUsage = virCgroupV2GetMemoryUsage,
+ .setMemoryHardLimit = virCgroupV2SetMemoryHardLimit,
+ .getMemoryHardLimit = virCgroupV2GetMemoryHardLimit,
};
--
2.17.1