From 5ac015efe124068bf06d6646489788e39c17cec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 8 Aug 2019 18:55:04 +0400 Subject: [PATCH] qemu-conf: add slirp state dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau Signed-off-by: Michal Privoznik Reviewed-by: Michal Privoznik --- src/qemu/qemu_conf.c | 3 +++ src/qemu/qemu_conf.h | 1 + src/qemu/qemu_driver.c | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 4f96b0aaa5..bf9ab32a12 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -247,6 +247,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged) goto error; if (virAsprintf(&cfg->autostartDir, "%s/qemu/autostart", cfg->configBaseDir) < 0) goto error; + if (virAsprintf(&cfg->slirpStateDir, "%s/slirp", cfg->stateDir) < 0) + goto error; /* Set the default directory to find TLS X.509 certificates. * This will then be used as a fallback if the service specific @@ -335,6 +337,7 @@ static void virQEMUDriverConfigDispose(void *obj) VIR_FREE(cfg->swtpmLogDir); VIR_FREE(cfg->stateDir); VIR_FREE(cfg->swtpmStateDir); + VIR_FREE(cfg->slirpStateDir); VIR_FREE(cfg->libDir); VIR_FREE(cfg->cacheDir); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a85ae50e14..8473d6d4ca 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -96,6 +96,7 @@ struct _virQEMUDriverConfig { char *swtpmLogDir; char *stateDir; char *swtpmStateDir; + char *slirpStateDir; /* 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 7124349f8e..69c841d5f5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -832,6 +832,11 @@ qemuStateInitialize(bool privileged, cfg->memoryBackingDir); goto error; } + if (virFileMakePath(cfg->slirpStateDir) < 0) { + virReportSystemError(errno, _("Failed to create slirp state dir %s"), + cfg->slirpStateDir); + goto error; + } if ((qemu_driver->lockFD = virPidFileAcquire(cfg->stateDir, "driver", false, getpid())) < 0) @@ -971,6 +976,13 @@ qemuStateInitialize(bool privileged, (int)cfg->group); goto error; } + if (chown(cfg->slirpStateDir, cfg->user, cfg->group) < 0) { + virReportSystemError(errno, + _("unable to set ownership of '%s' to %d:%d"), + cfg->slirpStateDir, (int)cfg->user, + (int)cfg->group); + goto error; + } run_uid = cfg->user; run_gid = cfg->group;