diff options
author | Eric Blake <eblake@redhat.com> | 2017-04-06 20:37:09 -0500 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2017-04-28 16:02:03 +0200 |
commit | 048c5fd1bfc787adcb1b726ce997e87fe44545fd (patch) | |
tree | fad9a99219396240b4a7612ddd2ee38ff3a60b42 /tests/qemu-iotests/066 | |
parent | f59adb325618a2d2ba16aece551e7ab6acadb0ae (diff) |
qcow2: Allow discard of final unaligned cluster
As mentioned in commit 0c1bd46, we ignored requests to
discard the trailing cluster of an unaligned image. While
discard is an advisory operation from the guest standpoint,
(and we are therefore free to ignore any request), our
qcow2 implementation exploits the fact that a discarded
cluster reads back as 0. As long as we discard on cluster
boundaries, we are fine; but that means we could observe
non-zero data leaked at the tail of an unaligned image.
Enhance iotest 66 to cover this case, and fix the implementation
to honor a discard request on the final partial cluster.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-id: 20170407013709.18440-1-eblake@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/066')
-rwxr-xr-x | tests/qemu-iotests/066 | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/qemu-iotests/066 b/tests/qemu-iotests/066 index 364166d3b2..c2116a3088 100755 --- a/tests/qemu-iotests/066 +++ b/tests/qemu-iotests/066 @@ -42,16 +42,18 @@ _supported_fmt qcow2 _supported_proto generic _supported_os Linux +# Intentionally create an unaligned image IMGOPTS="compat=1.1" -IMG_SIZE=64M +IMG_SIZE=$((64 * 1024 * 1024 + 512)) echo -echo "=== Testing snapshotting an image with zero clusters ===" +echo "=== Testing cluster discards ===" echo _make_test_img $IMG_SIZE -# Write some normal clusters, zero them (creating preallocated zero clusters) -# and discard those -$QEMU_IO -c "write 0 256k" -c "write -z 0 256k" -c "discard 0 256k" "$TEST_IMG" \ +# Write some normal clusters, zero some of them (creating preallocated +# zero clusters) and discard everything. Everything should now read as 0. +$QEMU_IO -c "write 0 256k" -c "write -z 0 256k" -c "write 64M 512" \ + -c "discard 0 $IMG_SIZE" -c "read -P 0 0 $IMG_SIZE" "$TEST_IMG" \ | _filter_qemu_io # Check the image (there shouldn't be any leaks) _check_test_img |