From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org
Subject: [PULL 7/8] iotests: test shared mmap for fuse export
Date: Mon, 8 Jun 2026 18:52:06 +0200 [thread overview]
Message-ID: <20260608165207.307488-8-kwolf@redhat.com> (raw)
In-Reply-To: <20260608165207.307488-1-kwolf@redhat.com>
From: Fiona Ebner <f.ebner@proxmox.com>
This test would have worked before commit 8599559580 ("fuse: Set
direct_io and parallel_direct_writes") and is working again since
commit HEAD~1 ("block/export/fuse: set FUSE_DIRECT_IO_ALLOW_MMAP flag
to fix regression").
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Message-ID: <20260506145424.10249-4-f.ebner@proxmox.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/qemu-iotests/tests/fuse-mmap-shared | 103 ++++++++++++++++++
tests/qemu-iotests/tests/fuse-mmap-shared.out | 5 +
2 files changed, 108 insertions(+)
create mode 100755 tests/qemu-iotests/tests/fuse-mmap-shared
create mode 100644 tests/qemu-iotests/tests/fuse-mmap-shared.out
diff --git a/tests/qemu-iotests/tests/fuse-mmap-shared b/tests/qemu-iotests/tests/fuse-mmap-shared
new file mode 100755
index 00000000000..a0a10cea6ac
--- /dev/null
+++ b/tests/qemu-iotests/tests/fuse-mmap-shared
@@ -0,0 +1,103 @@
+#!/usr/bin/env python3
+# group: rw
+#
+# Test that a FUSE export can be mmap()-ed with MAP_SHARED
+#
+# Copyright (C) 2026 Proxmox Server Solutions GmbH
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os
+import itertools
+import mmap
+from mmap import MAP_SHARED
+from pathlib import Path
+
+import iotests
+from iotests import qemu_img, qemu_io, QemuStorageDaemon
+
+def test_fuse_support(mount_point):
+ test_qsd = QemuStorageDaemon('--blockdev', 'null-co,node-name=node0',
+ qmp=True)
+ res = test_qsd.qmp('block-export-add', {
+ 'id': 'exp0',
+ 'type': 'fuse',
+ 'node-name': 'node0',
+ 'mountpoint': mount_point,
+ 'allow-other': 'off'
+ })
+ test_qsd.stop()
+ if 'error' in res:
+ assert (res['error']['desc'] ==
+ "Parameter 'type' does not accept value 'fuse'")
+ iotests.notrun('No FUSE support')
+
+# Shared mmap when using direct IO is only supported for Linux kernels >= 6.6
+# with commit e78662e818f94 ("fuse: add a new fuse init flag to relax
+# estrictions in no cache mode").
+def test_linux_kernel_support():
+ [major, minor] = map(int, os.uname().release.split('.')[:2])
+ if major < 6 or (major == 6 and minor < 6):
+ iotests.notrun('No kernel support for shared mmap with direct IO')
+
+image_size = 1 * 1024 * 1024
+image = os.path.join(iotests.test_dir, 'image.' + iotests.imgfmt)
+fuse_mount_point = os.path.join(iotests.test_dir, 'export.fuse')
+Path(fuse_mount_point).touch()
+
+test_fuse_support(fuse_mount_point)
+test_linux_kernel_support()
+
+class TestMmapShared(iotests.QMPTestCase):
+
+ def setUp(self):
+ qemu_img('create', '-f', iotests.imgfmt, image, str(image_size))
+ qemu_io(image, '-c', f'write -P 23 0 {image_size}')
+
+ self.qsd = QemuStorageDaemon(qmp=True)
+
+ self.qsd.cmd('blockdev-add', {
+ 'node-name': 'node0',
+ 'driver': iotests.imgfmt,
+ 'file': {
+ 'driver': 'file',
+ 'filename': image
+ }
+ })
+
+ self.qsd.cmd('block-export-add', {
+ 'id': 'exp0',
+ 'type': 'fuse',
+ 'node-name': 'node0',
+ 'mountpoint': fuse_mount_point,
+ 'writable': True,
+ 'allow-other': 'off'
+ })
+
+ def tearDown(self):
+ self.stop_qsd()
+ os.remove(image)
+ os.remove(fuse_mount_point)
+
+ def stop_qsd(self):
+ if self.qsd:
+ self.qsd.stop()
+ self.qsd = None
+
+ def test_mmap_shared(self):
+ with open(fuse_mount_point, 'r+b') as file:
+ with mmap.mmap(file.fileno(), image_size, flags=MAP_SHARED) as mm:
+ buf = bytearray(image_size)
+ buf[:] = itertools.repeat(23, image_size)
+ assert mm.read(image_size) == buf
+ buf[:] = itertools.repeat(42, image_size)
+ mm.seek(0)
+ mm.write(buf)
+ mm.flush()
+ self.stop_qsd()
+ qemu_io(image, '-c', f'read -P 42 0 {image_size}')
+
+if __name__ == '__main__':
+ iotests.main(supported_fmts=['generic'],
+ supported_protocols=['file'],
+ supported_platforms=['linux'])
diff --git a/tests/qemu-iotests/tests/fuse-mmap-shared.out b/tests/qemu-iotests/tests/fuse-mmap-shared.out
new file mode 100644
index 00000000000..ae1213e6f86
--- /dev/null
+++ b/tests/qemu-iotests/tests/fuse-mmap-shared.out
@@ -0,0 +1,5 @@
+.
+----------------------------------------------------------------------
+Ran 1 tests
+
+OK
--
2.54.0
next prev parent reply other threads:[~2026-06-08 16:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 16:51 [PULL 0/8] Block layer patches Kevin Wolf
2026-06-08 16:52 ` [PULL 1/8] virtio-blk: add missing VIRTIO_BLK_T_SCSI_CMD size check (CVE-2026-48914) Kevin Wolf
2026-06-08 16:52 ` [PULL 2/8] qemu-img: add sub-command --remove-all to 'qemu-img bitmap' Kevin Wolf
2026-06-08 16:52 ` [PULL 3/8] iotests/136: Test stats-intervals with -blockdev/-device Kevin Wolf
2026-06-08 16:52 ` [PULL 4/8] qcow2: Fix data loss on zero write with detect-zeroes=unmap Kevin Wolf
2026-06-08 16:52 ` [PULL 5/8] block/export/fuse: use struct fuse_init_in Kevin Wolf
2026-06-08 16:52 ` [PULL 6/8] block/export/fuse: set FUSE_DIRECT_IO_ALLOW_MMAP flag to fix regression Kevin Wolf
2026-06-08 16:52 ` Kevin Wolf [this message]
2026-06-08 16:52 ` [PULL 8/8] qed: Don't try to flush during incoming migration Kevin Wolf
2026-06-09 17:44 ` [PULL 0/8] Block layer patches Stefan Hajnoczi
2026-06-10 10:15 ` Kevin Wolf
2026-06-10 10:18 ` Fiona Ebner
2026-06-10 11:17 ` Daniel P. Berrangé
2026-06-10 11:39 ` Kevin Wolf
2026-06-10 11:48 ` Daniel P. Berrangé
2026-06-10 12:21 ` Kevin Wolf
2026-06-10 12:39 ` Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260608165207.307488-8-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.