提交 83704663 编写于 作者: P Pavel Hrdina

vircgroup: extract virCgroupV1GetCpuacct*Usage

Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 d182fac0
...@@ -2261,8 +2261,7 @@ virCgroupSetCpuCfsQuota(virCgroupPtr group, long long cfs_quota) ...@@ -2261,8 +2261,7 @@ virCgroupSetCpuCfsQuota(virCgroupPtr group, long long cfs_quota)
int int
virCgroupGetCpuacctPercpuUsage(virCgroupPtr group, char **usage) virCgroupGetCpuacctPercpuUsage(virCgroupPtr group, char **usage)
{ {
return virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPUACCT, VIR_CGROUP_BACKEND_CALL(group, getCpuacctPercpuUsage, -1, usage);
"cpuacct.usage_percpu", usage);
} }
...@@ -2585,9 +2584,7 @@ virCgroupGetCpuCfsQuota(virCgroupPtr group, long long *cfs_quota) ...@@ -2585,9 +2584,7 @@ virCgroupGetCpuCfsQuota(virCgroupPtr group, long long *cfs_quota)
int int
virCgroupGetCpuacctUsage(virCgroupPtr group, unsigned long long *usage) virCgroupGetCpuacctUsage(virCgroupPtr group, unsigned long long *usage)
{ {
return virCgroupGetValueU64(group, VIR_CGROUP_BACKEND_CALL(group, getCpuacctUsage, -1, usage);
VIR_CGROUP_CONTROLLER_CPUACCT,
"cpuacct.usage", usage);
} }
......
...@@ -303,6 +303,14 @@ typedef int ...@@ -303,6 +303,14 @@ typedef int
typedef bool typedef bool
(*virCgroupSupportsCpuBWCB)(virCgroupPtr cgroup); (*virCgroupSupportsCpuBWCB)(virCgroupPtr cgroup);
typedef int
(*virCgroupGetCpuacctUsageCB)(virCgroupPtr group,
unsigned long long *usage);
typedef int
(*virCgroupGetCpuacctPercpuUsageCB)(virCgroupPtr group,
char **usage);
struct _virCgroupBackend { struct _virCgroupBackend {
virCgroupBackendType type; virCgroupBackendType type;
...@@ -365,6 +373,9 @@ struct _virCgroupBackend { ...@@ -365,6 +373,9 @@ struct _virCgroupBackend {
virCgroupSetCpuCfsQuotaCB setCpuCfsQuota; virCgroupSetCpuCfsQuotaCB setCpuCfsQuota;
virCgroupGetCpuCfsQuotaCB getCpuCfsQuota; virCgroupGetCpuCfsQuotaCB getCpuCfsQuota;
virCgroupSupportsCpuBWCB supportsCpuBW; virCgroupSupportsCpuBWCB supportsCpuBW;
virCgroupGetCpuacctUsageCB getCpuacctUsage;
virCgroupGetCpuacctPercpuUsageCB getCpuacctPercpuUsage;
}; };
typedef struct _virCgroupBackend virCgroupBackend; typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr; typedef virCgroupBackend *virCgroupBackendPtr;
......
...@@ -1863,6 +1863,25 @@ virCgroupV1SupportsCpuBW(virCgroupPtr cgroup) ...@@ -1863,6 +1863,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 = { virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1, .type = VIR_CGROUP_BACKEND_TYPE_V1,
...@@ -1923,6 +1942,9 @@ virCgroupBackend virCgroupV1Backend = { ...@@ -1923,6 +1942,9 @@ virCgroupBackend virCgroupV1Backend = {
.setCpuCfsQuota = virCgroupV1SetCpuCfsQuota, .setCpuCfsQuota = virCgroupV1SetCpuCfsQuota,
.getCpuCfsQuota = virCgroupV1GetCpuCfsQuota, .getCpuCfsQuota = virCgroupV1GetCpuCfsQuota,
.supportsCpuBW = virCgroupV1SupportsCpuBW, .supportsCpuBW = virCgroupV1SupportsCpuBW,
.getCpuacctUsage = virCgroupV1GetCpuacctUsage,
.getCpuacctPercpuUsage = virCgroupV1GetCpuacctPercpuUsage,
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册