提交 5e2df3d0 编写于 作者: P Pavel Hrdina

vircgroup: extract virCgroupV1HasController

Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 d7f77dd6
......@@ -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);
}
......
......@@ -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;
......
......@@ -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,
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册