Blob Blame History Raw
From 54d26cd3d6839c67970d19559aaa13294c55f9a0 Mon Sep 17 00:00:00 2001
Message-Id: <54d26cd3d6839c67970d19559aaa13294c55f9a0@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:08:22 +0200
Subject: [PATCH] util: vircgroupv2: mark only requested controllers as
 available
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When detecting available controllers on host we can be limited by list
of controllers from qemu.conf file.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
(cherry picked from commit 05807e5d42f23832ab7dab17fb7e51b48b0a7c7b)

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

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

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index e1ab1849ba..bdeab397a3 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -301,15 +301,15 @@ virCgroupV2DetectControllers(virCgroupPtr group,
         group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_CPUACCT;
     }
 
+    if (controllers >= 0)
+        group->unified.controllers &= controllers;
+
     for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++)
         VIR_DEBUG("Controller '%s' present=%s",
                   virCgroupV2ControllerTypeToString(i),
                   (group->unified.controllers & 1 << i) ? "yes" : "no");
 
-    if (controllers >= 0)
-        return controllers & group->unified.controllers;
-    else
-        return group->unified.controllers;
+    return group->unified.controllers;
 }
 
 
-- 
2.22.0