d76c62
From d4f90466fc4685b72ae9ca4bae1d022c04f0e2be Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <d4f90466fc4685b72ae9ca4bae1d022c04f0e2be@dist-git>
d76c62
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
d76c62
Date: Wed, 4 Mar 2020 12:42:46 +0100
d76c62
Subject: [PATCH] qemu: add code for handling virtiofsd
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Start virtiofsd for each <filesystem> device using it.
d76c62
d76c62
Pre-create the socket for communication with QEMU and pass it
d76c62
to virtiofsd.
d76c62
d76c62
Note that virtiofsd needs to run as root.
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1694166
d76c62
d76c62
Introduced by QEMU commit a43efa34c7d7b628cbf1ec0fe60043e5c91043ea
d76c62
d76c62
Signed-off-by: Ján Tomko <jtomko@redhat.com>
d76c62
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Tested-by: Andrea Bolognani <abologna@redhat.com>
d76c62
(cherry picked from commit f0f986efa8a8e352fbdce7079ec440a4f3c8f522)
d76c62
Signed-off-by: Ján Tomko <jtomko@redhat.com>
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1694166
d76c62
Message-Id: <78ba169fbe59c5307db462ad78b65b06776d64a6.1583322091.git.jtomko@redhat.com>
d76c62
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
d76c62
---
d76c62
 po/POTFILES.in            |   1 +
d76c62
 src/qemu/Makefile.inc.am  |   2 +
d76c62
 src/qemu/qemu_domain.c    |   5 +-
d76c62
 src/qemu/qemu_domain.h    |   2 +-
d76c62
 src/qemu/qemu_extdevice.c |  20 ++-
d76c62
 src/qemu/qemu_virtiofs.c  | 301 ++++++++++++++++++++++++++++++++++++++
d76c62
 src/qemu/qemu_virtiofs.h  |  37 +++++
d76c62
 tests/qemuxml2argvtest.c  |  11 ++
d76c62
 8 files changed, 376 insertions(+), 3 deletions(-)
d76c62
 create mode 100644 src/qemu/qemu_virtiofs.c
d76c62
 create mode 100644 src/qemu/qemu_virtiofs.h
d76c62
d76c62
diff --git a/po/POTFILES.in b/po/POTFILES.in
d76c62
index faf173584e..29984042f4 100644
d76c62
--- a/po/POTFILES.in
d76c62
+++ b/po/POTFILES.in
d76c62
@@ -169,6 +169,7 @@
d76c62
 @SRCDIR@/src/qemu/qemu_tpm.c
d76c62
 @SRCDIR@/src/qemu/qemu_vhost_user.c
d76c62
 @SRCDIR@/src/qemu/qemu_vhost_user_gpu.c
d76c62
+@SRCDIR@/src/qemu/qemu_virtiofs.c
d76c62
 @SRCDIR@/src/remote/remote_daemon.c
d76c62
 @SRCDIR@/src/remote/remote_daemon_config.c
d76c62
 @SRCDIR@/src/remote/remote_daemon_dispatch.c
d76c62
diff --git a/src/qemu/Makefile.inc.am b/src/qemu/Makefile.inc.am
d76c62
index 967f6e75a2..77786526ea 100644
d76c62
--- a/src/qemu/Makefile.inc.am
d76c62
+++ b/src/qemu/Makefile.inc.am
d76c62
@@ -67,6 +67,8 @@ QEMU_DRIVER_SOURCES = \
d76c62
 	qemu/qemu_vhost_user.h \
d76c62
 	qemu/qemu_vhost_user_gpu.c \
d76c62
 	qemu/qemu_vhost_user_gpu.h \
d76c62
+	qemu/qemu_virtiofs.c \
d76c62
+	qemu/qemu_virtiofs.h \
d76c62
 	qemu/qemu_checkpoint.c \
d76c62
 	qemu/qemu_checkpoint.h \
d76c62
 	qemu/qemu_backup.c \
d76c62
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
d76c62
index 79d8de2e42..3cbe7ef6e1 100644
d76c62
--- a/src/qemu/qemu_domain.c
d76c62
+++ b/src/qemu/qemu_domain.c
d76c62
@@ -1440,8 +1440,11 @@ qemuDomainFSPrivateNew(void)
d76c62
 
d76c62
 
