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:
Pavel Hrdina 2018-08-17 16:23:14 +02:00
parent 5436fd75d8
commit d182fac0bb
3 changed files with 24 additions and 12 deletions

View File

@ -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

View File

@ -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;

View File

@ -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,
};