mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
vircgroup: extract virCgroupV1SupportsCpuBW
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
5436fd75d8
commit
d182fac0bb
@ -2681,18 +2681,7 @@ int virCgroupSetOwner(virCgroupPtr cgroup,
|
||||
bool
|
||||
virCgroupSupportsCpuBW(virCgroupPtr cgroup)
|
||||
{
|
||||
VIR_AUTOFREE(char *) path = NULL;
|
||||
|
||||
if (!cgroup)
|
||||
return false;
|
||||
|
||||
if (virCgroupPathOfController(cgroup, VIR_CGROUP_CONTROLLER_CPU,
|
||||
"cpu.cfs_period_us", &path) < 0) {
|
||||
virResetLastError();
|
||||
return false;
|
||||
}
|
||||
|
||||
return virFileExists(path);
|
||||
VIR_CGROUP_BACKEND_CALL(cgroup, supportsCpuBW, false);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -300,6 +300,9 @@ typedef int
|
||||
(*virCgroupGetCpuCfsQuotaCB)(virCgroupPtr group,
|
||||
long long *cfs_quota);
|
||||
|
||||
typedef bool
|
||||
(*virCgroupSupportsCpuBWCB)(virCgroupPtr cgroup);
|
||||
|
||||
struct _virCgroupBackend {
|
||||
virCgroupBackendType type;
|
||||
|
||||
@ -361,6 +364,7 @@ struct _virCgroupBackend {
|
||||
virCgroupGetCpuCfsPeriodCB getCpuCfsPeriod;
|
||||
virCgroupSetCpuCfsQuotaCB setCpuCfsQuota;
|
||||
virCgroupGetCpuCfsQuotaCB getCpuCfsQuota;
|
||||
virCgroupSupportsCpuBWCB supportsCpuBW;
|
||||
};
|
||||
typedef struct _virCgroupBackend virCgroupBackend;
|
||||
typedef virCgroupBackend *virCgroupBackendPtr;
|
||||
|
@ -1845,6 +1845,24 @@ virCgroupV1GetCpuCfsQuota(virCgroupPtr group,
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
virCgroupV1SupportsCpuBW(virCgroupPtr cgroup)
|
||||
{
|
||||
VIR_AUTOFREE(char *) path = NULL;
|
||||
|
||||
if (!cgroup)
|
||||
return false;
|
||||
|
||||
if (virCgroupV1PathOfController(cgroup, VIR_CGROUP_CONTROLLER_CPU,
|
||||
"cpu.cfs_period_us", &path) < 0) {
|
||||
virResetLastError();
|
||||
return false;
|
||||
}
|
||||
|
||||
return virFileExists(path);
|
||||
}
|
||||
|
||||
|
||||
virCgroupBackend virCgroupV1Backend = {
|
||||
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
||||
|
||||
@ -1904,6 +1922,7 @@ virCgroupBackend virCgroupV1Backend = {
|
||||
.getCpuCfsPeriod = virCgroupV1GetCpuCfsPeriod,
|
||||
.setCpuCfsQuota = virCgroupV1SetCpuCfsQuota,
|
||||
.getCpuCfsQuota = virCgroupV1GetCpuCfsQuota,
|
||||
.supportsCpuBW = virCgroupV1SupportsCpuBW,
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user