|
|
c313de |
From 8c784cd15bbac88334271f95d14a9770c1b2d864 Mon Sep 17 00:00:00 2001
|
|
|
c313de |
Message-Id: <8c784cd15bbac88334271f95d14a9770c1b2d864@dist-git>
|
|
|
c313de |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c313de |
Date: Mon, 1 Jul 2019 17:08:17 +0200
|
|
|
c313de |
Subject: [PATCH] util: vircgroup: improve controller detection
|
|
|
c313de |
MIME-Version: 1.0
|
|
|
c313de |
Content-Type: text/plain; charset=UTF-8
|
|
|
c313de |
Content-Transfer-Encoding: 8bit
|
|
|
c313de |
|
|
|
c313de |
This affects only cgroups v2 where enabled controllers are not based on
|
|
|
c313de |
available mount points but on the list provided in cgroup.controllers
|
|
|
c313de |
file. However, moving it will fill in placement as well, so it needs
|
|
|
c313de |
to be freed together with mount point if we don't need that controller.
|
|
|
c313de |
|
|
|
c313de |
Before this patch we were assuming that all controllers available in
|
|
|
c313de |
root cgroup where available in all other sub-cgroups which was wrong.
|
|
|
c313de |
|
|
|
c313de |
In order to fix it we need to move the cgroup controllers detection
|
|
|
c313de |
after cgroup placement was prepared in order to build correct path for
|
|
|
c313de |
cgroup.controllers file.
|
|
|
c313de |
|
|
|
c313de |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c313de |
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
c313de |
(cherry picked from commit d3007c844d8aa0caa0328ab18275be375f597704)
|
|
|
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: <cec99e4c53912c3ee6f45012fc4fd760f6e8445b.1561993100.git.phrdina@redhat.com>
|
|
|
c313de |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c313de |
---
|
|
|
c313de |
src/util/vircgroup.c | 32 ++++++++++++++++----------------
|
|
|
c313de |
src/util/vircgroupv1.c | 1 +
|
|
|
c313de |
src/util/vircgroupv2.c | 5 +++--
|
|
|
c313de |
3 files changed, 20 insertions(+), 18 deletions(-)
|
|
|
c313de |
|
|
|
c313de |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c313de |
index 4f71a1d197..ff2a0b75b5 100644
|
|
|
c313de |
--- a/src/util/vircgroup.c
|
|
|
c313de |
+++ b/src/util/vircgroup.c
|
|
|
c313de |
@@ -386,22 +386,6 @@ virCgroupDetect(virCgroupPtr group,
|
|
|
c313de |
return -1;
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
- for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c313de |
- if (group->backends[i]) {
|
|
|
c313de |
- int rc = group->backends[i]->detectControllers(group, controllers, parent);
|
|
|
c313de |
- if (rc < 0)
|
|
|
c313de |
- return -1;
|
|
|
c313de |
- controllersAvailable |= rc;
|
|
|
c313de |
- }
|
|
|
c313de |
- }
|
|
|
c313de |
-
|
|
|
c313de |
- /* Check that at least 1 controller is available */
|
|
|
c313de |
- if (controllersAvailable == 0) {
|
|
|
c313de |
- virReportSystemError(ENXIO, "%s",
|
|
|
c313de |
- _("At least one cgroup controller is required"));
|
|
|
c313de |
- return -1;
|
|
|
c313de |
- }
|
|
|
c313de |
-
|
|
|
c313de |
/* In some cases we can copy part of the placement info
|
|
|
c313de |
* based on the parent cgroup...
|
|
|
c313de |
*/
|
|
|
c313de |
@@ -426,6 +410,22 @@ virCgroupDetect(virCgroupPtr group,
|
|
|
c313de |
}
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c313de |
+ if (group->backends[i]) {
|
|
|
c313de |
+ int rc = group->backends[i]->detectControllers(group, controllers, parent);
|
|
|
c313de |
+ if (rc < 0)
|
|
|
c313de |
+ return -1;
|
|
|
c313de |
+ controllersAvailable |= rc;
|
|
|
c313de |
+ }
|
|
|
c313de |
+ }
|
|
|
c313de |
+
|
|
|
c313de |
+ /* Check that at least 1 controller is available */
|
|
|
c313de |
+ if (controllersAvailable == 0) {
|
|
|
c313de |
+ virReportSystemError(ENXIO, "%s",
|
|
|
c313de |
+ _("At least one cgroup controller is required"));
|
|
|
c313de |
+ return -1;
|
|
|
c313de |
+ }
|
|
|
c313de |
+
|
|
|
c313de |
return 0;
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
|
c313de |
index 784a963b79..5b218c7f78 100644
|
|
|
c313de |
--- a/src/util/vircgroupv1.c
|
|
|
c313de |
+++ b/src/util/vircgroupv1.c
|
|
|
c313de |
@@ -463,6 +463,7 @@ virCgroupV1DetectControllers(virCgroupPtr group,
|
|
|
c313de |
}
|
|
|
c313de |
}
|
|
|
c313de |
VIR_FREE(group->legacy[i].mountPoint);
|
|
|
c313de |
+ VIR_FREE(group->legacy[i].placement);
|
|
|
c313de |
}
|
|
|
c313de |
}
|
|
|
c313de |
} else {
|
|
|
c313de |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
|
c313de |
index 60598712c8..10f8a9bbdf 100644
|
|
|
c313de |
--- a/src/util/vircgroupv2.c
|
|
|
c313de |
+++ b/src/util/vircgroupv2.c
|
|
|
c313de |
@@ -249,8 +249,9 @@ virCgroupV2ParseControllersFile(virCgroupPtr group)
|
|
|
c313de |
char **contList = NULL;
|
|
|
c313de |
char **tmp;
|
|
|
c313de |
|
|
|
c313de |
- if (virAsprintf(&contFile, "%s/cgroup.controllers",
|
|
|
c313de |
- group->unified.mountPoint) < 0)
|
|
|
c313de |
+ if (virAsprintf(&contFile, "%s%s/cgroup.controllers",
|
|
|
c313de |
+ group->unified.mountPoint,
|
|
|
c313de |
+ NULLSTR_EMPTY(group->unified.placement)) < 0)
|
|
|
c313de |
return -1;
|
|
|
c313de |
|
|
|
c313de |
rc = virFileReadAll(contFile, 1024 * 1024, &contStr);
|
|
|
c313de |
--
|
|
|
c313de |
2.22.0
|
|
|
c313de |
|