render / rpms / libvirt

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