-- It seems a bit wasteful to allocate another string for this, since it is 100% always ${stateDir}/passt, but everyone else is doing this (e.g. slirpStateDir), so I'm just following along with the cult. Signed-off-by: Laine Stump <laine@xxxxxxxxxx> --- src/qemu/qemu_conf.c | 2 ++ src/qemu/qemu_conf.h | 1 + src/qemu/qemu_driver.c | 12 ++++++++++++ 3 files changed, 15 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index ae5bbcd138..bb6a55738b 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -225,6 +225,7 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged, cfg->configDir = g_strdup_printf("%s/qemu", cfg->configBaseDir); cfg->autostartDir = g_strdup_printf("%s/qemu/autostart", cfg->configBaseDir); cfg->slirpStateDir = g_strdup_printf("%s/slirp", cfg->stateDir); + cfg->passtStateDir = g_strdup_printf("%s/passt", cfg->stateDir); cfg->dbusStateDir = g_strdup_printf("%s/dbus", cfg->stateDir); /* Set the default directory to find TLS X.509 certificates. @@ -310,6 +311,7 @@ static void virQEMUDriverConfigDispose(void *obj) g_free(cfg->stateDir); g_free(cfg->swtpmStateDir); g_free(cfg->slirpStateDir); + g_free(cfg->passtStateDir); g_free(cfg->dbusStateDir); g_free(cfg->libDir); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 8cf2dd2ec5..159fd61d2b 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -95,6 +95,7 @@ struct _virQEMUDriverConfig { char *stateDir; char *swtpmStateDir; char *slirpStateDir; + char *passtStateDir; char *dbusStateDir; /* These two directories are ones QEMU processes use (so must match * the QEMU user/group */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d509582719..3d8bea6462 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -663,6 +663,11 @@ qemuStateInitialize(bool privileged, cfg->slirpStateDir); goto error; } + if (g_mkdir_with_parents(cfg->passtStateDir, 0777) < 0) { + virReportSystemError(errno, _("Failed to create passt state dir %s"), + cfg->passtStateDir); + goto error; + } if (virDirCreate(cfg->dbusStateDir, 0770, cfg->user, cfg->group, VIR_DIR_CREATE_ALLOW_EXIST) < 0) { @@ -811,6 +816,13 @@ qemuStateInitialize(bool privileged, (int)cfg->group); goto error; } + if (chown(cfg->passtStateDir, cfg->user, cfg->group) < 0) { + virReportSystemError(errno, + _("unable to set ownership of '%s' to %d:%d"), + cfg->passtStateDir, (int)cfg->user, + (int)cfg->group); + goto error; + } run_uid = cfg->user; run_gid = cfg->group; -- 2.38.1