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