提交 525ac688 编写于 作者: P Pavel Hrdina

vircgroup: introduce virCgroupV2SetOwner

Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 cda8ed06
......@@ -494,6 +494,32 @@ virCgroupV2BindMount(virCgroupPtr group,
}
static int
virCgroupV2SetOwner(virCgroupPtr cgroup,
uid_t uid,
gid_t gid,
int controllers ATTRIBUTE_UNUSED)
{
VIR_AUTOFREE(char *) base = NULL;
if (virAsprintf(&base, "%s%s", cgroup->unified.mountPoint,
cgroup->unified.placement) < 0) {
return -1;
}
if (virFileChownFiles(base, uid, gid) < 0)
return -1;
if (chown(base, uid, gid) < 0) {
virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"),
base, uid, gid);
return -1;
}
return 0;
}
virCgroupBackend virCgroupV2Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V2,
......@@ -514,6 +540,7 @@ virCgroupBackend virCgroupV2Backend = {
.addTask = virCgroupV2AddTask,
.hasEmptyTasks = virCgroupV2HasEmptyTasks,
.bindMount = virCgroupV2BindMount,
.setOwner = virCgroupV2SetOwner,
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册