On Tue, Sep 18, 2018 at 5:46 PM, Pavel Hrdina <phrdina(a)redhat.com> wrote:
---
src/util/vircgroup.c | 7 ++-----
src/util/vircgroupbackend.h | 11 +++++++++++
src/util/vircgroupv1.c | 22 ++++++++++++++++++++++
3 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index bdbed65be2..598147acf7 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -2267,8 +2267,7 @@ virCgroupSetCpuCfsQuota(virCgroupPtr group, long
long cfs_quota)
int
virCgroupGetCpuacctPercpuUsage(virCgroupPtr group, char **usage)
{
- return virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPUACCT,
- "cpuacct.usage_percpu", usage);
+ VIR_CGROUP_BACKEND_CALL(group, getCpuacctPercpuUsage, -1, usage);
}
@@ -2591,9 +2590,7 @@ virCgroupGetCpuCfsQuota(virCgroupPtr group, long
long *cfs_quota)
int
virCgroupGetCpuacctUsage(virCgroupPtr group, unsigned long long *usage)
{
- return virCgroupGetValueU64(group,
- VIR_CGROUP_CONTROLLER_CPUACCT,
- "cpuacct.usage", usage);
+ VIR_CGROUP_BACKEND_CALL(group, getCpuacctUsage, -1, usage);
}
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 049f9040bd..380ab9850d 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -295,6 +295,14 @@ typedef int
typedef bool
(*virCgroupSupportsCpuBWCB)(virCgroupPtr cgroup);
+typedef int
+(*virCgroupGetCpuacctUsageCB)(virCgroupPtr group,
+ unsigned long long *usage);
+
+typedef int
+(*virCgroupGetCpuacctPercpuUsageCB)(virCgroupPtr group,
+ char **usage);
+
struct _virCgroupBackend {
virCgroupBackendType type;
@@ -357,6 +365,9 @@ struct _virCgroupBackend {
virCgroupSetCpuCfsQuotaCB setCpuCfsQuota;
virCgroupGetCpuCfsQuotaCB getCpuCfsQuota;
virCgroupSupportsCpuBWCB supportsCpuBW;
+
+ virCgroupGetCpuacctUsageCB getCpuacctUsage;
+ virCgroupGetCpuacctPercpuUsageCB getCpuacctPercpuUsage;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 88912778b5..a827917db1 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -1858,6 +1858,25 @@ virCgroupV1SupportsCpuBW(virCgroupPtr cgroup)
}
+static int
+virCgroupV1GetCpuacctUsage(virCgroupPtr group,
+ unsigned long long *usage)
+{
+ return virCgroupGetValueU64(group,
+ VIR_CGROUP_CONTROLLER_CPUACCT,
+ "cpuacct.usage", usage);
+}
+
+
+static int
+virCgroupV1GetCpuacctPercpuUsage(virCgroupPtr group,
+ char **usage)
+{
+ return virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPUACCT,
+ "cpuacct.usage_percpu", usage);
+}
+
+
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
@@ -1918,6 +1937,9 @@ virCgroupBackend virCgroupV1Backend = {
.setCpuCfsQuota = virCgroupV1SetCpuCfsQuota,
.getCpuCfsQuota = virCgroupV1GetCpuCfsQuota,
.supportsCpuBW = virCgroupV1SupportsCpuBW,
+
+ .getCpuacctUsage = virCgroupV1GetCpuacctUsage,
+ .getCpuacctPercpuUsage = virCgroupV1GetCpuacctPercpuUsage,
};
--
2.17.1
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list