diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 44e88c46f2..fce4b82874 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -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 diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h index f7c230db76..d3d5e7c222 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -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; diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index ea206d8b37..2707e7d1fb 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -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, };