qemu/tests
Nir Soffer d05ae948cc Consider discard option when writing zeros
When opening an image with discard=off, we punch hole in the image when
writing zeroes, making the image sparse. This breaks users that want to
ensure that writes cannot fail with ENOSPACE by using fully allocated
images[1].

bdrv_co_pwrite_zeroes() correctly disables BDRV_REQ_MAY_UNMAP if we
opened the child without discard=unmap or discard=on. But we don't go
through this function when accessing the top node. Move the check down
to bdrv_co_do_pwrite_zeroes() which seems to be used in all code paths.

This change implements the documented behavior, punching holes only when
opening the image with discard=on or discard=unmap. This may not be the
best default but can improve it later.

The test depends on a file system supporting discard, deallocating the
entire file when punching hole with the length of the entire file.
Tested with xfs, ext4, and tmpfs.

[1] https://lists.nongnu.org/archive/html/qemu-discuss/2024-06/msg00003.html

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Message-id: 20240628202058.1964986-3-nsoffer@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2024-07-11 11:06:36 +02:00
..
avocado machine_aspeed.py: update to test network for AST2700 2024-07-09 08:05:44 +02:00
bench tests/bench: Add bufferiszero-bench 2024-05-03 08:03:35 -07:00
data tests/data/acpi/rebuild-expected-aml.sh: Add RISC-V 2024-07-03 18:14:07 -04:00
decode tests/: spelling fixes 2023-09-08 13:08:52 +03:00
docker tests/docker: Specify --userns keep-id for Podman 2024-07-05 12:33:41 +01:00
fp tests/fp: Bump fp-test-mulAdd test timeout to 3 minutes 2024-01-12 13:23:48 +00:00
guest-debug tests: Gently exit from GDB when tests complete 2024-05-17 16:49:04 +02:00
image-fuzzer
include
keys
lcitool tests/lcitool: fix debian-i686-cross toolchain prefix 2024-07-05 12:33:32 +01:00
migration tests/qtest/migration-test: Use custom asm bios for ppc64 2024-06-14 14:01:23 -03:00
multiboot
perf/block/qcow2
plugin test/plugins: preserve the instruction record over translations 2024-07-05 12:34:41 +01:00
qapi-schema qapi/parser: don't parse rST markup as section headers 2024-07-06 08:58:24 +02:00
qemu-iotests Consider discard option when writing zeros 2024-07-11 11:06:36 +02:00
qtest tests/qtest/npcm7xx_sdhci: Access the card using its published address 2024-07-05 23:50:12 +02:00
rocker
tcg tests/tcg/aarch64: Add MTE gdbstub tests 2024-07-05 12:35:36 +01:00
tsan block: remove AioContext locking 2023-12-21 22:49:27 +01:00
uefi-test-tools tests/data/uefi-boot-images: Add RISC-V ISO image 2024-07-03 18:14:06 -04:00
unit * Fix loongarch64 avocado test 2024-06-13 07:51:58 -07:00
vm tests/vm: remove plain centos image 2024-06-06 10:25:51 +01:00
vmstate-static-checker-data
dbus-vmstate-daemon.sh
Makefile.include meson: Drop the .fa library suffix 2024-07-03 18:41:26 +02:00
meson.build tests: only build plugins if TCG is enabled 2024-04-18 11:17:27 +02:00
test-qht-par.c
vhost-user-bridge.c error handling: Use RETRY_ON_EINTR() macro where applicable 2023-01-09 13:50:47 +01:00