d76c62
 static void
d76c62
-qemuDomainFSPrivateDispose(void *obj G_GNUC_UNUSED)
d76c62
+qemuDomainFSPrivateDispose(void *obj)
d76c62
 {
d76c62
+    qemuDomainFSPrivatePtr priv = obj;
d76c62
+
d76c62
+    g_free(priv->vhostuser_fs_sock);
d76c62
 }
d76c62
 
d76c62
 static virClassPtr qemuDomainVideoPrivateClass;
d76c62
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
d76c62
index c581b3a162..83150e4e6d 100644
d76c62
--- a/src/qemu/qemu_domain.h
d76c62
+++ b/src/qemu/qemu_domain.h
d76c62
@@ -568,7 +568,7 @@ typedef qemuDomainFSPrivate *qemuDomainFSPrivatePtr;
d76c62
 struct _qemuDomainFSPrivate {
d76c62
     virObject parent;
d76c62
 
d76c62
-    int dummy;
d76c62
+    char *vhostuser_fs_sock;
d76c62
 };
d76c62
 
d76c62
 
d76c62
diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c
d76c62
index bb73787b8d..bfa770f45a 100644
d76c62
--- a/src/qemu/qemu_extdevice.c
d76c62
+++ b/src/qemu/qemu_extdevice.c
d76c62
@@ -20,11 +20,13 @@
d76c62
 
d76c62
 #include <config.h>
d76c62
 
d76c62
+#include "qemu_command.h"
d76c62
 #include "qemu_extdevice.h"
d76c62
 #include "qemu_vhost_user_gpu.h"
d76c62
 #include "qemu_domain.h"
d76c62
 #include "qemu_tpm.h"
d76c62
 #include "qemu_slirp.h"
d76c62
+#include "qemu_virtiofs.h"
d76c62
 
d76c62
 #include "viralloc.h"
d76c62
 #include "virlog.h"
d76c62
@@ -153,7 +155,7 @@ qemuExtDevicesCleanupHost(virQEMUDriverPtr driver,
d76c62
 int
d76c62
 qemuExtDevicesStart(virQEMUDriverPtr driver,
d76c62
                     virDomainObjPtr vm,
d76c62
-                    virLogManagerPtr logManager G_GNUC_UNUSED,
d76c62
+                    virLogManagerPtr logManager,
d76c62
                     bool incomingMigration)
d76c62
 {
d76c62
     virDomainDefPtr def = vm->def;
d76c62
@@ -183,6 +185,15 @@ qemuExtDevicesStart(virQEMUDriverPtr driver,
d76c62
             return -1;
d76c62
     }
d76c62
 
d76c62
+    for (i = 0; i < def->nfss; i++) {
d76c62
+        virDomainFSDefPtr fs = def->fss[i];
d76c62
+
d76c62
+        if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) {
d76c62
+            if (qemuVirtioFSStart(logManager, driver, vm, fs) < 0)
d76c62
+                return -1;
d76c62
+        }
d76c62
+    }
d76c62
+
d76c62
     return 0;
d76c62
 }
d76c62
 
d76c62
@@ -214,6 +225,13 @@ qemuExtDevicesStop(virQEMUDriverPtr driver,
d76c62
         if (slirp)
d76c62
             qemuSlirpStop(slirp, vm, driver, net, false);
d76c62
     }
d76c62
+
d76c62
+    for (i = 0; i < def->nfss; i++) {
d76c62
+        virDomainFSDefPtr fs = def->fss[i];
d76c62
+
d76c62
+        if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS)
d76c62
+            qemuVirtioFSStop(driver, vm, fs);
d76c62
+    }
d76c62
 }
d76c62
 
d76c62
 
