On 10/02/2018 10:44 AM, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/vircgroupv2.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index ae352f0212..3d1d68ded5 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1292,6 +1292,21 @@ virCgroupV2GetMemSwapHardLimit(virCgroupPtr group,
}
+static int
+virCgroupV2GetMemSwapUsage(virCgroupPtr group,
+ unsigned long long *kb)
+{
+ long long unsigned int usage_in_bytes;
Looks like a copy & paste & paste & paste & paste ... error :-)
+ int ret;
+ ret = virCgroupGetValueU64(group,
+ VIR_CGROUP_CONTROLLER_MEMORY,
+ "memory.swap.current", &usage_in_bytes);
+ if (ret == 0)
+ *kb = (unsigned long) usage_in_bytes >> 10;
+ return ret;
+}
+
+
virCgroupBackend virCgroupV2Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V2,
@@ -1338,6 +1353,7 @@ virCgroupBackend virCgroupV2Backend = {
.getMemorySoftLimit = virCgroupV2GetMemorySoftLimit,
.setMemSwapHardLimit = virCgroupV2SetMemSwapHardLimit,
.getMemSwapHardLimit = virCgroupV2GetMemSwapHardLimit,
+ .getMemSwapUsage = virCgroupV2GetMemSwapUsage,
};
ACK
Michal