libvirt/libvirt-qemu-do-not-use-deprecated-options-for-new-virtiofsd.patch
Jiri Denemark 37fd552490 libvirt-10.5.0-4.el10
- Synchronize with libvirt-10.5.0-4.el9 (RHEL-30177)
- virt-host-validate: Allow longer list of CPU flags
- vmx: Be even more lax when trying to comprehend serial ports
- vmx: Do not require all ID data for VMWare Distributed Switch
- tests: vhostuser: add virtiofsd json descriptor
- tests: qemuxmlconf: adjust test case to new virtiofsd
- qemu: fill capabilities for virtiofsd
- qemu: do not use deprecated options for new virtiofsd
- qemu: migration: allow migration for virtiofs
- virt-host-validate: Drop extra "PASS"
- qemu: Don't leave beingDestroyed=true on inactive domain

Related: RHEL-30177
2024-07-25 13:30:17 +02:00

129 lines
5.1 KiB
Diff

From c30b3dd904c094c478c5b362de6b3580379edd8b Mon Sep 17 00:00:00 2001
Message-ID: <c30b3dd904c094c478c5b362de6b3580379edd8b.1720800605.git.jdenemar@redhat.com>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Thu, 4 Jul 2024 15:54:29 +0200
Subject: [PATCH] qemu: do not use deprecated options for new virtiofsd
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 8dc04cafecd2432c071c73366e4c6eb3b7bff495)
https://issues.redhat.com/browse/RHEL-7108
Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
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 0df8d67b1b..0e3c7dbb58 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