d76c62
diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c
d76c62
new file mode 100644
d76c62
index 0000000000..09ab2cef27
d76c62
--- /dev/null
d76c62
+++ b/src/qemu/qemu_virtiofs.c
d76c62
@@ -0,0 +1,301 @@
d76c62
+/*
d76c62
+ * qemu_virtiofs.c: virtiofs support
d76c62
+ *
d76c62
+ * This library is free software; you can redistribute it and/or
d76c62
+ * modify it under the terms of the GNU Lesser General Public
d76c62
+ * License as published by the Free Software Foundation; either
d76c62
+ * version 2.1 of the License, or (at your option) any later version.
d76c62
+ *
d76c62
+ * This library is distributed in the hope that it will be useful,
d76c62
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
d76c62
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
d76c62
+ * Lesser General Public License for more details.
d76c62
+ *
d76c62
+ * You should have received a copy of the GNU Lesser General Public
d76c62
+ * License along with this library.  If not, see
d76c62
+ * <http://www.gnu.org/licenses/>.
d76c62
+ */
d76c62
+
d76c62
+#include <config.h>
d76c62
+
d76c62
+#include <sys/types.h>
d76c62
+#include <sys/stat.h>
d76c62
+#include <fcntl.h>
d76c62
+
d76c62
+#include "logging/log_manager.h"
d76c62
+#include "virlog.h"
d76c62
+#include "qemu_command.h"
d76c62
+#include "qemu_conf.h"
d76c62
+#include "qemu_extdevice.h"
d76c62
+#include "qemu_security.h"
d76c62
+#include "qemu_virtiofs.h"
d76c62
+#include "virpidfile.h"
d76c62
+#include "virqemu.h"
d76c62
+#include "virutil.h"
d76c62
+
d76c62
+#define VIR_FROM_THIS VIR_FROM_QEMU
d76c62
+
d76c62
+
d76c62
+char *
d76c62
+qemuVirtioFSCreatePidFilename(virDomainObjPtr vm,
d76c62
+                              const char *alias)
d76c62
+{
d76c62
+    qemuDomainObjPrivatePtr priv = vm->privateData;
d76c62
+    g_autofree char *shortName = NULL;
d76c62
+    g_autofree char *name = NULL;
d76c62
+
d76c62
+    if (!(shortName = virDomainDefGetShortName(vm->def)))
d76c62
+        return NULL;
d76c62
+
d76c62
+    name = g_strdup_printf("%s-%s-virtiofsd", shortName, alias);
d76c62
+
d76c62
+    return virPidFileBuildPath(priv->libDir, name);
d76c62
+}
d76c62
+
d76c62
+
d76c62
+char *
d76c62
+qemuVirtioFSCreateSocketFilename(virDomainObjPtr vm,
d76c62
+                                 const char *alias)
d76c62
+{
d76c62
+    qemuDomainObjPrivatePtr priv = vm->privateData;
d76c62
+
d76c62
+    return virFileBuildPath(priv->libDir, alias, "-virtiofsd.sock");
d76c62
+}
d76c62
+
d76c62
+
d76c62
+static char *
d76c62
+qemuVirtioFSCreateLogFilename(virQEMUDriverConfigPtr cfg,
d76c62
+                              const virDomainDef *def,
d76c62
+                              const char *alias)
d76c62
+{
d76c62
+    g_autofree char *name = NULL;
d76c62
+
d76c62
+    name = g_strdup_printf("%s-%s", def->name, alias);
d76c62
+
d76c62
+    return virFileBuildPath(cfg->logDir, name, "-virtiofsd.log");
d76c62
+}
d76c62
+
d76c62
+
d76c62
+static int
d76c62
+qemuVirtioFSOpenChardev(virQEMUDriverPtr driver,
d76c62
+                        virDomainObjPtr vm,
d76c62
+                        const char *socket_path)
d76c62
+{
d76c62
+    virDomainChrSourceDefPtr chrdev = virDomainChrSourceDefNew(NULL);
d76c62
+    virDomainChrDef chr = { .source = chrdev };
d76c62
+    VIR_AUTOCLOSE fd = -1;
d76c62
+    int ret = -1;
d76c62
+
d76c62
+    chrdev->type = VIR_DOMAIN_CHR_TYPE_UNIX;
d76c62
+    chrdev->data.nix.listen = true;
d76c62
+    chrdev->data.nix.path = g_strdup(socket_path);
d76c62
+
d76c62
+    if (qemuSecuritySetDaemonSocketLabel(driver->securityManager, vm->def) < 0)
d76c62
+        goto cleanup;
d76c62
+    fd = qemuOpenChrChardevUNIXSocket(chrdev);
d76c62
+    if (fd < 0) {
d76c62
+        ignore_value(qemuSecurityClearSocketLabel(driver->securityManager, vm->def));
d76c62
+        goto cleanup;
d76c62
+    }
d76c62
+    if (qemuSecurityClearSocketLabel(driver->securityManager, vm->def) < 0)
d76c62
+        goto cleanup;
d76c62
+
d76c62
+    if (qemuSecuritySetChardevLabel(driver, vm, &chr) < 0)
d76c62
+        goto cleanup;
d76c62
+
d76c62
+    ret = fd;
d76c62
+    fd = -1;
d76c62
+
d76c62
+ cleanup:
d76c62
+    virObjectUnref(chrdev);
d76c62
+    return ret;
d76c62
+}
d76c62
+
d76c62
+
d76c62
+static virCommandPtr
d76c62
+qemuVirtioFSBuildCommandLine(virQEMUDriverConfigPtr cfg,
d76c62
+                             virDomainFSDefPtr fs,
d76c62
+                             int *fd)
d76c62
+{
d76c62
+    g_autoptr(virCommand) cmd = NULL;
d76c62
+    g_auto(virBuffer) opts = VIR_BUFFER_INITIALIZER;
d76c62
+
d76c62
+    if (!(cmd = virCommandNew(fs->binary)))
d76c62
+        return NULL;
d76c62
+
d76c62
+    virCommandAddArgFormat(cmd, "--fd=%d", *fd);
d76c62
+    virCommandPassFD(cmd, *fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
d76c62
+    *fd = -1;
d76c62
+
d76c62
+    virCommandAddArg(cmd, "-o");
d76c62
+    virBufferAddLit(&opts, "source=");
d76c62
+    virQEMUBuildBufferEscapeComma(&opts, fs->src->path);
d76c62
+    if (fs->cache)
d76c62
+        virBufferAsprintf(&opts, ",cache=%s", virDomainFSCacheModeTypeToString(fs->cache));
d76c62
+
d76c62
+    if (fs->xattr == VIR_TRISTATE_SWITCH_ON)
d76c62
+        virBufferAddLit(&opts, ",xattr");
d76c62
+    else if (fs->xattr == VIR_TRISTATE_SWITCH_OFF)
d76c62
+        virBufferAddLit(&opts, ",no_xattr");
d76c62
+
d76c62
+    if (fs->flock == VIR_TRISTATE_SWITCH_ON)
d76c62
+        virBufferAddLit(&opts, ",flock");
d76c62
+    else if (fs->flock == VIR_TRISTATE_SWITCH_OFF)
d76c62
+        virBufferAddLit(&opts, ",no_flock");
d76c62
+
d76c62
+    if (fs->posix_lock == VIR_TRISTATE_SWITCH_ON)
d76c62
+        virBufferAddLit(&opts, ",posix_lock");
d76c62
+    else if (fs->posix_lock == VIR_TRISTATE_SWITCH_OFF)
d76c62
+        virBufferAddLit(&opts, ",no_posix_lock");
d76c62
+
d76c62
+    virCommandAddArgBuffer(cmd, &opts);
d76c62
+    if (cfg->virtiofsdDebug)
d76c62
+        virCommandAddArg(cmd, "-d");
d76c62
+
d76c62
+    return g_steal_pointer(&cmd);
d76c62
+}
d76c62
+
d76c62
+int
d76c62
+qemuVirtioFSStart(virLogManagerPtr logManager,
d76c62
+                  virQEMUDriverPtr driver,
d76c62
+                  virDomainObjPtr vm,
d76c62
+                  virDomainFSDefPtr fs)
d76c62
+{
d76c62
+    g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
d76c62
+    g_autoptr(virCommand) cmd = NULL;
d76c62
+    g_autofree char *socket_path = NULL;
d76c62
+    g_autofree char *pidfile = NULL;
d76c62
+    g_autofree char *logpath = NULL;
d76c62
+    pid_t pid = (pid_t) -1;
d76c62
+    VIR_AUTOCLOSE fd = -1;
d76c62
+    VIR_AUTOCLOSE logfd = -1;
d76c62
+    int ret = -1;
d76c62
+    int rc;
d76c62
+
d76c62
+    if (!virFileExists(fs->src->path)) {
d76c62
+        virReportError(VIR_ERR_INTERNAL_ERROR,
d76c62
+                       _("the virtiofs export directory '%s' does not exist"),
d76c62
+                       fs->src->path);
d76c62
+        return -1;
d76c62
+    }
d76c62
+
d76c62
+    if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias)))
d76c62
+        goto cleanup;
d76c62
+
d76c62
+    if (!(socket_path = qemuVirtioFSCreateSocketFilename(vm, fs->info.alias)))
d76c62
+        goto cleanup;
d76c62
+
d76c62
+    if ((fd = qemuVirtioFSOpenChardev(driver, vm, socket_path)) < 0)
d76c62
+        goto cleanup;
d76c62
+
d76c62
+    logpath = qemuVirtioFSCreateLogFilename(cfg, vm->def, fs->info.alias);
d76c62
+
d76c62
+    if (cfg->stdioLogD) {
d76c62
+        if ((logfd = virLogManagerDomainOpenLogFile(logManager,
d76c62
+                                                    "qemu",
d76c62
+                                                    vm->def->uuid,
d76c62
+                                                    vm->def->name,
d76c62
+                                                    logpath,
d76c62
+                                                    0,
d76c62
+                                                    NULL, NULL)) < 0)
d76c62
+            goto cleanup;
d76c62
+    } else {
d76c62
+        if ((logfd = open(logpath, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR)) < 0) {
d76c62
+            virReportSystemError(errno, _("failed to create logfile %s"),
d76c62
+                                 logpath);
d76c62
+            goto cleanup;
d76c62
+        }
d76c62
+        if (virSetCloseExec(logfd) < 0) {
d76c62
+            virReportSystemError(errno, _("failed to set close-on-exec flag on %s"),
d76c62
+                                 logpath);
d76c62
+            goto error;
d76c62
+        }
d76c62
+    }
d76c62
+
d76c62
+    if (!(cmd = qemuVirtioFSBuildCommandLine(cfg, fs, &fd)))
d76c62
+        goto cleanup;
d76c62
+
d76c62
+    /* so far only running as root is supported */
d76c62
+    virCommandSetUID(cmd, 0);
d76c62
+    virCommandSetGID(cmd, 0);
d76c62
+
d76c62
+    virCommandSetPidFile(cmd, pidfile);
d76c62
+    virCommandSetOutputFD(cmd, &logfd);
d76c62
+    virCommandSetErrorFD(cmd, &logfd);
d76c62
+    virCommandNonblockingFDs(cmd);
d76c62
+    virCommandDaemonize(cmd);
d76c62
+
d76c62
+    if (qemuExtDeviceLogCommand(driver, vm, cmd, "virtiofsd") < 0)
d76c62
+        goto cleanup;
d76c62
+
d76c62
+    rc = virCommandRun(cmd, NULL);
d76c62
+
d76c62
+    if (rc < 0) {
d76c62
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
d76c62
+                       _("Could not start 'virtiofsd'"));
d76c62
+        goto error;
d76c62
+    }
d76c62
+
d76c62
+    rc = virPidFileReadPath(pidfile, &pid;;
d76c62
+    if (rc < 0) {
d76c62
+        virReportSystemError(-rc,
d76c62
+                             _("Unable to read virtiofsd pidfile '%s'"),
d76c62
+                             pidfile);
d76c62
+        goto error;
d76c62
+    }
d76c62
+
d76c62
+    if (virProcessKill(pid, 0) != 0) {
d76c62
+        virReportSystemError(errno, "%s",
d76c62
+                             _("virtiofsd died unexpectedly"));
d76c62
+        goto error;
d76c62
+    }
d76c62
+
d76c62
+    QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock = g_steal_pointer(&socket_path);
d76c62
+    ret = 0;
d76c62
+
d76c62
+ cleanup:
d76c62
+    if (socket_path)
d76c62
+        unlink(socket_path);
d76c62
+    return ret;
d76c62
+
d76c62
+ error:
d76c62
+    if (pid != -1)
d76c62
+        virProcessKillPainfully(pid, true);
d76c62
+    if (pidfile)
d76c62
+        unlink(pidfile);
d76c62
+    goto cleanup;
d76c62
+}
d76c62
+
d76c62
+
d76c62
+void
d76c62
+qemuVirtioFSStop(virQEMUDriverPtr driver G_GNUC_UNUSED,
d76c62
+                    virDomainObjPtr vm,
d76c62
+                    virDomainFSDefPtr fs)
d76c62
+{
d76c62
+    g_autofree char *pidfile = NULL;
d76c62
+    virErrorPtr orig_err;
d76c62
+    pid_t pid = -1;
d76c62
+    int rc;
d76c62
+
d76c62
+    virErrorPreserveLast(&orig_err);
d76c62
+
d76c62
+    if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias)))
d76c62
+        goto cleanup;
d76c62
+
d76c62
+    rc = virPidFileReadPathIfAlive(pidfile, &pid, NULL);
d76c62
+    if (rc >= 0 && pid != (pid_t) -1)
d76c62
+        virProcessKillPainfully(pid, true);
d76c62
+
d76c62
+    if (unlink(pidfile) < 0 &&
d76c62
+        errno != ENOENT) {
d76c62
+        virReportSystemError(errno,
d76c62
+                             _("Unable to remove stale pidfile %s"),
d76c62
+                             pidfile);
d76c62
+    }
d76c62
+
d76c62
+    if (QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock)
d76c62
+        unlink(QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock);
d76c62
+
d76c62
+ cleanup:
d76c62
+    virErrorRestore(&orig_err);
d76c62
+}
d76c62
diff --git a/src/qemu/qemu_virtiofs.h b/src/qemu/qemu_virtiofs.h
d76c62
new file mode 100644
d76c62
index 0000000000..b2f0c57d0c
d76c62
--- /dev/null
d76c62
+++ b/src/qemu/qemu_virtiofs.h
d76c62
@@ -0,0 +1,37 @@
d76c62
+/*
d76c62
+ * qemu_virtiofs.h: virtiofs support
d76c62
+ *
d76c62
+ * This library is free software; you can redistribute it and/or
d76c62
+ * modify it under the terms of the GNU Lesser General Public
d76c62
+ * License as published by the Free Software Foundation; either
d76c62
+ * version 2.1 of the License, or (at your option) any later version.
d76c62
+ *
d76c62
+ * This library is distributed in the hope that it will be useful,
d76c62
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
d76c62
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
d76c62
+ * Lesser General Public License for more details.
d76c62
+ *
d76c62
+ * You should have received a copy of the GNU Lesser General Public
d76c62
+ * License along with this library.  If not, see
d76c62
+ * <http://www.gnu.org/licenses/>.
d76c62
+ */
d76c62
+
d76c62
+#pragma once
d76c62
+
d76c62
+
d76c62
+char *
d76c62
+qemuVirtioFSCreatePidFilename(virDomainObjPtr vm,
d76c62
+                              const char *alias);
d76c62
+char *
d76c62
+qemuVirtioFSCreateSocketFilename(virDomainObjPtr vm,
d76c62
+                                 const char *alias);
d76c62
+
d76c62
+int
d76c62
+qemuVirtioFSStart(virLogManagerPtr logManager,
d76c62
+                  virQEMUDriverPtr driver,
d76c62
+                  virDomainObjPtr vm,
d76c62
+                  virDomainFSDefPtr fs);
d76c62
+void
d76c62
+qemuVirtioFSStop(virQEMUDriverPtr driver,
d76c62
+                 virDomainObjPtr vm,
d76c62
+                 virDomainFSDefPtr fs);
d76c62
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
d76c62
index 8215935bab..a391823090 100644
d76c62
--- a/tests/qemuxml2argvtest.c
d76c62
+++ b/tests/qemuxml2argvtest.c
d76c62
@@ -496,6 +496,17 @@ testCompareXMLToArgv(const void *data)
d76c62
         }
d76c62
     }
d76c62
 
d76c62
+    for (i = 0; i < vm->def->nfss; i++) {
d76c62
+        virDomainFSDefPtr fs = vm->def->fss[i];
d76c62
+        char *s;
d76c62
+
d76c62
+        if (fs->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS)
d76c62
+            continue;
d76c62
+
d76c62
+        s = g_strdup_printf("/tmp/lib/domain--1-guest/fs%zu.vhost-fs.sock", i);
d76c62
+        QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock = s;
d76c62
+    }
d76c62
+
d76c62
     if (vm->def->vsock) {
d76c62
         virDomainVsockDefPtr vsock = vm->def->vsock;
d76c62
         qemuDomainVsockPrivatePtr vsockPriv =
d76c62
-- 
d76c62
2.25.1
d76c62