Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/vircgroupv2.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index fcc42e3df1..51e08fe74b 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1124,6 +1124,20 @@ virCgroupV2GetMemoryStat(virCgroupPtr group,
}
+static int
+virCgroupV2GetMemoryUsage(virCgroupPtr group,
+ unsigned long *kb)
+{
+ unsigned long long usage_in_bytes;
+ int ret = virCgroupGetValueU64(group,
+ VIR_CGROUP_CONTROLLER_MEMORY,
+ "memory.current", &usage_in_bytes);
+ if (ret == 0)
+ *kb = (unsigned long) usage_in_bytes >> 10;
+ return ret;
+}
+
+
virCgroupBackend virCgroupV2Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V2,
@@ -1163,6 +1177,7 @@ virCgroupBackend virCgroupV2Backend = {
.setMemory = virCgroupV2SetMemory,
.getMemoryStat = virCgroupV2GetMemoryStat,
+ .getMemoryUsage = virCgroupV2GetMemoryUsage,
};
--
2.17.1