mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
vircgroup: extract virCgroupV1GetCpuacct*Usage
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
d182fac0bb
commit
8370466323
@ -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,
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user