Blame SOURCES/libvirt-util-vircgroupv2-don-t-error-out-if-enabling-controller-fails.patch

c313de
From 02b2342b6b5e45e3f41cb145521f53118ba8430f Mon Sep 17 00:00:00 2001
c313de
Message-Id: <02b2342b6b5e45e3f41cb145521f53118ba8430f@dist-git>
c313de
From: Pavel Hrdina <phrdina@redhat.com>
c313de
Date: Mon, 1 Jul 2019 17:08:21 +0200
c313de
Subject: [PATCH] util: vircgroupv2: don't error out if enabling controller
c313de
 fails
c313de
MIME-Version: 1.0
c313de
Content-Type: text/plain; charset=UTF-8
c313de
Content-Transfer-Encoding: 8bit
c313de
c313de
Currently CPU controller cannot be enabled if there is any real-time
c313de
task running and is assigned to non-root cgroup which is the case on
c313de
several distributions with graphical environment.
c313de
c313de
Instead of erroring out treat it as the controller is not available.
c313de
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
c313de
(cherry picked from commit 1d49cdcd116186e079db5668893da17f56141652)
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: <4a10dec59ca8cf5a2f81acf70d43f48b0a3bfd82.1561993100.git.phrdina@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
---
c313de
 src/util/vircgroupv2.c | 13 ++++++++++++-
c313de
 1 file changed, 12 insertions(+), 1 deletion(-)
c313de
c313de
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
c313de
index a67d5cfe04..e1ab1849ba 100644
c313de
--- a/src/util/vircgroupv2.c
c313de
+++ b/src/util/vircgroupv2.c
c313de
@@ -437,6 +437,8 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
c313de
         } else {
c313de
             size_t i;
c313de
             for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
c313de
+                int rc;
c313de
+
c313de
                 if (!virCgroupV2HasController(parent, i))
c313de
                     continue;
c313de
 
c313de
@@ -444,8 +446,17 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
c313de
                 if (i == VIR_CGROUP_CONTROLLER_CPUACCT)
c313de
                     continue;
c313de
 
c313de
-                if (virCgroupV2EnableController(parent, i, true) < 0)
c313de
+                rc = virCgroupV2EnableController(parent, i, false);
c313de
+                if (rc < 0) {
c313de
+                    if (rc == -2) {
c313de
+                        virResetLastError();
c313de
+                        VIR_DEBUG("failed to enable '%s' controller, skipping",
c313de
+                                  virCgroupV2ControllerTypeToString(i));
c313de
+                        group->unified.controllers &= ~(1 << i);
c313de
+                        continue;
c313de
+                    }
c313de
                     return -1;
c313de
+                }
c313de
             }
c313de
         }
c313de
     }
c313de
-- 
c313de
2.22.0
c313de