On Tue, Sep 18, 2018 at 5:45 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

Reviewed-by: Fabiano Fidêncio <fidencio@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 7822eec683..3d10ac2427 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1437,7 +1437,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 31be70688c..8b751af355 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;
     virCgroupGetPlacementCB getPlacement;
     virCgroupDetectControllersCB detectControllers;
+    virCgroupHasControllerCB hasController;
 };
 typedef struct _virCgroupBackend virCgroupBackend;
 typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 4dbb3020f5..c040d50141 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -477,6 +477,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,

@@ -489,6 +497,7 @@ virCgroupBackend virCgroupV1Backend = {
     .validatePlacement = virCgroupV1ValidatePlacement,
     .getPlacement = virCgroupV1GetPlacement,
     .detectControllers = virCgroupV1DetectControllers,
+    .hasController = virCgroupV1HasController,
 };
 

--
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list