forked from rpms/libvirt
112 lines
3.4 KiB
Diff
112 lines
3.4 KiB
Diff
From 36f035a5d6620f5f39f4aec45d4ec1ec0fa7ccbc Mon Sep 17 00:00:00 2001
|
|
Message-Id: <36f035a5d6620f5f39f4aec45d4ec1ec0fa7ccbc@dist-git>
|
|
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Date: Mon, 1 Jul 2019 17:06:59 +0200
|
|
Subject: [PATCH] vircgroup: extract virCgroupV1SupportsCpuBW
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
(cherry picked from commit d182fac0bb07ff06ca938b40030849f86dfa24f1)
|
|
|
|
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Message-Id: <679862bf39de7fbd81ab5b1e65c61cf578abb944.1561993100.git.phrdina@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@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 a3e7954d03..fa9fa52019 100644
|
|
--- a/src/util/vircgroup.c
|
|
+++ b/src/util/vircgroup.c
|
|
@@ -2685,18 +2685,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 25f7376026..f2a8839f6e 100644
|
|
--- a/src/util/vircgroupv1.c
|
|
+++ b/src/util/vircgroupv1.c
|
|
@@ -1846,6 +1846,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,
|
|
|
|
@@ -1905,6 +1923,7 @@ virCgroupBackend virCgroupV1Backend = {
|
|
.getCpuCfsPeriod = virCgroupV1GetCpuCfsPeriod,
|
|
.setCpuCfsQuota = virCgroupV1SetCpuCfsQuota,
|
|
.getCpuCfsQuota = virCgroupV1GetCpuCfsQuota,
|
|
+ .supportsCpuBW = virCgroupV1SupportsCpuBW,
|
|
};
|
|
|
|
|
|
--
|
|
2.22.0
|
|
|