mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
vircgroup: introduce virCgroupV2SetOwner
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
cda8ed0646
commit
525ac6885b
@ -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 = {
|
virCgroupBackend virCgroupV2Backend = {
|
||||||
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
||||||
|
|
||||||
@ -514,6 +540,7 @@ virCgroupBackend virCgroupV2Backend = {
|
|||||||
.addTask = virCgroupV2AddTask,
|
.addTask = virCgroupV2AddTask,
|
||||||
.hasEmptyTasks = virCgroupV2HasEmptyTasks,
|
.hasEmptyTasks = virCgroupV2HasEmptyTasks,
|
||||||
.bindMount = virCgroupV2BindMount,
|
.bindMount = virCgroupV2BindMount,
|
||||||
|
.setOwner = virCgroupV2SetOwner,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user