Blob Blame History Raw
From 6d526969ab72e7c35b988a7154d8343001a05208 Mon Sep 17 00:00:00 2001
Message-Id: <6d526969ab72e7c35b988a7154d8343001a05208@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Thu, 25 Jul 2019 13:37:02 +0200
Subject: [PATCH] vircgroupv2: store enabled controllers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In cgroups v2 when a new group is created by default no controller is
enabled so the detection code will not detect any controllers.

When enabling the controllers we should also store them for the group.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
(cherry picked from commit 56fdf3f025207a550726767e3f0ec1f290603ba4)

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <3cef886d4257a746e5a7182246d5457664d8bcec.1564054553.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/util/vircgroupv2.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 7b3cd64cc5..9ae47e775e 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -364,7 +364,8 @@ virCgroupV2PathOfController(virCgroupPtr group,
  *          0 on success
  */
 static int
-virCgroupV2EnableController(virCgroupPtr parent,
+virCgroupV2EnableController(virCgroupPtr group,
+                            virCgroupPtr parent,
                             int controller,
                             bool report)
 {
@@ -390,6 +391,8 @@ virCgroupV2EnableController(virCgroupPtr parent,
         return -2;
     }
 
+    group->unified.controllers |= 1 << controller;
+
     return 0;
 }
 
@@ -431,14 +434,14 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
             }
 
             if (virCgroupV2HasController(parent, VIR_CGROUP_CONTROLLER_CPU) &&
-                virCgroupV2EnableController(parent,
+                virCgroupV2EnableController(group, parent,
                                             VIR_CGROUP_CONTROLLER_CPU,
                                             true) < 0) {
                 return -1;
             }
 
             if (virCgroupV2HasController(parent, VIR_CGROUP_CONTROLLER_CPUSET) &&
-                virCgroupV2EnableController(parent,
+                virCgroupV2EnableController(group, parent,
                                             VIR_CGROUP_CONTROLLER_CPUSET,
                                             true) < 0) {
                 return -1;
@@ -455,7 +458,7 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
                 if (i == VIR_CGROUP_CONTROLLER_CPUACCT)
                     continue;
 
-                rc = virCgroupV2EnableController(parent, i, false);
+                rc = virCgroupV2EnableController(group, parent, i, false);
                 if (rc < 0) {
                     if (rc == -2) {
                         virResetLastError();
-- 
2.22.0