Blob Blame History Raw
From 784cb29187b72cd44c528b1435b27ca5f0a36f33 Mon Sep 17 00:00:00 2001
Message-Id: <784cb29187b72cd44c528b1435b27ca5f0a36f33@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:06:32 +0200
Subject: [PATCH] vircgroup: extract virCgroupV1HasController
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 5e2df3d07f63128259a9677acdbbbcd983069110)

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <e823ddab991e14aa8cb5e9b9d139236eb460b594.1561993100.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/util/vircgroup.c        | 3 ++-
 src/util/vircgroupbackend.h | 5 +++++
 src/util/vircgroupv1.c      | 9 +++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 2e74cbbff4..5bbe42b699 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1443,7 +1443,8 @@ virCgroupHasController(virCgroupPtr cgroup, int controller)
         return false;
     if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST)
         return false;
-    return cgroup->controllers[controller].mountPoint != NULL;
+
+    return cgroup->backend->hasController(cgroup, controller);
 }
 
 
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 011d1b00da..29b2fd119f 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -73,6 +73,10 @@ typedef int
 (*virCgroupDetectControllersCB)(virCgroupPtr group,
                                 int controllers);
 
+typedef bool
+(*virCgroupHasControllerCB)(virCgroupPtr cgroup,
+                            int controller);
+
 struct _virCgroupBackend {
     virCgroupBackendType type;
 
@@ -86,6 +90,7 @@ struct _virCgroupBackend {
     virCgroupValidatePlacementCB validatePlacement;
     virCgroupStealPlacementCB stealPlacement;
     virCgroupDetectControllersCB detectControllers;
+    virCgroupHasControllerCB hasController;
 };
 typedef struct _virCgroupBackend virCgroupBackend;
 typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 11a86c061a..0638f48d50 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -478,6 +478,14 @@ virCgroupV1DetectControllers(virCgroupPtr group,
 }
 
 
+static bool
+virCgroupV1HasController(virCgroupPtr group,
+                         int controller)
+{
+    return group->controllers[controller].mountPoint != NULL;
+}
+
+
 virCgroupBackend virCgroupV1Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V1,
 
@@ -490,6 +498,7 @@ virCgroupBackend virCgroupV1Backend = {
     .validatePlacement = virCgroupV1ValidatePlacement,
     .stealPlacement = virCgroupV1StealPlacement,
     .detectControllers = virCgroupV1DetectControllers,
+    .hasController = virCgroupV1HasController,
 };
 
 
-- 
2.22.0