qemu: do not put virtiofs socket in private data

Reconstruct the socket path from priv->libDir in every user.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Ján Tomko 2021-08-18 14:05:46 +02:00
parent cf5b3482c1
commit e7801a490c
4 changed files with 14 additions and 26 deletions

View File

@ -2035,14 +2035,16 @@ qemuBuildDisksCommandLine(virCommand *cmd,
static char * static char *
qemuBuildVHostUserFsChardevStr(const virDomainFSDef *fs, qemuBuildVHostUserFsChardevStr(const virDomainFSDef *fs,
const char *chardev_alias) const char *chardev_alias,
qemuDomainObjPrivate *priv)
{ {
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autofree char *socket_path = qemuDomainGetVHostUserFSSocketPath(priv, fs);
virBufferAddLit(&buf, "socket"); virBufferAddLit(&buf, "socket");
virBufferAsprintf(&buf, ",id=%s", chardev_alias); virBufferAsprintf(&buf, ",id=%s", chardev_alias);
virBufferAddLit(&buf, ",path="); virBufferAddLit(&buf, ",path=");
virQEMUBuildBufferEscapeComma(&buf, QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock); virQEMUBuildBufferEscapeComma(&buf, socket_path);
return virBufferContentAndReset(&buf); return virBufferContentAndReset(&buf);
} }
@ -2088,7 +2090,7 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd,
g_autofree char *devstr = NULL; g_autofree char *devstr = NULL;
chardev_alias = qemuDomainGetVhostUserChrAlias(fs->info.alias); chardev_alias = qemuDomainGetVhostUserChrAlias(fs->info.alias);
chrdevstr = qemuBuildVHostUserFsChardevStr(fs, chardev_alias); chrdevstr = qemuBuildVHostUserFsChardevStr(fs, chardev_alias, priv);
virCommandAddArg(cmd, "-chardev"); virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, chrdevstr); virCommandAddArg(cmd, chrdevstr);

View File

@ -196,10 +196,8 @@ qemuExtDevicesStart(virQEMUDriver *driver,
for (i = 0; i < def->nfss; i++) { for (i = 0; i < def->nfss; i++) {
virDomainFSDef *fs = def->fss[i]; virDomainFSDef *fs = def->fss[i];
if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) { if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS && !fs->sock) {
if (fs->sock) if (qemuVirtioFSStart(logManager, driver, vm, fs) < 0)
QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock = g_strdup(fs->sock);
else if (qemuVirtioFSStart(logManager, driver, vm, fs) < 0)
return -1; return -1;
} }
} }

View File

@ -183,8 +183,7 @@ qemuVirtioFSStart(virLogManager *logManager,
if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias))) if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias)))
goto cleanup; goto cleanup;
if (!(socket_path = qemuVirtioFSCreateSocketFilename(vm, fs->info.alias))) socket_path = qemuDomainGetVHostUserFSSocketPath(vm->privateData, fs);
goto cleanup;
if ((fd = qemuVirtioFSOpenChardev(driver, vm, socket_path)) < 0) if ((fd = qemuVirtioFSOpenChardev(driver, vm, socket_path)) < 0)
goto cleanup; goto cleanup;
@ -251,12 +250,9 @@ qemuVirtioFSStart(virLogManager *logManager,
goto error; goto error;
} }
QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock = g_steal_pointer(&socket_path);
ret = 0; ret = 0;
cleanup: cleanup:
if (socket_path)
unlink(socket_path);
return ret; return ret;
error: error:
@ -264,6 +260,8 @@ qemuVirtioFSStart(virLogManager *logManager,
virProcessKillPainfully(pid, true); virProcessKillPainfully(pid, true);
if (pidfile) if (pidfile)
unlink(pidfile); unlink(pidfile);
if (socket_path)
unlink(socket_path);
goto cleanup; goto cleanup;
} }
@ -284,8 +282,10 @@ qemuVirtioFSStop(virQEMUDriver *driver G_GNUC_UNUSED,
if (virPidFileForceCleanupPathFull(pidfile, true) < 0) { if (virPidFileForceCleanupPathFull(pidfile, true) < 0) {
VIR_WARN("Unable to kill virtiofsd process"); VIR_WARN("Unable to kill virtiofsd process");
} else { } else {
if (QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock) g_autofree char *socket_path = NULL;
unlink(QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock);
socket_path = qemuDomainGetVHostUserFSSocketPath(vm->privateData, fs);
unlink(socket_path);
} }
cleanup: cleanup:

View File

@ -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) { if (vm->def->vsock) {
virDomainVsockDef *vsock = vm->def->vsock; virDomainVsockDef *vsock = vm->def->vsock;
qemuDomainVsockPrivate *vsockPriv = qemuDomainVsockPrivate *vsockPriv =