qemu-img: Fail fast on convert --bitmaps with inconsistent bitmap
authorEric Blake <eblake@redhat.com>
Fri, 9 Jul 2021 15:39:50 +0000 (10:39 -0500)
committerEric Blake <eblake@redhat.com>
Wed, 21 Jul 2021 19:14:41 +0000 (14:14 -0500)
commit74a4320f30632fa539507861b3835698282e462e
tree726ed608ae7eb0881adc5ab0cae3d51e38ac53ec
parent94075c28eea0755173939dfaf1eae688b224a74e
qemu-img: Fail fast on convert --bitmaps with inconsistent bitmap

Waiting until the end of the convert operation (a potentially
time-consuming task) to finally detect that we can't copy a bitmap is
bad, comparing to failing fast up front.  Furthermore, this prevents
us from leaving a file behind with a bitmap that is not marked as
inconsistent even though it does not have sane contents.

This fixes the problems exposed in the previous patch to the iotest:
it adds a fast failure up front, and even if we don't fail early, it
ensures that any bitmap we add but do not properly populate is removed
again rather than left behind incomplete.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210709153951.2801666-3-eblake@redhat.com>
[eblake: add a hint to the warning message, simplify name computation]
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
qemu-img.c
tests/qemu-iotests/tests/qemu-img-bitmaps
tests/qemu-iotests/tests/qemu-img-bitmaps.out