From: Marc-André Lureau <marcandre.lureau(a)redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau(a)redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange(a)redhat.com>
Reviewed-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_conf.c | 2 ++
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_driver.c | 12 ++++++++++++
tests/testutilsqemu.c | 2 ++
4 files changed, 17 insertions(+)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index b376841388..1708f4f5ad 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -226,6 +226,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->rdpStateDir = g_strdup_printf("%s/rdp", cfg->stateDir);
cfg->passtStateDir = g_strdup_printf("%s/passt", cfg->stateDir);
cfg->dbusStateDir = g_strdup_printf("%s/dbus", cfg->stateDir);
@@ -327,6 +328,7 @@ static void virQEMUDriverConfigDispose(void *obj)
g_free(cfg->slirpStateDir);
g_free(cfg->passtStateDir);
g_free(cfg->dbusStateDir);
+ g_free(cfg->rdpStateDir);
g_free(cfg->libDir);
g_free(cfg->cacheDir);
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 3e1b41af73..af1f59708f 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -99,6 +99,7 @@ struct _virQEMUDriverConfig {
char *slirpStateDir;
char *passtStateDir;
char *dbusStateDir;
+ char *rdpStateDir;
/* These two directories are ones QEMU processes use (so must match
* the QEMU user/group */
char *libDir;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f0e9681161..6f0ce5a2f3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -648,6 +648,11 @@ qemuStateInitialize(bool privileged,
cfg->dbusStateDir);
goto error;
}
+ if (g_mkdir_with_parents(cfg->rdpStateDir, 0777) < 0) {
+ virReportSystemError(errno, _("Failed to create rdp state dir %1$s"),
+ cfg->rdpStateDir);
+ goto error;
+ }
qemu_driver->inhibitor = virInhibitorNew(
VIR_INHIBITOR_WHAT_SHUTDOWN,
@@ -793,6 +798,13 @@ qemuStateInitialize(bool privileged,
(int)cfg->group);
goto error;
}
+ if (chown(cfg->rdpStateDir, cfg->user, cfg->group) < 0) {
+ virReportSystemError(errno,
+ _("unable to set ownership of '%1$s' to
%2$d:%3$d"),
+ cfg->rdpStateDir, (int)cfg->user,
+ (int)cfg->group);
+ goto error;
+ }
run_uid = cfg->user;
run_gid = cfg->group;
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 20409a6535..6189b47d9b 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -330,6 +330,8 @@ int qemuTestDriverInit(virQEMUDriver *driver)
cfg->passtStateDir = g_strdup("/var/run/libvirt/qemu/passt");
VIR_FREE(cfg->dbusStateDir);
cfg->dbusStateDir = g_strdup("/var/run/libvirt/qemu/dbus");
+ VIR_FREE(cfg->rdpStateDir);
+ cfg->rdpStateDir = g_strdup("/var/run/libvirt/qemu/rdp");
if (!g_mkdtemp(statedir)) {
fprintf(stderr, "Cannot create fake stateDir");
--
2.47.0