|
|
c480ed |
From 98be75680dd7026b7156b3f9a0bd220f00714387 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <98be75680dd7026b7156b3f9a0bd220f00714387@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:06:33 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: extract virCgroupV1GetAnyController
|
|
|
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 d6564037e8161bbdd270a822f5a2aafd90c7df10)
|
|
|
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: <fc1d1ba80e734d7cdbdf6300e0199b48ede77bd1.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroup.c | 16 ++++------------
|
|
|
c480ed |
src/util/vircgroupbackend.h | 4 ++++
|
|
|
c480ed |
src/util/vircgroupv1.c | 22 ++++++++++++++++++++++
|
|
|
c480ed |
3 files changed, 30 insertions(+), 12 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c480ed |
index 5bbe42b699..a6f529accd 100644
|
|
|
c480ed |
--- a/src/util/vircgroup.c
|
|
|
c480ed |
+++ b/src/util/vircgroup.c
|
|
|
c480ed |
@@ -3173,19 +3173,11 @@ virCgroupPathOfAnyController(virCgroupPtr group,
|
|
|
c480ed |
const char *name,
|
|
|
c480ed |
char **keypath)
|
|
|
c480ed |
{
|
|
|
c480ed |
- size_t i;
|
|
|
c480ed |
+ int controller;
|
|
|
c480ed |
|
|
|
c480ed |
- for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c480ed |
- /* Reject any controller with a placement
|
|
|
c480ed |
- * of '/' to avoid doing bad stuff to the root
|
|
|
c480ed |
- * cgroup
|
|
|
c480ed |
- */
|
|
|
c480ed |
- if (group->controllers[i].mountPoint &&
|
|
|
c480ed |
- group->controllers[i].placement &&
|
|
|
c480ed |
- STRNEQ(group->controllers[i].placement, "/")) {
|
|
|
c480ed |
- return virCgroupPathOfController(group, i, name, keypath);
|
|
|
c480ed |
- }
|
|
|
c480ed |
- }
|
|
|
c480ed |
+ controller = group->backend->getAnyController(group);
|
|
|
c480ed |
+ if (controller >= 0)
|
|
|
c480ed |
+ return virCgroupPathOfController(group, controller, name, keypath);
|
|
|
c480ed |
|
|
|
c480ed |
virReportSystemError(ENOSYS, "%s",
|
|
|
c480ed |
_("No controllers are mounted"));
|
|
|
c480ed |
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
|
c480ed |
index 29b2fd119f..b4eaa89021 100644
|
|
|
c480ed |
--- a/src/util/vircgroupbackend.h
|
|
|
c480ed |
+++ b/src/util/vircgroupbackend.h
|
|
|
c480ed |
@@ -77,6 +77,9 @@ typedef bool
|
|
|
c480ed |
(*virCgroupHasControllerCB)(virCgroupPtr cgroup,
|
|
|
c480ed |
int controller);
|
|
|
c480ed |
|
|
|
c480ed |
+typedef int
|
|
|
c480ed |
+(*virCgroupGetAnyControllerCB)(virCgroupPtr group);
|
|
|
c480ed |
+
|
|
|
c480ed |
struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupBackendType type;
|
|
|
c480ed |
|
|
|
c480ed |
@@ -91,6 +94,7 @@ struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupStealPlacementCB stealPlacement;
|
|
|
c480ed |
virCgroupDetectControllersCB detectControllers;
|
|
|
c480ed |
virCgroupHasControllerCB hasController;
|
|
|
c480ed |
+ virCgroupGetAnyControllerCB getAnyController;
|
|
|
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 0638f48d50..bae16b8294 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv1.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv1.c
|
|
|
c480ed |
@@ -486,6 +486,27 @@ virCgroupV1HasController(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV1GetAnyController(virCgroupPtr group)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c480ed |
+ /* Reject any controller with a placement
|
|
|
c480ed |
+ * of '/' to avoid doing bad stuff to the root
|
|
|
c480ed |
+ * cgroup
|
|
|
c480ed |
+ */
|
|
|
c480ed |
+ if (group->controllers[i].mountPoint &&
|
|
|
c480ed |
+ group->controllers[i].placement &&
|
|
|
c480ed |
+ STRNEQ(group->controllers[i].placement, "/")) {
|
|
|
c480ed |
+ return i;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV1Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
|
|
c480ed |
|
|
|
c480ed |
@@ -499,6 +520,7 @@ virCgroupBackend virCgroupV1Backend = {
|
|
|
c480ed |
.stealPlacement = virCgroupV1StealPlacement,
|
|
|
c480ed |
.detectControllers = virCgroupV1DetectControllers,
|
|
|
c480ed |
.hasController = virCgroupV1HasController,
|
|
|
c480ed |
+ .getAnyController = virCgroupV1GetAnyController,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|