qemu: format uid/gid map for virtiofs

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>
This commit is contained in:
Ján Tomko 2023-08-16 15:40:03 +02:00
parent 6de2068dd6
commit bdf96a0f72

View 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);
}