Format the 'vhost-user-fs' device on the QEMU command line.
---
src/qemu/qemu_command.c | 49 +++++++++++++++++--
...vhost-user-fs-fd-memory.x86_64-latest.args | 3 ++
2 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d953e3626a..a3008e47ee 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2593,6 +2593,46 @@ qemuBuildDisksCommandLine(virCommandPtr cmd,
}
+static int
+qemuBuildVHostUserFsCommandLine(virCommandPtr cmd,
+ virDomainFSDef *fs,
+ const virDomainDef *def G_GNUC_UNUSED,
+ qemuDomainObjPrivatePtr priv)
+{
+ /* TODO: reject non-passthrough accessmode */
+ g_autofree char *chardev_alias = NULL;
+ g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
+ const char *tag = fs->dst;
+
+ chardev_alias = g_strdup_printf("chr-vu-%s", fs->info.alias);
+
+ virCommandAddArg(cmd, "-chardev");
+ virBufferAddLit(&opt, "socket");
+ virBufferAsprintf(&opt, ",id=%s", chardev_alias);
+ virBufferEscapeString(&opt, ",path=%s", fs->vhost_user_fs_path);
+ virCommandAddArg(cmd, virBufferContentAndReset(&opt));
+
+ virCommandAddArg(cmd, "-device");
+
+ if (qemuBuildVirtioDevStr(&opt, "vhost-user-fs", priv->qemuCaps,
+ VIR_DOMAIN_DEVICE_FS, fs) < 0)
+ return -1;
+
+ virBufferAsprintf(&opt, ",chardev=%s", chardev_alias);
+ /* TODO: do not hardcode this */
+ virBufferAsprintf(&opt, ",queue-size=%u", 1024);
+ virBufferEscapeString(&opt, ",tag=%s,cache-size=2G", tag);
+ if (qemuBuildVirtioOptionsStr(&opt, fs->virtio, priv->qemuCaps) < 0)
+ return -1;
+
+ if (qemuBuildDeviceAddressStr(&opt, def, &fs->info, priv->qemuCaps)
< 0)
+ return -1;
+
+ virCommandAddArg(cmd, virBufferContentAndReset(&opt));
+ return 0;
+}
+
+
static char *
qemuBuildFSStr(virDomainFSDefPtr fs)
{
@@ -2685,7 +2725,7 @@ static int
qemuBuildFilesystemCommandLine(virCommandPtr cmd,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps,
- qemuDomainObjPrivatePtr priv G_GNUC_UNUSED)
+ qemuDomainObjPrivatePtr priv)
{
size_t i;
@@ -2699,8 +2739,11 @@ qemuBuildFilesystemCommandLine(virCommandPtr cmd,
return -1;
break;
case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIO_FS:
- /* TODO: vhost-user-fs-pci */
- return 0;
+ /* vhost-user-fs-pci */
+ if (qemuBuildVHostUserFsCommandLine(cmd, def->fss[i], def, priv) < 0)
+ return -1;
+ break;
+
case VIR_DOMAIN_FS_DRIVER_TYPE_LOOP:
case VIR_DOMAIN_FS_DRIVER_TYPE_NBD:
case VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP:
diff --git a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args
b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args
index 39c7dbf6d8..a63d6b6dcc 100644
--- a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args
@@ -30,6 +30,9 @@ size=15032385536 \
-no-shutdown \
-no-acpi \
-boot strict=on \
+-chardev socket,id=chr-vu-fs0,path=/tmp/lib/domain--1-guest/fs0.vhost-fs.sock \
+-device vhost-user-fs-pci,chardev=chr-vu-fs0,queue-size=1024,tag=/path,\
+cache-size=2G,bus=pci.0,addr=0x2 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny \
-msg timestamp=on
--
2.21.0