From 5e2df3d07f63128259a9677acdbbbcd983069110 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Sun, 19 Aug 2018 19:17:27 +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 Reviewed-by: Ján Tomko Signed-off-by: Pavel Hrdina --- 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 61c62b08c2..80b9a0c83f 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1439,7 +1439,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 9a04cc1818..0b41fca1cc 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, .stealPlacement = virCgroupV1StealPlacement, .detectControllers = virCgroupV1DetectControllers, + .hasController = virCgroupV1HasController, };