[libvirt PATCHv2 4/5] qemu: do not use deprecated options for new virtiofsd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the to-be-introduced virtiofsd capability to mark whether
new options are safe to use.

Depends on:
https://gitlab.com/virtio-fs/virtiofsd/-/merge_requests/231

https://issues.redhat.com/browse/RHEL-7108

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/qemu/qemu_virtiofs.c | 83 +++++++++++++++++++++++++++-------------
 1 file changed, 57 insertions(+), 26 deletions(-)

diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c
index aba6a19562..2271051b9a 100644
--- a/src/qemu/qemu_virtiofs.c
+++ b/src/qemu/qemu_virtiofs.c
@@ -139,36 +139,67 @@ qemuVirtioFSBuildCommandLine(virQEMUDriverConfig *cfg,
     virCommandPassFD(cmd, *fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
     *fd = -1;
 
-    virCommandAddArg(cmd, "-o");
-    virBufferAddLit(&opts, "source=");
-    virQEMUBuildBufferEscapeComma(&opts, fs->src->path);
-    if (fs->cache)
-        virBufferAsprintf(&opts, ",cache=%s", virDomainFSCacheModeTypeToString(fs->cache));
-    if (fs->sandbox)
-        virBufferAsprintf(&opts, ",sandbox=%s", virDomainFSSandboxModeTypeToString(fs->sandbox));
-
-    if (fs->xattr == VIR_TRISTATE_SWITCH_ON)
-        virBufferAddLit(&opts, ",xattr");
-    else if (fs->xattr == VIR_TRISTATE_SWITCH_OFF)
-        virBufferAddLit(&opts, ",no_xattr");
-
-    if (fs->flock == VIR_TRISTATE_SWITCH_ON)
-        virBufferAddLit(&opts, ",flock");
-    else if (fs->flock == VIR_TRISTATE_SWITCH_OFF)
-        virBufferAddLit(&opts, ",no_flock");
-
-    if (fs->posix_lock == VIR_TRISTATE_SWITCH_ON)
-        virBufferAddLit(&opts, ",posix_lock");
-    else if (fs->posix_lock == VIR_TRISTATE_SWITCH_OFF)
-        virBufferAddLit(&opts, ",no_posix_lock");
-
-    virCommandAddArgBuffer(cmd, &opts);
+    if (virBitmapIsBitSet(fs->caps, QEMU_VHOST_USER_FS_FEATURE_SEPARATE_OPTIONS)) {
+        /* Note that this option format is used by the Rust version of the daemon
+         * since v1.0.0, which is way longer than the capability existed.
+         * The -o style of options can be removed once we bump the minimal
+         * QEMU version to 8.0.0, which dropped the C virtiofsd daemon */
+        virCommandAddArg(cmd, "--shared-dir");
+        virCommandAddArg(cmd, fs->src->path);
+
+        if (fs->cache) {
+            virCommandAddArg(cmd, "--cache");
+            virCommandAddArg(cmd, virDomainFSCacheModeTypeToString(fs->cache));
+        }
+        if (fs->sandbox) {
+            virCommandAddArg(cmd, "--sandbox");
+            virCommandAddArg(cmd, virDomainFSSandboxModeTypeToString(fs->sandbox));
+        }
+
+        if (fs->xattr == VIR_TRISTATE_SWITCH_ON)
+            virCommandAddArg(cmd, "--xattr");
+
+        if (fs->posix_lock != VIR_TRISTATE_SWITCH_ABSENT ||
+            fs->flock != VIR_TRISTATE_SWITCH_ABSENT) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("locking options are not supported by this virtiofsd"));
+            return NULL;
+        }
+    } else {
+        virCommandAddArg(cmd, "-o");
+        virBufferAddLit(&opts, "source=");
+        virQEMUBuildBufferEscapeComma(&opts, fs->src->path);
+        if (fs->cache)
+            virBufferAsprintf(&opts, ",cache=%s", virDomainFSCacheModeTypeToString(fs->cache));
+        if (fs->sandbox)
+            virBufferAsprintf(&opts, ",sandbox=%s", virDomainFSSandboxModeTypeToString(fs->sandbox));
+
+        if (fs->xattr == VIR_TRISTATE_SWITCH_ON)
+            virBufferAddLit(&opts, ",xattr");
+        else if (fs->xattr == VIR_TRISTATE_SWITCH_OFF)
+            virBufferAddLit(&opts, ",no_xattr");
+
+        if (fs->flock == VIR_TRISTATE_SWITCH_ON)
+            virBufferAddLit(&opts, ",flock");
+        else if (fs->flock == VIR_TRISTATE_SWITCH_OFF)
+            virBufferAddLit(&opts, ",no_flock");
+
+        if (fs->posix_lock == VIR_TRISTATE_SWITCH_ON)
+            virBufferAddLit(&opts, ",posix_lock");
+        else if (fs->posix_lock == VIR_TRISTATE_SWITCH_OFF)
+            virBufferAddLit(&opts, ",no_posix_lock");
+
+        virCommandAddArgBuffer(cmd, &opts);
+    }
 
     if (fs->thread_pool_size >= 0)
         virCommandAddArgFormat(cmd, "--thread-pool-size=%i", fs->thread_pool_size);
 
-    if (cfg->virtiofsdDebug)
-        virCommandAddArg(cmd, "-d");
+    if (cfg->virtiofsdDebug) {
+        if (virBitmapIsBitSet(fs->caps, QEMU_VHOST_USER_FS_FEATURE_SEPARATE_OPTIONS))
+            virCommandAddArgList(cmd, "--log-level", "debug", NULL);
+        else
+            virCommandAddArg(cmd, "-d");
+    }
 
     for (i = 0; i < fs->idmap.nuidmap; i++) {
         virCommandAddArgFormat(cmd, "--uid-map=:%u:%u:%u:",
-- 
2.45.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux