Re: [PATCH 33/47] vircgroup: extract virCgroupV1GetMemSwapUsage

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

 





On Tue, Sep 18, 2018 at 5:45 PM, Pavel Hrdina <phrdina@xxxxxxxxxx> wrote:
Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>

Reviewed-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
 
---
 src/util/vircgroup.c        |  9 +--------
 src/util/vircgroupbackend.h |  5 +++++
 src/util/vircgroupv1.c      | 16 ++++++++++++++++
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index cd6b087a69..38a30b759f 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1699,14 +1699,7 @@ virCgroupGetMemSwapHardLimit(virCgroupPtr group, unsigned long long *kb)
 int
 virCgroupGetMemSwapUsage(virCgroupPtr group, unsigned long long *kb)
 {
-    long long unsigned int usage_in_bytes;
-    int ret;
-    ret = virCgroupGetValueU64(group,
-                               VIR_CGROUP_CONTROLLER_MEMORY,
-                               "memory.memsw.usage_in_bytes", &usage_in_bytes);
-    if (ret == 0)
-        *kb = usage_in_bytes >> 10;
-    return ret;
+    VIR_CGROUP_BACKEND_CALL(group, getMemSwapUsage, -1, kb);
 }


diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 5e75e495c3..f5454e41f7 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -243,6 +243,10 @@ typedef int
 (*virCgroupGetMemSwapHardLimitCB)(virCgroupPtr group,
                                   unsigned long long *kb);

+typedef int
+(*virCgroupGetMemSwapUsageCB)(virCgroupPtr group,
+                              unsigned long long *kb);
+
 struct _virCgroupBackend {
     virCgroupBackendType type;

@@ -291,6 +295,7 @@ struct _virCgroupBackend {
     virCgroupGetMemorySoftLimitCB getMemorySoftLimit;
     virCgroupSetMemSwapHardLimitCB setMemSwapHardLimit;
     virCgroupGetMemSwapHardLimitCB getMemSwapHardLimit;
+    virCgroupGetMemSwapUsageCB getMemSwapUsage;
 };
 typedef struct _virCgroupBackend virCgroupBackend;
 typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 5fc046afad..936cf1b1f5 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -1650,6 +1650,21 @@ virCgroupV1GetMemSwapHardLimit(virCgroupPtr group,
 }


+static int
+virCgroupV1GetMemSwapUsage(virCgroupPtr group,
+                           unsigned long long *kb)
+{
+    long long unsigned int usage_in_bytes;
+    int ret;
+    ret = virCgroupGetValueU64(group,
+                               VIR_CGROUP_CONTROLLER_MEMORY,
+                               "memory.memsw.usage_in_bytes", &usage_in_bytes);
+    if (ret == 0)
+        *kb = usage_in_bytes >> 10;
+    return ret;
+}
+
+
 virCgroupBackend virCgroupV1Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V1,

@@ -1696,6 +1711,7 @@ virCgroupBackend virCgroupV1Backend = {
     .getMemorySoftLimit = virCgroupV1GetMemorySoftLimit,
     .setMemSwapHardLimit = virCgroupV1SetMemSwapHardLimit,
     .getMemSwapHardLimit = virCgroupV1GetMemSwapHardLimit,
+    .getMemSwapUsage = virCgroupV1GetMemSwapUsage,
 };
 

--
2.17.1

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

--
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