On Tue, Sep 18, 2018 at 5:46 PM, Pavel Hrdina <phrdina(a)redhat.com> wrote:
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
Reviewed-by: Fabiano Fidêncio <fidencio(a)redhat.com>
---
src/util/vircgroup.c | 13 +------------
src/util/vircgroupbackend.h | 4 ++++
src/util/vircgroupv1.c | 19 +++++++++++++++++++
3 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 17b8c13cf9..bdbed65be2 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -2687,18 +2687,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 b94a89069a..049f9040bd 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -292,6 +292,9 @@ typedef int
(*virCgroupGetCpuCfsQuotaCB)(virCgroupPtr group,
long long *cfs_quota);
+typedef bool
+(*virCgroupSupportsCpuBWCB)(virCgroupPtr cgroup);
+
struct _virCgroupBackend {
virCgroupBackendType type;
@@ -353,6 +356,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 5de6d27f48..88912778b5 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -1840,6 +1840,24 @@ virCgroupV1GetCpuCfsQuota(virCgroupPtr group,
}
+static bool
+virCgroupV1SupportsCpuBW(virCgroupPtr cgroup)
+{
+ VIR_AUTOFREE(char *) path = NULL;
+
+ if (!cgroup)
+ return false;
Not related to this patch, but this check should be removed as cgroup is
never NULL here.
+
+ 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,
@@ -1899,6 +1917,7 @@ virCgroupBackend virCgroupV1Backend = {
.getCpuCfsPeriod = virCgroupV1GetCpuCfsPeriod,
.setCpuCfsQuota = virCgroupV1SetCpuCfsQuota,
.getCpuCfsQuota = virCgroupV1GetCpuCfsQuota,
+ .supportsCpuBW = virCgroupV1SupportsCpuBW,
};
--
2.17.1
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list