提交 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)
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);
}
......@@ -2585,9 +2584,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);
}
......
......@@ -303,6 +303,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;
......@@ -365,6 +373,9 @@ struct _virCgroupBackend {
virCgroupSetCpuCfsQuotaCB setCpuCfsQuota;
virCgroupGetCpuCfsQuotaCB getCpuCfsQuota;
virCgroupSupportsCpuBWCB supportsCpuBW;
virCgroupGetCpuacctUsageCB getCpuacctUsage;
virCgroupGetCpuacctPercpuUsageCB getCpuacctPercpuUsage;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
......
......@@ -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 = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
......@@ -1923,6 +1942,9 @@ virCgroupBackend virCgroupV1Backend = {
.setCpuCfsQuota = virCgroupV1SetCpuCfsQuota,
.getCpuCfsQuota = virCgroupV1GetCpuCfsQuota,
.supportsCpuBW = virCgroupV1SupportsCpuBW,
.getCpuacctUsage = virCgroupV1GetCpuacctUsage,
.getCpuacctPercpuUsage = virCgroupV1GetCpuacctPercpuUsage,
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册