vircgroup: extract virCgroupV1HasController

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2018-08-19 19:17:27 +02:00
parent d7f77dd6d5
commit 5e2df3d07f
3 changed files with 16 additions and 1 deletions

View File

@ -1439,7 +1439,8 @@ virCgroupHasController(virCgroupPtr cgroup, int controller)
return false; return false;
if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST) if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST)
return false; return false;
return cgroup->controllers[controller].mountPoint != NULL;
return cgroup->backend->hasController(cgroup, controller);
} }

View File

@ -73,6 +73,10 @@ typedef int
(*virCgroupDetectControllersCB)(virCgroupPtr group, (*virCgroupDetectControllersCB)(virCgroupPtr group,
int controllers); int controllers);
typedef bool
(*virCgroupHasControllerCB)(virCgroupPtr cgroup,
int controller);
struct _virCgroupBackend { struct _virCgroupBackend {
virCgroupBackendType type; virCgroupBackendType type;
@ -86,6 +90,7 @@ struct _virCgroupBackend {
virCgroupValidatePlacementCB validatePlacement; virCgroupValidatePlacementCB validatePlacement;
virCgroupStealPlacementCB stealPlacement; virCgroupStealPlacementCB stealPlacement;
virCgroupDetectControllersCB detectControllers; virCgroupDetectControllersCB detectControllers;
virCgroupHasControllerCB hasController;
}; };
typedef struct _virCgroupBackend virCgroupBackend; typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr; typedef virCgroupBackend *virCgroupBackendPtr;

View File

@ -477,6 +477,14 @@ virCgroupV1DetectControllers(virCgroupPtr group,
} }
static bool
virCgroupV1HasController(virCgroupPtr group,
int controller)
{
return group->controllers[controller].mountPoint != NULL;
}
virCgroupBackend virCgroupV1Backend = { virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1, .type = VIR_CGROUP_BACKEND_TYPE_V1,
@ -489,6 +497,7 @@ virCgroupBackend virCgroupV1Backend = {
.validatePlacement = virCgroupV1ValidatePlacement, .validatePlacement = virCgroupV1ValidatePlacement,
.stealPlacement = virCgroupV1StealPlacement, .stealPlacement = virCgroupV1StealPlacement,
.detectControllers = virCgroupV1DetectControllers, .detectControllers = virCgroupV1DetectControllers,
.hasController = virCgroupV1HasController,
}; };