|
|
c480ed |
From 36f035a5d6620f5f39f4aec45d4ec1ec0fa7ccbc Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <36f035a5d6620f5f39f4aec45d4ec1ec0fa7ccbc@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:06:59 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: extract virCgroupV1SupportsCpuBW
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
(cherry picked from commit d182fac0bb07ff06ca938b40030849f86dfa24f1)
|
|
|
c480ed |
|
|
|
c480ed |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Message-Id: <679862bf39de7fbd81ab5b1e65c61cf578abb944.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroup.c | 13 +------------
|
|
|
c480ed |
src/util/vircgroupbackend.h | 4 ++++
|
|
|
c480ed |
src/util/vircgroupv1.c | 19 +++++++++++++++++++
|
|
|
c480ed |
3 files changed, 24 insertions(+), 12 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c480ed |
index a3e7954d03..fa9fa52019 100644
|
|
|
c480ed |
--- a/src/util/vircgroup.c
|
|
|
c480ed |
+++ b/src/util/vircgroup.c
|
|
|
c480ed |
@@ -2685,18 +2685,7 @@ int virCgroupSetOwner(virCgroupPtr cgroup,
|
|
|
c480ed |
bool
|
|
|
c480ed |
virCgroupSupportsCpuBW(virCgroupPtr cgroup)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_AUTOFREE(char *) path = NULL;
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (!cgroup)
|
|
|
c480ed |
- return false;
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (virCgroupPathOfController(cgroup, VIR_CGROUP_CONTROLLER_CPU,
|
|
|
c480ed |
- "cpu.cfs_period_us", &path) < 0) {
|
|
|
c480ed |
- virResetLastError();
|
|
|
c480ed |
- return false;
|
|
|
c480ed |
- }
|
|
|
c480ed |
-
|
|
|
c480ed |
- return virFileExists(path);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(cgroup, supportsCpuBW, false);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
int
|
|
|
c480ed |
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
|
c480ed |
index f7c230db76..d3d5e7c222 100644
|
|
|
c480ed |
--- a/src/util/vircgroupbackend.h
|
|
|
c480ed |
+++ b/src/util/vircgroupbackend.h
|
|
|
c480ed |
@@ -300,6 +300,9 @@ typedef int
|
|
|
c480ed |
(*virCgroupGetCpuCfsQuotaCB)(virCgroupPtr group,
|
|
|
c480ed |
long long *cfs_quota);
|
|
|
c480ed |
|
|
|
c480ed |
+typedef bool
|
|
|
c480ed |
+(*virCgroupSupportsCpuBWCB)(virCgroupPtr cgroup);
|
|
|
c480ed |
+
|
|
|
c480ed |
struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupBackendType type;
|
|
|
c480ed |
|
|
|
c480ed |
@@ -361,6 +364,7 @@ struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupGetCpuCfsPeriodCB getCpuCfsPeriod;
|
|
|
c480ed |
virCgroupSetCpuCfsQuotaCB setCpuCfsQuota;
|
|
|
c480ed |
virCgroupGetCpuCfsQuotaCB getCpuCfsQuota;
|
|
|
c480ed |
+ virCgroupSupportsCpuBWCB supportsCpuBW;
|
|
|
c480ed |
};
|
|
|
c480ed |
typedef struct _virCgroupBackend virCgroupBackend;
|
|
|
c480ed |
typedef virCgroupBackend *virCgroupBackendPtr;
|
|
|
c480ed |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
|
c480ed |
index 25f7376026..f2a8839f6e 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv1.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv1.c
|
|
|
c480ed |
@@ -1846,6 +1846,24 @@ virCgroupV1GetCpuCfsQuota(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static bool
|
|
|
c480ed |
+virCgroupV1SupportsCpuBW(virCgroupPtr cgroup)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) path = NULL;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!cgroup)
|
|
|
c480ed |
+ return false;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virCgroupV1PathOfController(cgroup, VIR_CGROUP_CONTROLLER_CPU,
|
|
|
c480ed |
+ "cpu.cfs_period_us", &path) < 0) {
|
|
|
c480ed |
+ virResetLastError();
|
|
|
c480ed |
+ return false;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return virFileExists(path);
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV1Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1905,6 +1923,7 @@ virCgroupBackend virCgroupV1Backend = {
|
|
|
c480ed |
.getCpuCfsPeriod = virCgroupV1GetCpuCfsPeriod,
|
|
|
c480ed |
.setCpuCfsQuota = virCgroupV1SetCpuCfsQuota,
|
|
|
c480ed |
.getCpuCfsQuota = virCgroupV1GetCpuCfsQuota,
|
|
|
c480ed |
+ .supportsCpuBW = virCgroupV1SupportsCpuBW,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|