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