提交 3ae7b990 编写于 作者: P Pavel Hrdina

vircgroup: Extract placement validation into function

Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 bddf975c
......@@ -630,6 +630,36 @@ 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)
......@@ -701,7 +731,6 @@ virCgroupDetect(virCgroupPtr group,
const char *path,
virCgroupPtr parent)
{
size_t i;
int rc;
VIR_DEBUG("group=%p controllers=%d path=%s parent=%p",
......@@ -738,25 +767,8 @@ virCgroupDetect(virCgroupPtr group,
return -1;
/* Check that for every mounted controller, we found our placement */
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);
}
if (virCgroupValidatePlacement(group, pid) < 0)
return -1;
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册