[PATCH v2 34/53] [ACKED] vircgroup: introduce virCgroupV2GetMemSwapUsage

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

 



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

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index fcadf9381d..991d32f4b7 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1298,6 +1298,21 @@ virCgroupV2GetMemSwapHardLimit(virCgroupPtr group,
 }
 
 
+static int
+virCgroupV2GetMemSwapUsage(virCgroupPtr group,
+                           unsigned long long *kb)
+{
+    unsigned long long usage_in_bytes;
+    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,
 
@@ -1344,6 +1359,7 @@ virCgroupBackend virCgroupV2Backend = {
     .getMemorySoftLimit = virCgroupV2GetMemorySoftLimit,
     .setMemSwapHardLimit = virCgroupV2SetMemSwapHardLimit,
     .getMemSwapHardLimit = virCgroupV2GetMemSwapHardLimit,
+    .getMemSwapUsage = virCgroupV2GetMemSwapUsage,
 };
 
 
-- 
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