|
|
c480ed |
From 931ae6bf56044020c057716e1db59288beca2bc8 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <931ae6bf56044020c057716e1db59288beca2bc8@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:06:05 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: Extract controller detection into function
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
(cherry picked from commit bddf975c7615a30da0709b6c1509b43440d72393)
|
|
|
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: <484f007f9f43d727b829bb18fa4ad2f116a7fae1.1561993099.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroup.c | 48 +++++++++++++++++++++++++++++---------------
|
|
|
c480ed |
1 file changed, 32 insertions(+), 16 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c480ed |
index 45b854e864..6f27c50cbd 100644
|
|
|
c480ed |
--- a/src/util/vircgroup.c
|
|
|
c480ed |
+++ b/src/util/vircgroup.c
|
|
|
c480ed |
@@ -631,24 +631,11 @@ virCgroupDetectPlacement(virCgroupPtr group,
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
static int
|
|
|
c480ed |
-virCgroupDetect(virCgroupPtr group,
|
|
|
c480ed |
- pid_t pid,
|
|
|
c480ed |
- int controllers,
|
|
|
c480ed |
- const char *path,
|
|
|
c480ed |
- virCgroupPtr parent)
|
|
|
c480ed |
+virCgroupDetectControllers(virCgroupPtr group,
|
|
|
c480ed |
+ int controllers)
|
|
|
c480ed |
{
|
|
|
c480ed |
size_t i;
|
|
|
c480ed |
size_t j;
|
|
|
c480ed |
- VIR_DEBUG("group=%p controllers=%d path=%s parent=%p",
|
|
|
c480ed |
- group, controllers, path, parent);
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (parent) {
|
|
|
c480ed |
- if (virCgroupCopyMounts(group, parent) < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
- } else {
|
|
|
c480ed |
- if (virCgroupDetectMounts(group) < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
- }
|
|
|
c480ed |
|
|
|
c480ed |
if (controllers >= 0) {
|
|
|
c480ed |
VIR_DEBUG("Filtering controllers %d", controllers);
|
|
|
c480ed |
@@ -703,8 +690,37 @@ virCgroupDetect(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
+ return controllers;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupDetect(virCgroupPtr group,
|
|
|
c480ed |
+ pid_t pid,
|
|
|
c480ed |
+ int controllers,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ virCgroupPtr parent)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+ int rc;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ VIR_DEBUG("group=%p controllers=%d path=%s parent=%p",
|
|
|
c480ed |
+ group, controllers, path, parent);
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (parent) {
|
|
|
c480ed |
+ if (virCgroupCopyMounts(group, parent) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ } else {
|
|
|
c480ed |
+ if (virCgroupDetectMounts(group) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ rc = virCgroupDetectControllers(group, controllers);
|
|
|
c480ed |
+ if (rc < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
/* Check that at least 1 controller is available */
|
|
|
c480ed |
- if (!controllers) {
|
|
|
c480ed |
+ if (rc == 0) {
|
|
|
c480ed |
virReportSystemError(ENXIO, "%s",
|
|
|
c480ed |
_("At least one cgroup controller is required"));
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|