qcow2: Expose bitmaps' size during measure
commita19ecd9b0a5a7d5cc09ff108fe1547c36bcc87bd
authorEric Blake <eblake@redhat.com>
Wed, 13 May 2020 01:16:46 +0000 (12 20:16 -0500)
committerEric Blake <eblake@redhat.com>
Thu, 21 May 2020 19:12:39 +0000 (21 14:12 -0500)
tree3ecf7454117107b9b91e07f3b1689228dfbeb634
parent09517848576abd4be07d0d2a04f528a824f328f1
qcow2: Expose bitmaps' size during measure

It's useful to know how much space can be occupied by qcow2 persistent
bitmaps, even though such metadata is unrelated to the guest-visible
data.  Report this value as an additional QMP field, present when
measuring an existing image and output format that both support
bitmaps.  Update iotest 178 and 190 to updated output, as well as new
coverage in 190 demonstrating non-zero values made possible with the
recently-added qemu-img bitmap command (see 3b51ab4b).

The new 'bitmaps size:' field is displayed automatically as part of
'qemu-img measure' any time it is present in QMP (that is, any time
both the source image being measured and destination format support
bitmaps, even if the measurement is 0 because there are no bitmaps
present).  If the field is absent, it means that no bitmaps can be
copied (source, destination, or both lack bitmaps, including when
measuring based on size rather than on a source image).  This behavior
is compatible with an upcoming patch adding 'qemu-img convert
--bitmaps': that command will fail in the same situations where this
patch omits the field.

The addition of a new field demonstrates why we should always
zero-initialize qapi C structs; while the qcow2 driver still fully
populates all fields, the raw and crypto drivers had to be tweaked to
avoid uninitialized data.

See also: https://bugzilla.redhat.com/1779904

Reported-by: Nir Soffer <nsoffer@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
block/crypto.c
block/qcow2-bitmap.c
block/qcow2.c
block/qcow2.h
block/raw-format.c
docs/tools/qemu-img.rst
qapi/block-core.json
qemu-img.c
tests/qemu-iotests/178.out.qcow2
tests/qemu-iotests/190
tests/qemu-iotests/190.out