On Thu, Feb 20, 2020 at 15:32:51 +0100, Ján Tomko wrote:
Format the 'vhost-user-fs' device on the QEMU command line.
This device provides shared file system access using the FUSE protocol
carried over virtio.
The actual file server is implemented in an external vhost-user-fs device
backend process.
https://bugzilla.redhat.com/show_bug.cgi?id=1694166
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/qemu/qemu_command.c | 45 +++++++++++++++++-
...vhost-user-fs-fd-memory.x86_64-latest.args | 39 +++++++++++++++
...vhost-user-fs-hugepages.x86_64-latest.args | 47 +++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
4 files changed, 132 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9fcd06f8c3..272a0b8d44 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2574,6 +2574,45 @@ qemuBuildDisksCommandLine(virCommandPtr cmd,
}
+static int
+qemuBuildVHostUserFsCommandLine(virCommandPtr cmd,
+ virDomainFSDef *fs,
+ const virDomainDef *def,
+ qemuDomainObjPrivatePtr priv)
+{
+ g_autofree char *chardev_alias = NULL;
+ g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
+
+ chardev_alias = g_strdup_printf("chr-vu-%s", fs->info.alias);
Neither this function nor any other place actually checks that qemu
supports QEMU_CAPS_DEVICE_VHOST_USER_FS. Actually the capability is only
ever mentioned in qemu_capabilities.(c|h).
+ virCommandAddArg(cmd, "-chardev");
+ virBufferAddLit(&opt, "socket");
+ virBufferAsprintf(&opt, ",id=%s", chardev_alias);
+ virBufferEscapeString(&opt, ",path=%s",
QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock);
This function is for escaping the string for XML use not shell use.
+ virCommandAddArg(cmd, virBufferContentAndReset(&opt));
virCommandAddArgBuffer
+
+ 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);
+ if (fs->queue_size)
+ virBufferAsprintf(&opt, ",queue-size=%llu", fs->queue_size);
+ virBufferAddLit(&opt, ",tag=");
+ virQEMUBuildBufferEscapeComma(&opt, fs->dst);
This one is correct ;)
> + 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));
virCommandAddArgBuffer
+ return 0;
+}
+
+