On Wed, Oct 28, 2026 at 06:10:57PM +0100, Kevin Wolf wrote:
> Add a test for the accept-read-only-device option of host_device.
>
> Signed-off-by: Kevin Wolf <[email protected]>
> ---
> tests/qemu-iotests/tests/loop-accept-ro-dev | 87 +++++++++++++++++++
> .../qemu-iotests/tests/loop-accept-ro-dev.out | 19 ++++
> 2 files changed, 106 insertions(+)
> create mode 100755 tests/qemu-iotests/tests/loop-accept-ro-dev
> create mode 100644 tests/qemu-iotests/tests/loop-accept-ro-dev.out
>
> +
> +run_qemu()
> +{
> + echo -e '{"execute":"qmp_capabilities"}\n{"execute":"quit"}' |
'printf %s' is slightly more portable than 'echo -e'; even though this
script uses /bin/bash, you can use 'shopt -s xpg_echo' to break the
latter. On the other hand, this is copy-paste from other tests, so not
a showstopper.
> + do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp |
> + _filter_generated_node_ids | _filter_imgfmt |
> + _filter_actual_image_size | _filter_img_info
> +}
> +
> +if ! sudo -n losetup &>/dev/null; then
> + _notrun "sudo losetup not available"
> +fi
Huh - we seem to have several outstanding patches related to probing
whether losetup is usable:
https://lists.nongnu.org/archive/html/qemu-devel/2026-10/msg02963.html
https://lists.nongnu.org/archive/html/qemu-devel/2026-10/msg01918.html
Is this a common enough pattern in our qemu-iotests that we should
factor it out?
> +++ b/tests/qemu-iotests/tests/loop-accept-ro-dev.out
> @@ -0,0 +1,19 @@
> +QA output created by loop-accept-ro-dev
> +
> +=== Start QEMU on a loop device after blockdev --setro ===
> +
> +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
> +Testing: -blockdev host_device,node-name=disk,filename=/dev/loop1 -device
> virtio-blk,drive=disk
> +QEMU_PROG: -blockdev host_device,node-name=disk,filename=/dev/loop1: The
> device is not writable: Permission denied
> +
> +Testing: -blockdev
> host_device,node-name=disk,filename=/dev/loop1,accept-read-only-device=off
> -device virtio-blk,drive=disk
/dev/loop1 might already be busy, at which point losetup will pick
/dev/loop2 or similar. This output needs to be filtered.
The rest of the test looks okay.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization: qemu.org | libguestfs.org