On 05/03/2017 06:11 PM, Max Reitz wrote: > 066 was supposed to be a test "for discarding preallocated zero > clusters", but it did so incompletely: While it did check the image > file's integrity after the operation, it did not confirm that the > clusters are indeed freed. This patch adds this test. > > In addition, new cases for writing to preallocated zero clusters are > added. > > Signed-off-by: Max Reitz <mre...@redhat.com> > --- > tests/qemu-iotests/066 | 128 > ++++++++++++++++++++++++++++++++++++++++++++- > tests/qemu-iotests/066.out | 46 ++++++++++++++++ > 2 files changed, 173 insertions(+), 1 deletion(-) > > @@ -55,8 +55,134 @@ _make_test_img $IMG_SIZE > $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 > +# Map the image (we want all clusters to be gone) > +$QEMU_IMG map "$TEST_IMG"
The human-readable qemu-img map ignores allocated but reads-as-zeros clusters. Maybe it shouldn't, but only --output=json does the right thing (actually, even then it doesn't, without my pending patch that I am rebasing on top of your series [1]). But I think this is sufficient for test 66, since I'm adding more tests in my pending series. [1] https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg05224.html > +# Create three normal clusters > +$QEMU_IO -c 'write -P 42 0 192k' "$TEST_IMG" | _filter_qemu_io > +orig_map=$($QEMU_IMG map --output=json "$TEST_IMG") > + > +# Make the middle cluster a preallocated zero cluster > +$QEMU_IO -c 'write -z 64k 64k' "$TEST_IMG" | _filter_qemu_io > + > +# Try to overwrite everything: This should reuse the whole range. To test > that > +# this only issues a single continuous write request, use blkdebug. > +$QEMU_IO -c 'write -P 42 0 192k' \ > + "json:{ > + 'driver': '$IMGFMT', > + 'file': { > + 'driver': 'blkdebug', > + 'image.filename': '$TEST_IMG', > + 'set-state': [{ > + 'event': 'write_aio', > + 'new_state': 2 > + }], > + 'inject-error': [{ > + 'event': 'write_aio', > + 'state': 2 > + }] > + } > + }" \ > + | _filter_qemu_io blkdebug is cool! Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature