]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: format uid/gid map for virtiofs
authorJán Tomko <jtomko@redhat.com>
Wed, 16 Aug 2023 13:40:03 +0000 (15:40 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 14 Dec 2023 16:10:22 +0000 (17:10 +0100)
Pass the ID map to virtiofsd, which will run the suid `newuidmap`
binary for us.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_virtiofs.c

index 230f85c29176093007f295310e3c84b140ecd41d..af51d586737c818219ecd82fea2757e46707a6c0 100644 (file)
@@ -131,6 +131,7 @@ qemuVirtioFSBuildCommandLine(virQEMUDriverConfig *cfg,
 {
     g_autoptr(virCommand) cmd = NULL;
     g_auto(virBuffer) opts = VIR_BUFFER_INITIALIZER;
+    size_t i = 4;
 
     cmd = virCommandNew(fs->binary);
 
@@ -169,6 +170,20 @@ qemuVirtioFSBuildCommandLine(virQEMUDriverConfig *cfg,
     if (cfg->virtiofsdDebug)
         virCommandAddArg(cmd, "-d");
 
+    for (i = 0; i < fs->idmap.nuidmap; i++) {
+        virCommandAddArgFormat(cmd, "--uid-map=:%u:%u:%u:",
+                               fs->idmap.uidmap[i].start,
+                               fs->idmap.uidmap[i].target,
+                               fs->idmap.uidmap[i].count);
+    }
+
+    for (i = 0; i < fs->idmap.ngidmap; i++) {
+        virCommandAddArgFormat(cmd, "--gid-map=:%u:%u:%u:",
+                               fs->idmap.gidmap[i].start,
+                               fs->idmap.gidmap[i].target,
+                               fs->idmap.gidmap[i].count);
+    }
+
     return g_steal_pointer(&cmd);
 }