qemu-img: Add --skip-broken-bitmaps for 'convert --bitmaps'
commit955171e4417bf39edb5503e694501e082a757731
authorEric Blake <eblake@redhat.com>
Wed, 21 Jul 2021 15:53:48 +0000 (21 10:53 -0500)
committerEric Blake <eblake@redhat.com>
Wed, 21 Jul 2021 19:14:41 +0000 (21 14:14 -0500)
tree89e724bf1cd142b1786fcc85675077c3138e4c23
parent74a4320f30632fa539507861b3835698282e462e
qemu-img: Add --skip-broken-bitmaps for 'convert --bitmaps'

The point of 'qemu-img convert --bitmaps' is to be a convenience for
actions that are already possible through a string of smaller
'qemu-img bitmap' sub-commands.  One situation not accounted for
already is that if a source image contains an inconsistent bitmap (for
example, because a qemu process died abruptly before flushing bitmap
state), the user MUST delete those inconsistent bitmaps before
anything else useful can be done with the image.

We don't want to delete inconsistent bitmaps by default: although a
corrupt bitmap is only a loss of optimization rather than a corruption
of user-visible data, it is still nice to require the user to opt in
to the fact that they are aware of the loss of the bitmap.  Still,
requiring the user to check 'qemu-img info' to see whether bitmaps are
consistent, then use 'qemu-img bitmap --remove' to remove offenders,
all before using 'qemu-img convert', is a lot more work than just
adding a knob 'qemu-img convert --bitmaps --skip-broken-bitmaps' which
opts in to skipping the broken bitmaps.

After testing the new option, also demonstrate the way to manually fix
things (either deleting bad bitmaps, or re-creating them as empty) so
that it is possible to convert without the option.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1946084
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210709153951.2801666-4-eblake@redhat.com>
[eblake: warning message tweak, test enhancements]
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
docs/tools/qemu-img.rst
qemu-img.c
tests/qemu-iotests/tests/qemu-img-bitmaps
tests/qemu-iotests/tests/qemu-img-bitmaps.out