Reconstruct the socket path from priv->libDir in every user.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/qemu/qemu_command.c | 8 +++++---
src/qemu/qemu_extdevice.c | 6 ++----
src/qemu/qemu_virtiofs.c | 14 +++++++-------
tests/qemuxml2argvtest.c | 12 ------------
4 files changed, 14 insertions(+), 26 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d0f961b8ea..dc4f91ce25 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2035,14 +2035,16 @@ qemuBuildDisksCommandLine(virCommand *cmd,
static char *
qemuBuildVHostUserFsChardevStr(const virDomainFSDef *fs,
- const char *chardev_alias)
+ const char *chardev_alias,
+ qemuDomainObjPrivate *priv)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+ g_autofree char *socket_path = qemuDomainGetVHostUserFSSocketPath(priv, fs);
virBufferAddLit(&buf, "socket");
virBufferAsprintf(&buf, ",id=%s", chardev_alias);
virBufferAddLit(&buf, ",path=");
- virQEMUBuildBufferEscapeComma(&buf,
QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock);
+ virQEMUBuildBufferEscapeComma(&buf, socket_path);
return virBufferContentAndReset(&buf);
}
@@ -2088,7 +2090,7 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd,
g_autofree char *devstr = NULL;
chardev_alias = qemuDomainGetVhostUserChrAlias(fs->info.alias);
- chrdevstr = qemuBuildVHostUserFsChardevStr(fs, chardev_alias);
+ chrdevstr = qemuBuildVHostUserFsChardevStr(fs, chardev_alias, priv);
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, chrdevstr);
diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c
index 98b546fc73..ef0b3f1981 100644
--- a/src/qemu/qemu_extdevice.c
+++ b/src/qemu/qemu_extdevice.c
@@ -196,10 +196,8 @@ qemuExtDevicesStart(virQEMUDriver *driver,
for (i = 0; i < def->nfss; i++) {
virDomainFSDef *fs = def->fss[i];
- if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) {
- if (fs->sock)
- QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock =
g_strdup(fs->sock);
- else if (qemuVirtioFSStart(logManager, driver, vm, fs) < 0)
+ if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS &&
!fs->sock) {
+ if (qemuVirtioFSStart(logManager, driver, vm, fs) < 0)
return -1;
}
}
diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c
index 15c05479c8..08a8b4ed42 100644
--- a/src/qemu/qemu_virtiofs.c
+++ b/src/qemu/qemu_virtiofs.c
@@ -183,8 +183,7 @@ qemuVirtioFSStart(virLogManager *logManager,
if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias)))
goto cleanup;
- if (!(socket_path = qemuVirtioFSCreateSocketFilename(vm, fs->info.alias)))
- goto cleanup;
+ socket_path = qemuDomainGetVHostUserFSSocketPath(vm->privateData, fs);
if ((fd = qemuVirtioFSOpenChardev(driver, vm, socket_path)) < 0)
goto cleanup;
@@ -251,12 +250,9 @@ qemuVirtioFSStart(virLogManager *logManager,
goto error;
}
- QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock =
g_steal_pointer(&socket_path);
ret = 0;
cleanup:
- if (socket_path)
- unlink(socket_path);
return ret;
error:
@@ -264,6 +260,8 @@ qemuVirtioFSStart(virLogManager *logManager,
virProcessKillPainfully(pid, true);
if (pidfile)
unlink(pidfile);
+ if (socket_path)
+ unlink(socket_path);
goto cleanup;
}
@@ -284,8 +282,10 @@ qemuVirtioFSStop(virQEMUDriver *driver G_GNUC_UNUSED,
if (virPidFileForceCleanupPathFull(pidfile, true) < 0) {
VIR_WARN("Unable to kill virtiofsd process");
} else {
- if (QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock)
- unlink(QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock);
+ g_autofree char *socket_path = NULL;
+
+ socket_path = qemuDomainGetVHostUserFSSocketPath(vm->privateData, fs);
+ unlink(socket_path);
}
cleanup:
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e35380293c..7df3946751 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -436,18 +436,6 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv,
}
}
- for (i = 0; i < vm->def->nfss; i++) {
- virDomainFSDef *fs = vm->def->fss[i];
- char *s;
-
- if (fs->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS ||
- QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock)
- continue;
-
- s = g_strdup_printf("/tmp/lib/domain--1-guest/fs%zu-fs.sock", i);
- QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock = s;
- }
-
if (vm->def->vsock) {
virDomainVsockDef *vsock = vm->def->vsock;
qemuDomainVsockPrivate *vsockPriv =
--
2.31.1