From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-block@nongnu.org
Subject: Re: [PATCH v2 6/6] iotests: Add test 291 to for qemu-img bitmap coverage
Date: Tue, 5 May 2020 16:22:54 -0500 [thread overview]
Message-ID: <1b6cb574-a15b-e79d-53d5-1d8ea90e0d96@redhat.com> (raw)
In-Reply-To: <7fb923a4-0ea8-c29b-2b05-86c4336c1286@redhat.com>
On 5/4/20 8:05 AM, Max Reitz wrote:
> On 21.04.20 23:20, Eric Blake wrote:
>> Add a new test covering the 'qemu-img bitmap' subcommand, as well as
>> 'qemu-img convert --bitmaps', both added in recent patches.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> +echo
>> +echo "=== Bitmap preservation not possible to non-qcow2 ==="
>> +echo
>> +
>> +mv "$TEST_IMG" "$TEST_IMG.orig"
>
> “mv” doesn’t work images with external data files.
>
> (ORIG_IMG=$TEST_IMG; TEST_IMG="$TEST_IMG".orig should work)
Good idea.
>
>> +$QEMU_IMG convert --bitmaps -O raw "$TEST_IMG.orig" "$TEST_IMG"
>> +
>> +echo
>> +echo "=== Convert with bitmap preservation ==="
>> +echo
>> +
>> +# Only bitmaps from the active layer are copied
>
> That’s kind of obvious when you think about (whenever an image is
> attached to a VM, only the active layer’s bitmaps are visible, not those
> from the backing chain), but maybe this should be noted in the
> documentation?
As part of integrating bitmaps with external snapshots, libvirt actually
depends on being able to see bitmaps from the backing chain - but as
bitmaps are always referenced as a 'node name, bitmap name' tuple, this
is indeed doable.
>
>> +$QEMU_IMG convert --bitmaps -O qcow2 "$TEST_IMG.orig" "$TEST_IMG"
>> +$QEMU_IMG info "$TEST_IMG" | _filter_img_info --format-specific
>> +# But we can also merge in bitmaps from other layers
>> +$QEMU_IMG bitmap --add --disabled -f $IMGFMT "$TEST_IMG" b0
>> +$QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG" tmp
>> +$QEMU_IMG bitmap --merge b0 -b "$TEST_IMG.base" -F $IMGFMT "$TEST_IMG" tmp
>> +$QEMU_IMG bitmap --merge tmp "$TEST_IMG" b0
>> +$QEMU_IMG bitmap --remove -f $IMGFMT "$TEST_IMG" tmp
>
> Why do we need tmp here? Can’t we just merge base’s b0 directly into
> $TEST_IMG’s b0?
Yes, we could. But then I wouldn't cover as many bitmap subcommands.
Adding a comment about why the example is contrived (for maximal
coverage) is a good idea.
>> +=== Check bitmap contents ===
>> +
>> +[{ "start": 0, "length": 3145728, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
>> +{ "start": 3145728, "length": 1048576, "depth": 0, "zero": false, "data": false},
>> +{ "start": 4194304, "length": 6291456, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
>> +[{ "start": 0, "length": 1048576, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
>> +{ "start": 1048576, "length": 1048576, "depth": 0, "zero": false, "data": false},
>> +{ "start": 2097152, "length": 8388608, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
>> +[{ "start": 0, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
>> +{ "start": 2097152, "length": 1048576, "depth": 0, "zero": false, "data": false},
>> +{ "start": 3145728, "length": 7340032, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
>
> Am I looking at this wrong or does the bitmap data seem to be inverted?
> Everywhere where I’d expect the bitmaps to be cleared, this map reports
> data=true, whereas where I’d expect them to be set, it reports data=false.
>
> I suppose that’s intentional, but can you explain this behavior to me?
This is an artifact of how x-dirty-bitmap works (it has the x- prefix
because it is a hack, but we don't have anything better for reading out
bitmap contents). The NBD spec returns block status as a 32-bit value
for a 'metadata context'; normally, we use context 'base:allocation'
context where bit 0 is set for holes or clear for allocated, and bit 1
is set for reads-as-zero or clear for unknown contents (favoring all-0
as the most-common case). But with x-dirty-bitmap, we are instead
abusing NBD to query the 'qemu:dirty-bitmap:FOO' context, where bit 0 is
set for anywhere the bitmap has a 1, yet feed that information into the
pre-existing qemu code for handling block status. So qemu-img map is
reporting "data":true for what it thinks is the normal 0-for-allocated,
and "data":false for 1-for-sparse, and we just have to translate that
back into an understanding of what the bitmap reported. Yes, a comment
would be helpful.
I would _really_ love to enhance 'qemu-img map' to output image-specific
metadata _in addition_ to the existing "zero" and "data" fields (by
having qemu-img read two NBD contexts at once: both base:allocation and
qemu:dirty-bitmap:FOO), at which point we can drop the x- prefix and
avoid the abuse of qemu's internals by overwriting the block_status
code. But that's a bigger project.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2020-05-05 21:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-21 21:20 [PATCH v2 0/6] qemu-img: Add convert --bitmaps Eric Blake
2020-04-21 21:20 ` [PATCH v2 1/6] docs: Sort sections on qemu-img subcommand parameters Eric Blake
2020-04-30 12:50 ` Max Reitz
2020-04-21 21:20 ` [PATCH v2 2/6] blockdev: Split off basic bitmap operations for qemu-img Eric Blake
2020-04-30 13:59 ` Max Reitz
2020-04-30 14:50 ` Eric Blake
2020-05-08 11:37 ` Kevin Wolf
2020-05-08 13:48 ` Eric Blake
2020-04-21 21:20 ` [PATCH v2 3/6] qemu-img: Add bitmap sub-command Eric Blake
2020-04-30 14:55 ` Max Reitz
2020-04-30 15:21 ` Eric Blake
2020-05-04 10:01 ` Max Reitz
2020-05-04 13:28 ` Eric Blake
2020-04-21 21:20 ` [PATCH v2 4/6] qcow2: Expose bitmaps' size during measure Eric Blake
2020-05-04 11:36 ` Max Reitz
2020-05-04 13:44 ` Eric Blake
2020-04-21 21:20 ` [PATCH v2 5/6] qemu-img: Add convert --bitmaps option Eric Blake
2020-05-04 12:14 ` Max Reitz
2020-04-21 21:20 ` [PATCH v2 6/6] iotests: Add test 291 to for qemu-img bitmap coverage Eric Blake
2020-05-04 13:05 ` Max Reitz
2020-05-05 21:22 ` Eric Blake [this message]
2020-04-21 22:22 ` [PATCH v2 0/6] qemu-img: Add convert --bitmaps no-reply
2020-04-21 22:49 ` [PATCH] fixup! qemu-img: Add bitmap sub-command Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1b6cb574-a15b-e79d-53d5-1d8ea90e0d96@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).