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