提交 b549a66e 编写于 作者: P Pavel Hrdina

vircgroup: extract virCgroupV1ValidatePlacement

Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 229a8b5d
......@@ -345,36 +345,6 @@ virCgroupDetectPlacement(virCgroupPtr group,
}
static int
virCgroupValidatePlacement(virCgroupPtr group,
pid_t pid)
{
size_t i;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
if (!group->controllers[i].mountPoint)
continue;
if (!group->controllers[i].placement) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find placement for controller %s at %s"),
virCgroupControllerTypeToString(i),
group->controllers[i].placement);
return -1;
}
VIR_DEBUG("Detected mount/mapping %zu:%s at %s in %s for pid %lld",
i,
virCgroupControllerTypeToString(i),
group->controllers[i].mountPoint,
group->controllers[i].placement,
(long long) pid);
}
return 0;
}
static int
virCgroupDetectControllers(virCgroupPtr group,
int controllers)
......@@ -500,7 +470,7 @@ virCgroupDetect(virCgroupPtr group,
return -1;
/* Check that for every mounted controller, we found our placement */
if (virCgroupValidatePlacement(group, pid) < 0)
if (group->backend->validatePlacement(group, pid) < 0)
return -1;
return 0;
......
......@@ -62,6 +62,10 @@ typedef int
const char *controllers,
const char *selfpath);
typedef int
(*virCgroupValidatePlacementCB)(virCgroupPtr group,
pid_t pid);
struct _virCgroupBackend {
virCgroupBackendType type;
......@@ -72,6 +76,7 @@ struct _virCgroupBackend {
virCgroupCopyPlacementCB copyPlacement;
virCgroupDetectMountsCB detectMounts;
virCgroupDetectPlacementCB detectPlacement;
virCgroupValidatePlacementCB validatePlacement;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
......
......@@ -372,6 +372,36 @@ virCgroupV1DetectPlacement(virCgroupPtr group,
}
static int
virCgroupV1ValidatePlacement(virCgroupPtr group,
pid_t pid)
{
size_t i;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
if (!group->controllers[i].mountPoint)
continue;
if (!group->controllers[i].placement) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find placement for v1 controller %s at %s"),
virCgroupV1ControllerTypeToString(i),
group->controllers[i].placement);
return -1;
}
VIR_DEBUG("Detected mount/mapping %zu:%s at %s in %s for pid %lld",
i,
virCgroupV1ControllerTypeToString(i),
group->controllers[i].mountPoint,
group->controllers[i].placement,
(long long) pid);
}
return 0;
}
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
......@@ -381,6 +411,7 @@ virCgroupBackend virCgroupV1Backend = {
.copyPlacement = virCgroupV1CopyPlacement,
.detectMounts = virCgroupV1DetectMounts,
.detectPlacement = virCgroupV1DetectPlacement,
.validatePlacement = virCgroupV1ValidatePlacement,
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册