iotests/108: Test new refcount rebuild algorithm
authorHanna Reitz <hreitz@redhat.com>
Tue, 5 Apr 2022 13:46:51 +0000 (15:46 +0200)
committerHanna Reitz <hreitz@redhat.com>
Wed, 20 Apr 2022 10:09:17 +0000 (12:09 +0200)
commit9ffd6d646d1d5ee9087a8cbf0b7d2f96c5656162
tree619948f3a7366fc81a137c2b502961979640d50e
parenta8c07ec287554dcefd33733f0e5888a281ddc95e
iotests/108: Test new refcount rebuild algorithm

One clear problem with how qcow2's refcount structure rebuild algorithm
used to be before "qcow2: Improve refcount structure rebuilding" was
that it is prone to failure for qcow2 images on block devices: There is
generally unused space after the actual image, and if that exceeds what
one refblock covers, the old algorithm would invariably write the
reftable past the block device's end, which cannot work.  The new
algorithm does not have this problem.

Test it with three tests:
(1) Create an image with more empty space at the end than what one
    refblock covers, see whether rebuilding the refcount structures
    results in a change in the image file length.  (It should not.)

(2) Leave precisely enough space somewhere at the beginning of the image
    for the new reftable (and the refblock for that place), see whether
    the new algorithm puts the reftable there.  (It should.)

(3) Test the original problem: Create (something like) a block device
    with a fixed size, then create a qcow2 image in there, write some
    data, and then have qemu-img check rebuild the refcount structures.
    Before HEAD^, the reftable would have been written past the image
    file end, i.e. outside of what the block device provides, which
    cannot work.  HEAD^ should have fixed that.
    ("Something like a block device" means a loop device if we can use
    one ("sudo -n losetup" works), or a FUSE block export with
    growable=false otherwise.)

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220405134652.19278-3-hreitz@redhat.com>
tests/qemu-iotests/108
tests/qemu-iotests/108.out