mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
iotests/308: Add test for 'write -zu'
Try writing zeroes to a FUSE export while allowing the area to be unmapped; block/file-posix.c generally implements writing zeroes with BDRV_REQ_MAY_UNMAP ('write -zu') by calling fallocate(PUNCH_HOLE). This used to lead to a blk_pdiscard() in the FUSE export, which may or may not lead to the area being zeroed. HEAD^ fixed this to use blk_pwrite_zeroes() instead (again with BDRV_REQ_MAY_UNMAP), so verify that running `qemu-io 'write -zu'` on a FUSE exports always results in zeroes being written. Signed-off-by: Hanna Czenczek <hreitz@redhat.com> Message-Id: <20230227104725.33511-3-hreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
1703eb1c27
commit
27e0d8b508
|
@ -370,6 +370,49 @@ echo
|
|||
echo '=== Compare copy with original ==='
|
||||
|
||||
$QEMU_IMG compare -f raw -F $IMGFMT "$COPIED_IMG" "$TEST_IMG"
|
||||
_cleanup_test_img
|
||||
|
||||
echo
|
||||
echo '=== Writing zeroes while unmapping ==='
|
||||
# Regression test for https://gitlab.com/qemu-project/qemu/-/issues/1507
|
||||
_make_test_img 64M
|
||||
$QEMU_IO -c 'write -s /dev/urandom 0 64M' "$TEST_IMG" | _filter_qemu_io
|
||||
|
||||
_launch_qemu
|
||||
_send_qemu_cmd $QEMU_HANDLE \
|
||||
"{'execute': 'qmp_capabilities'}" \
|
||||
'return'
|
||||
|
||||
_send_qemu_cmd $QEMU_HANDLE \
|
||||
"{'execute': 'blockdev-add',
|
||||
'arguments': {
|
||||
'driver': '$IMGFMT',
|
||||
'node-name': 'node-format',
|
||||
'file': {
|
||||
'driver': 'file',
|
||||
'filename': '$TEST_IMG'
|
||||
}
|
||||
} }" \
|
||||
'return'
|
||||
|
||||
fuse_export_add 'export' "'mountpoint': '$EXT_MP', 'writable': true"
|
||||
|
||||
# Try writing zeroes by unmapping
|
||||
$QEMU_IO -f raw -c 'write -zu 0 64M' "$EXT_MP" | _filter_qemu_io
|
||||
|
||||
# Check the result
|
||||
$QEMU_IO -f raw -c 'read -P 0 0 64M' "$EXT_MP" | _filter_qemu_io
|
||||
|
||||
_send_qemu_cmd $QEMU_HANDLE \
|
||||
"{'execute': 'quit'}" \
|
||||
'return'
|
||||
|
||||
wait=yes _cleanup_qemu
|
||||
|
||||
# Check the original image
|
||||
$QEMU_IO -c 'read -P 0 0 64M' "$TEST_IMG" | _filter_qemu_io
|
||||
|
||||
_cleanup_test_img
|
||||
|
||||
# success, all done
|
||||
echo "*** done"
|
||||
|
|
|
@ -171,4 +171,39 @@ OK: Post-truncate image size is as expected
|
|||
|
||||
=== Compare copy with original ===
|
||||
Images are identical.
|
||||
|
||||
=== Writing zeroes while unmapping ===
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
||||
wrote 67108864/67108864 bytes at offset 0
|
||||
64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
{'execute': 'qmp_capabilities'}
|
||||
{"return": {}}
|
||||
{'execute': 'blockdev-add',
|
||||
'arguments': {
|
||||
'driver': 'IMGFMT',
|
||||
'node-name': 'node-format',
|
||||
'file': {
|
||||
'driver': 'file',
|
||||
'filename': 'TEST_DIR/t.IMGFMT'
|
||||
}
|
||||
} }
|
||||
{"return": {}}
|
||||
{'execute': 'block-export-add',
|
||||
'arguments': {
|
||||
'type': 'fuse',
|
||||
'id': 'export',
|
||||
'node-name': 'node-format',
|
||||
'mountpoint': 'TEST_DIR/t.IMGFMT.fuse', 'writable': true
|
||||
} }
|
||||
{"return": {}}
|
||||
wrote 67108864/67108864 bytes at offset 0
|
||||
64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
read 67108864/67108864 bytes at offset 0
|
||||
64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
{'execute': 'quit'}
|
||||
{"return": {}}
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "export"}}
|
||||
read 67108864/67108864 bytes at offset 0
|
||||
64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
*** done
|
||||
|
|
Loading…
Reference in a new issue