[PATCH v2 19/53] [ACKED] vircgroup: introduce virCgroupV2SetOwner

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/util/vircgroupv2.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 2e296b738a..976e5e449b 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -503,6 +503,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,
 
@@ -523,6 +549,7 @@ virCgroupBackend virCgroupV2Backend = {
     .addTask = virCgroupV2AddTask,
     .hasEmptyTasks = virCgroupV2HasEmptyTasks,
     .bindMount = virCgroupV2BindMount,
+    .setOwner = virCgroupV2SetOwner,
 };
 
 
-- 
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux