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