|
Pablo Greco |
40546a |
From 1d91616a1f70531a38695b1634e5538e1699b648 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <1d91616a1f70531a38695b1634e5538e1699b648@dist-git>
|
|
Pablo Greco |
40546a |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Mon, 1 Jul 2019 17:07:00 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] vircgroup: extract virCgroupV1GetCpuacct*Usage
|
|
Pablo Greco |
40546a |
MIME-Version: 1.0
|
|
Pablo Greco |
40546a |
Content-Type: text/plain; charset=UTF-8
|
|
Pablo Greco |
40546a |
Content-Transfer-Encoding: 8bit
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
(cherry picked from commit 83704663234b894251eb197638e81b652674103e)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Message-Id: <fa6bba63dd9a7d3ad733b3107a613033e6fa6cd2.1561993100.git.phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
---
|
|
Pablo Greco |
40546a |
src/util/vircgroup.c | 7 ++-----
|
|
Pablo Greco |
40546a |
src/util/vircgroupbackend.h | 11 +++++++++++
|
|
Pablo Greco |
40546a |
src/util/vircgroupv1.c | 22 ++++++++++++++++++++++
|
|
Pablo Greco |
40546a |
3 files changed, 35 insertions(+), 5 deletions(-)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
index fa9fa52019..4f791204d3 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
@@ -2265,8 +2265,7 @@ virCgroupSetCpuCfsQuota(virCgroupPtr group, long long cfs_quota)
|
|
Pablo Greco |
40546a |
int
|
|
Pablo Greco |
40546a |
virCgroupGetCpuacctPercpuUsage(virCgroupPtr group, char **usage)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- return virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPUACCT,
|
|
Pablo Greco |
40546a |
- "cpuacct.usage_percpu", usage);
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_BACKEND_CALL(group, getCpuacctPercpuUsage, -1, usage);
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -2589,9 +2588,7 @@ virCgroupGetCpuCfsQuota(virCgroupPtr group, long long *cfs_quota)
|
|
Pablo Greco |
40546a |
int
|
|
Pablo Greco |
40546a |
virCgroupGetCpuacctUsage(virCgroupPtr group, unsigned long long *usage)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- return virCgroupGetValueU64(group,
|
|
Pablo Greco |
40546a |
- VIR_CGROUP_CONTROLLER_CPUACCT,
|
|
Pablo Greco |
40546a |
- "cpuacct.usage", usage);
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_BACKEND_CALL(group, getCpuacctUsage, -1, usage);
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
index d3d5e7c222..39a75a69f4 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
@@ -303,6 +303,14 @@ typedef int
|
|
Pablo Greco |
40546a |
typedef bool
|
|
Pablo Greco |
40546a |
(*virCgroupSupportsCpuBWCB)(virCgroupPtr cgroup);
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+typedef int
|
|
Pablo Greco |
40546a |
+(*virCgroupGetCpuacctUsageCB)(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ unsigned long long *usage);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+typedef int
|
|
Pablo Greco |
40546a |
+(*virCgroupGetCpuacctPercpuUsageCB)(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ char **usage);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
struct _virCgroupBackend {
|
|
Pablo Greco |
40546a |
virCgroupBackendType type;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -365,6 +373,9 @@ struct _virCgroupBackend {
|
|
Pablo Greco |
40546a |
virCgroupSetCpuCfsQuotaCB setCpuCfsQuota;
|
|
Pablo Greco |
40546a |
virCgroupGetCpuCfsQuotaCB getCpuCfsQuota;
|
|
Pablo Greco |
40546a |
virCgroupSupportsCpuBWCB supportsCpuBW;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ virCgroupGetCpuacctUsageCB getCpuacctUsage;
|
|
Pablo Greco |
40546a |
+ virCgroupGetCpuacctPercpuUsageCB getCpuacctPercpuUsage;
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
typedef struct _virCgroupBackend virCgroupBackend;
|
|
Pablo Greco |
40546a |
typedef virCgroupBackend *virCgroupBackendPtr;
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
index f2a8839f6e..9fb0c5cb96 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
@@ -1864,6 +1864,25 @@ virCgroupV1SupportsCpuBW(virCgroupPtr cgroup)
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV1GetCpuacctUsage(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ unsigned long long *usage)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ return virCgroupGetValueU64(group,
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_CONTROLLER_CPUACCT,
|
|
Pablo Greco |
40546a |
+ "cpuacct.usage", usage);
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV1GetCpuacctPercpuUsage(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ char **usage)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ return virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPUACCT,
|
|
Pablo Greco |
40546a |
+ "cpuacct.usage_percpu", usage);
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
virCgroupBackend virCgroupV1Backend = {
|
|
Pablo Greco |
40546a |
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -1924,6 +1943,9 @@ virCgroupBackend virCgroupV1Backend = {
|
|
Pablo Greco |
40546a |
.setCpuCfsQuota = virCgroupV1SetCpuCfsQuota,
|
|
Pablo Greco |
40546a |
.getCpuCfsQuota = virCgroupV1GetCpuCfsQuota,
|
|
Pablo Greco |
40546a |
.supportsCpuBW = virCgroupV1SupportsCpuBW,
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ .getCpuacctUsage = virCgroupV1GetCpuacctUsage,
|
|
Pablo Greco |
40546a |
+ .getCpuacctPercpuUsage = virCgroupV1GetCpuacctPercpuUsage,
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|