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