|
|
c480ed |
From 3e61b08bd5d925b262e3ca84d234670917604fda Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <3e61b08bd5d925b262e3ca84d234670917604fda@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:06:53 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: extract virCgroupV1GetMemSwapUsage
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 87d9fc5b3bfbe217af1a5316af4392540f676657)
|
|
|
c480ed |
|
|
|
c480ed |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Message-Id: <c660f81cdf6e8771917e54c44d362ebb4d2fbdb4.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroup.c | 9 +--------
|
|
|
c480ed |
src/util/vircgroupbackend.h | 5 +++++
|
|
|
c480ed |
src/util/vircgroupv1.c | 16 ++++++++++++++++
|
|
|
c480ed |
3 files changed, 22 insertions(+), 8 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c480ed |
index 6708eef0da..088e97cb3f 100644
|
|
|
c480ed |
--- a/src/util/vircgroup.c
|
|
|
c480ed |
+++ b/src/util/vircgroup.c
|
|
|
c480ed |
@@ -1697,14 +1697,7 @@ virCgroupGetMemSwapHardLimit(virCgroupPtr group, unsigned long long *kb)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetMemSwapUsage(virCgroupPtr group, unsigned long long *kb)
|
|
|
c480ed |
{
|
|
|
c480ed |
- long long unsigned int usage_in_bytes;
|
|
|
c480ed |
- int ret;
|
|
|
c480ed |
- ret = virCgroupGetValueU64(group,
|
|
|
c480ed |
- VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
- "memory.memsw.usage_in_bytes", &usage_in_bytes);
|
|
|
c480ed |
- if (ret == 0)
|
|
|
c480ed |
- *kb = usage_in_bytes >> 10;
|
|
|
c480ed |
- return ret;
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, getMemSwapUsage, -1, kb);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
|
c480ed |
index cdbca4b907..27e6b18ea2 100644
|
|
|
c480ed |
--- a/src/util/vircgroupbackend.h
|
|
|
c480ed |
+++ b/src/util/vircgroupbackend.h
|
|
|
c480ed |
@@ -251,6 +251,10 @@ typedef int
|
|
|
c480ed |
(*virCgroupGetMemSwapHardLimitCB)(virCgroupPtr group,
|
|
|
c480ed |
unsigned long long *kb);
|
|
|
c480ed |
|
|
|
c480ed |
+typedef int
|
|
|
c480ed |
+(*virCgroupGetMemSwapUsageCB)(virCgroupPtr group,
|
|
|
c480ed |
+ unsigned long long *kb);
|
|
|
c480ed |
+
|
|
|
c480ed |
struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupBackendType type;
|
|
|
c480ed |
|
|
|
c480ed |
@@ -299,6 +303,7 @@ struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupGetMemorySoftLimitCB getMemorySoftLimit;
|
|
|
c480ed |
virCgroupSetMemSwapHardLimitCB setMemSwapHardLimit;
|
|
|
c480ed |
virCgroupGetMemSwapHardLimitCB getMemSwapHardLimit;
|
|
|
c480ed |
+ virCgroupGetMemSwapUsageCB getMemSwapUsage;
|
|
|
c480ed |
};
|
|
|
c480ed |
typedef struct _virCgroupBackend virCgroupBackend;
|
|
|
c480ed |
typedef virCgroupBackend *virCgroupBackendPtr;
|
|
|
c480ed |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
|
c480ed |
index 779288fb97..55b1d3ebd0 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv1.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv1.c
|
|
|
c480ed |
@@ -1656,6 +1656,21 @@ virCgroupV1GetMemSwapHardLimit(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV1GetMemSwapUsage(virCgroupPtr group,
|
|
|
c480ed |
+ unsigned long long *kb)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ long long unsigned int usage_in_bytes;
|
|
|
c480ed |
+ int ret;
|
|
|
c480ed |
+ ret = virCgroupGetValueU64(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ "memory.memsw.usage_in_bytes", &usage_in_bytes);
|
|
|
c480ed |
+ if (ret == 0)
|
|
|
c480ed |
+ *kb = usage_in_bytes >> 10;
|
|
|
c480ed |
+ return ret;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV1Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1702,6 +1717,7 @@ virCgroupBackend virCgroupV1Backend = {
|
|
|
c480ed |
.getMemorySoftLimit = virCgroupV1GetMemorySoftLimit,
|
|
|
c480ed |
.setMemSwapHardLimit = virCgroupV1SetMemSwapHardLimit,
|
|
|
c480ed |
.getMemSwapHardLimit = virCgroupV1GetMemSwapHardLimit,
|
|
|
c480ed |
+ .getMemSwapUsage = virCgroupV1GetMemSwapUsage,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|