|
|
c480ed |
From b220fdba77897f65f3e7e963868f22d7ace58724 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <b220fdba77897f65f3e7e963868f22d7ace58724@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Thu, 25 Jul 2019 13:37:01 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: fix cgroups v2 controllers detection
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
When creating new group for cgroups v2 the we cannot check
|
|
|
c480ed |
cgroups.controllers for that cgroup because the directory is created
|
|
|
c480ed |
later. In that case we should check cgroups.subtree_control of parent
|
|
|
c480ed |
group to get list of controllers enabled for child cgroups.
|
|
|
c480ed |
|
|
|
c480ed |
In order to achieve that we will prefer the parent group if it exists,
|
|
|
c480ed |
the current group will be used only for root group.
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Acked-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 7b77f3a11e9ae3e3cf0ccb71bd72d4a865b7c71e)
|
|
|
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: <ff6427994e0904f5649b70206f8f73129d1b8452.1564054553.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroup.c | 2 +-
|
|
|
c480ed |
src/util/vircgroupbackend.h | 3 ++-
|
|
|
c480ed |
src/util/vircgroupv1.c | 3 ++-
|
|
|
c480ed |
src/util/vircgroupv2.c | 23 ++++++++++++++++-------
|
|
|
c480ed |
4 files changed, 21 insertions(+), 10 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c480ed |
index 37f6def08d..2c067edc5c 100644
|
|
|
c480ed |
--- a/src/util/vircgroup.c
|
|
|
c480ed |
+++ b/src/util/vircgroup.c
|
|
|
c480ed |
@@ -412,7 +412,7 @@ virCgroupDetect(virCgroupPtr group,
|
|
|
c480ed |
|
|
|
c480ed |
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
if (group->backends[i]) {
|
|
|
c480ed |
- int rc = group->backends[i]->detectControllers(group, controllers);
|
|
|
c480ed |
+ int rc = group->backends[i]->detectControllers(group, controllers, parent);
|
|
|
c480ed |
if (rc < 0)
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
controllersAvailable |= rc;
|
|
|
c480ed |
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
|
c480ed |
index 2b5be21a76..b97f686368 100644
|
|
|
c480ed |
--- a/src/util/vircgroupbackend.h
|
|
|
c480ed |
+++ b/src/util/vircgroupbackend.h
|
|
|
c480ed |
@@ -99,7 +99,8 @@ typedef char *
|
|
|
c480ed |
|
|
|
c480ed |
typedef int
|
|
|
c480ed |
(*virCgroupDetectControllersCB)(virCgroupPtr group,
|
|
|
c480ed |
- int controllers);
|
|
|
c480ed |
+ int controllers,
|
|
|
c480ed |
+ virCgroupPtr parent);
|
|
|
c480ed |
|
|
|
c480ed |
typedef bool
|
|
|
c480ed |
(*virCgroupHasControllerCB)(virCgroupPtr cgroup,
|
|
|
c480ed |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
|
c480ed |
index a7d6c92e4c..925e8ee1c1 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv1.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv1.c
|
|
|
c480ed |
@@ -419,7 +419,8 @@ virCgroupV1StealPlacement(virCgroupPtr group)
|
|
|
c480ed |
|
|
|
c480ed |
static int
|
|
|
c480ed |
virCgroupV1DetectControllers(virCgroupPtr group,
|
|
|
c480ed |
- int controllers)
|
|
|
c480ed |
+ int controllers,
|
|
|
c480ed |
+ virCgroupPtr parent ATTRIBUTE_UNUSED)
|
|
|
c480ed |
{
|
|
|
c480ed |
size_t i;
|
|
|
c480ed |
size_t j;
|
|
|
c480ed |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
|
c480ed |
index b4e90ed46d..7b3cd64cc5 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv2.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv2.c
|
|
|
c480ed |
@@ -241,7 +241,8 @@ virCgroupV2StealPlacement(virCgroupPtr group)
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
static int
|
|
|
c480ed |
-virCgroupV2ParseControllersFile(virCgroupPtr group)
|
|
|
c480ed |
+virCgroupV2ParseControllersFile(virCgroupPtr group,
|
|
|
c480ed |
+ virCgroupPtr parent)
|
|
|
c480ed |
{
|
|
|
c480ed |
int rc;
|
|
|
c480ed |
VIR_AUTOFREE(char *) contStr = NULL;
|
|
|
c480ed |
@@ -249,10 +250,17 @@ virCgroupV2ParseControllersFile(virCgroupPtr group)
|
|
|
c480ed |
char **contList = NULL;
|
|
|
c480ed |
char **tmp;
|
|
|
c480ed |
|
|
|
c480ed |
- if (virAsprintf(&contFile, "%s%s/cgroup.controllers",
|
|
|
c480ed |
- group->unified.mountPoint,
|
|
|
c480ed |
- NULLSTR_EMPTY(group->unified.placement)) < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
+ if (parent) {
|
|
|
c480ed |
+ if (virAsprintf(&contFile, "%s%s/cgroup.subtree_control",
|
|
|
c480ed |
+ parent->unified.mountPoint,
|
|
|
c480ed |
+ NULLSTR_EMPTY(parent->unified.placement)) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ } else {
|
|
|
c480ed |
+ if (virAsprintf(&contFile, "%s%s/cgroup.controllers",
|
|
|
c480ed |
+ group->unified.mountPoint,
|
|
|
c480ed |
+ NULLSTR_EMPTY(group->unified.placement)) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
|
|
|
c480ed |
rc = virFileReadAll(contFile, 1024 * 1024, &contStr);
|
|
|
c480ed |
if (rc < 0) {
|
|
|
c480ed |
@@ -285,11 +293,12 @@ virCgroupV2ParseControllersFile(virCgroupPtr group)
|
|
|
c480ed |
|
|
|
c480ed |
static int
|
|
|
c480ed |
virCgroupV2DetectControllers(virCgroupPtr group,
|
|
|
c480ed |
- int controllers)
|
|
|
c480ed |
+ int controllers,
|
|
|
c480ed |
+ virCgroupPtr parent)
|
|
|
c480ed |
{
|
|
|
c480ed |
size_t i;
|
|
|
c480ed |
|
|
|
c480ed |
- if (virCgroupV2ParseControllersFile(group) < 0)
|
|
|
c480ed |
+ if (virCgroupV2ParseControllersFile(group, parent) < 0)
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
|
|
|
c480ed |
/* In cgroup v2 there is no cpuacct controller, the cpu.stat file always
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|