bitmaps patches for 2020-09-21

- Eric Blake: Improve 'qemu-img bitmap --merge' by not opening backing images
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAl9pTDcACgkQp6FrSiUn
 Q2oB8ggArMx/o1aN+3tcTokC3KJlU1/7lt7F4LltiQpUglAUWmtJt6+hgF8vWEgz
 3L9IcyNDwI0c6ernmgKohUjLQh4n5M+0mzKWfASi2H4DF9iHiGnMe8OSHCQL4uE+
 /OvUkZ5N01ITtxXbxOL1RZGNztDaM4gozcJkqmpSn65Jve1tPwCZyGwtvBk8EOgv
 QEsiGGip3IGCwNHkVd46vkHBohf5hfDk7PI4k+O8XLDD7QQTYo0FJBu4BZYwYQBF
 MZVatYZGKbd1GIPQtS+16qZ/+x9Gcxj8Wyn2kira5w3OM/TzwqoDp9YfF9jLwNOX
 WbtN+mVtwnrKwEkBEghYxUt1GDIYEw==
 =PaDG
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/ericb/tags/pull-bitmaps-2020-09-21' into staging

bitmaps patches for 2020-09-21

- Eric Blake: Improve 'qemu-img bitmap --merge' by not opening backing images

# gpg: Signature made Tue 22 Sep 2020 01:58:31 BST
# gpg:                using RSA key 71C2CC22B1C4602927D2F3AAA7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>" [full]
# gpg:                 aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" [full]
# gpg:                 aka "[jpeg image of size 6874]" [full]
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A

* remotes/ericb/tags/pull-bitmaps-2020-09-21:
  qemu-img: Support bitmap --merge into backing image

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-09-23 15:11:38 +01:00
commit c122bca9cd
3 changed files with 76 additions and 3 deletions

View File

@ -4779,14 +4779,19 @@ static int img_bitmap(int argc, char **argv)
filename = argv[optind];
bitmap = argv[optind + 1];
blk = img_open(image_opts, filename, fmt, BDRV_O_RDWR, false, false,
false);
/*
* No need to open backing chains; we will be manipulating bitmaps
* directly in this image without reference to image contents.
*/
blk = img_open(image_opts, filename, fmt, BDRV_O_RDWR | BDRV_O_NO_BACKING,
false, false, false);
if (!blk) {
goto out;
}
bs = blk_bs(blk);
if (src_filename) {
src = img_open(false, src_filename, src_fmt, 0, false, false, false);
src = img_open(false, src_filename, src_fmt, BDRV_O_NO_BACKING,
false, false, false);
if (!src) {
goto out;
}

View File

@ -91,6 +91,15 @@ $QEMU_IMG bitmap --remove --image-opts \
driver=$IMGFMT,file.driver=file,file.filename="$TEST_IMG" tmp
_img_info --format-specific
echo
echo "=== Merge from top layer into backing image ==="
echo
$QEMU_IMG rebase -u -F qcow2 -b "$TEST_IMG.base" "$TEST_IMG"
$QEMU_IMG bitmap --add --merge b2 -b "$TEST_IMG" -F $IMGFMT \
-f $IMGFMT "$TEST_IMG.base" b3
_img_info --format-specific --backing-chain
echo
echo "=== Check bitmap contents ==="
echo
@ -107,6 +116,9 @@ $QEMU_IMG map --output=json --image-opts \
nbd_server_start_unix_socket -r -f qcow2 -B b2 "$TEST_IMG"
$QEMU_IMG map --output=json --image-opts \
"$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b2" | _filter_qemu_img_map
nbd_server_start_unix_socket -r -f qcow2 -B b3 "$TEST_IMG"
$QEMU_IMG map --output=json --image-opts \
"$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b3" | _filter_qemu_img_map
# success, all done
echo '*** done'

View File

@ -68,6 +68,59 @@ Format specific information:
corrupt: false
extended l2: false
=== Merge from top layer into backing image ===
image: TEST_DIR/t.IMGFMT
file format: IMGFMT
virtual size: 10 MiB (10485760 bytes)
cluster_size: 65536
backing file: TEST_DIR/t.IMGFMT.base
backing file format: IMGFMT
Format specific information:
compat: 1.1
compression type: zlib
lazy refcounts: false
bitmaps:
[0]:
flags:
name: b1
granularity: 524288
[1]:
flags:
[0]: auto
name: b2
granularity: 65536
[2]:
flags:
name: b0
granularity: 65536
refcount bits: 16
corrupt: false
extended l2: false
image: TEST_DIR/t.IMGFMT.base
file format: IMGFMT
virtual size: 10 MiB (10485760 bytes)
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
lazy refcounts: false
bitmaps:
[0]:
flags:
[0]: auto
name: b0
granularity: 65536
[1]:
flags:
[0]: auto
name: b3
granularity: 65536
refcount bits: 16
corrupt: false
extended l2: false
=== Check bitmap contents ===
[{ "start": 0, "length": 3145728, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
@ -79,4 +132,7 @@ Format specific information:
[{ "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}]
[{ "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}]
*** done