render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c480ed
From 784cb29187b72cd44c528b1435b27ca5f0a36f33 Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <784cb29187b72cd44c528b1435b27ca5f0a36f33@dist-git>
c480ed
From: Pavel Hrdina <phrdina@redhat.com>
c480ed
Date: Mon, 1 Jul 2019 17:06:32 +0200
c480ed
Subject: [PATCH] vircgroup: extract virCgroupV1HasController
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
(cherry picked from commit 5e2df3d07f63128259a9677acdbbbcd983069110)
c480ed
c480ed
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
c480ed
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
Message-Id: <e823ddab991e14aa8cb5e9b9d139236eb460b594.1561993100.git.phrdina@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/util/vircgroup.c        | 3 ++-
c480ed
 src/util/vircgroupbackend.h | 5 +++++
c480ed
 src/util/vircgroupv1.c      | 9 +++++++++
c480ed
 3 files changed, 16 insertions(+), 1 deletion(-)
c480ed
c480ed
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
c480ed
index 2e74cbbff4..5bbe42b699 100644
c480ed
--- a/src/util/vircgroup.c
c480ed
+++ b/src/util/vircgroup.c
c480ed
@@ -1443,7 +1443,8 @@ virCgroupHasController(virCgroupPtr cgroup, int controller)
c480ed
         return false;
c480ed
     if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST)
c480ed
         return false;
c480ed
-    return cgroup->controllers[controller].mountPoint != NULL;
c480ed
+
c480ed
+    return cgroup->backend->hasController(cgroup, controller);
c480ed
 }
c480ed
 
c480ed
 
c480ed
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
c480ed
index 011d1b00da..29b2fd119f 100644
c480ed
--- a/src/util/vircgroupbackend.h
c480ed
+++ b/src/util/vircgroupbackend.h
c480ed
@@ -73,6 +73,10 @@ typedef int
c480ed
 (*virCgroupDetectControllersCB)(virCgroupPtr group,
c480ed
                                 int controllers);
c480ed
 
c480ed
+typedef bool
c480ed
+(*virCgroupHasControllerCB)(virCgroupPtr cgroup,
c480ed
+                            int controller);
c480ed
+
c480ed
 struct _virCgroupBackend {
c480ed
     virCgroupBackendType type;
c480ed
 
c480ed
@@ -86,6 +90,7 @@ struct _virCgroupBackend {
c480ed
     virCgroupValidatePlacementCB validatePlacement;
c480ed
     virCgroupStealPlacementCB stealPlacement;
c480ed
     virCgroupDetectControllersCB detectControllers;
c480ed
+    virCgroupHasControllerCB hasController;
c480ed
 };
c480ed
 typedef struct _virCgroupBackend virCgroupBackend;
c480ed
 typedef virCgroupBackend *virCgroupBackendPtr;
c480ed
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
c480ed
index 11a86c061a..0638f48d50 100644
c480ed
--- a/src/util/vircgroupv1.c
c480ed
+++ b/src/util/vircgroupv1.c
c480ed
@@ -478,6 +478,14 @@ virCgroupV1DetectControllers(virCgroupPtr group,
c480ed
 }
c480ed
 
c480ed
 
c480ed
+static bool
c480ed
+virCgroupV1HasController(virCgroupPtr group,
c480ed
+                         int controller)
c480ed
+{
c480ed
+    return group->controllers[controller].mountPoint != NULL;
c480ed
+}
c480ed
+
c480ed
+
c480ed
 virCgroupBackend virCgroupV1Backend = {
c480ed
     .type = VIR_CGROUP_BACKEND_TYPE_V1,
c480ed
 
c480ed
@@ -490,6 +498,7 @@ virCgroupBackend virCgroupV1Backend = {
c480ed
     .validatePlacement = virCgroupV1ValidatePlacement,
c480ed
     .stealPlacement = virCgroupV1StealPlacement,
c480ed
     .detectControllers = virCgroupV1DetectControllers,
c480ed
+    .hasController = virCgroupV1HasController,
c480ed
 };
c480ed
 
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed