From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
"open list:Block layer core" <qemu-block@nongnu.org>,
Max Reitz <mreitz@redhat.com>
Subject: [PULL 09/11] qemu-img: Factor out code for merging bitmaps
Date: Tue, 26 May 2020 11:42:09 -0500 [thread overview]
Message-ID: <20200526164211.1569366-10-eblake@redhat.com> (raw)
In-Reply-To: <20200526164211.1569366-1-eblake@redhat.com>
The next patch will add another client that wants to merge dirty
bitmaps; it will be easier to refactor the code to construct the QAPI
struct correctly into a helper function.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200521192137.1120211-4-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
qemu-img.c | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index b2311bd3f6b4..0778d8f56614 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1638,6 +1638,24 @@ out4:
return ret;
}
+/* Convenience wrapper around qmp_block_dirty_bitmap_merge */
+static void do_dirty_bitmap_merge(const char *dst_node, const char *dst_name,
+ const char *src_node, const char *src_name,
+ Error **errp)
+{
+ BlockDirtyBitmapMergeSource *merge_src;
+ BlockDirtyBitmapMergeSourceList *list;
+
+ merge_src = g_new0(BlockDirtyBitmapMergeSource, 1);
+ merge_src->type = QTYPE_QDICT;
+ merge_src->u.external.node = g_strdup(src_node);
+ merge_src->u.external.name = g_strdup(src_name);
+ list = g_new0(BlockDirtyBitmapMergeSourceList, 1);
+ list->value = merge_src;
+ qmp_block_dirty_bitmap_merge(dst_node, dst_name, list, errp);
+ qapi_free_BlockDirtyBitmapMergeSourceList(list);
+}
+
enum ImgConvertBlockStatus {
BLK_DATA,
BLK_ZERO,
@@ -4714,21 +4732,11 @@ static int img_bitmap(int argc, char **argv)
qmp_block_dirty_bitmap_disable(bs->node_name, bitmap, &err);
op = "disable";
break;
- case BITMAP_MERGE: {
- BlockDirtyBitmapMergeSource *merge_src;
- BlockDirtyBitmapMergeSourceList *list;
-
- merge_src = g_new0(BlockDirtyBitmapMergeSource, 1);
- merge_src->type = QTYPE_QDICT;
- merge_src->u.external.node = g_strdup(src_bs->node_name);
- merge_src->u.external.name = g_strdup(act->src);
- list = g_new0(BlockDirtyBitmapMergeSourceList, 1);
- list->value = merge_src;
- qmp_block_dirty_bitmap_merge(bs->node_name, bitmap, list, &err);
- qapi_free_BlockDirtyBitmapMergeSourceList(list);
+ case BITMAP_MERGE:
+ do_dirty_bitmap_merge(bs->node_name, bitmap, src_bs->node_name,
+ act->src, &err);
op = "merge";
break;
- }
default:
g_assert_not_reached();
}
--
2.26.2
next prev parent reply other threads:[~2020-05-26 16:46 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-26 16:42 [PULL 00/11] bitmaps patches for 2020-05-26 Eric Blake
2020-05-26 16:42 ` [PULL 01/11] migration: refactor init_dirty_bitmap_migration Eric Blake
2020-05-26 16:42 ` [PULL 02/11] block/dirty-bitmap: add bdrv_has_named_bitmaps helper Eric Blake
2020-05-26 16:42 ` [PULL 03/11] migration: fix bitmaps pre-blockdev migration with mirror job Eric Blake
2020-05-26 16:42 ` [PULL 04/11] iotests: 194: test also migration of dirty bitmap Eric Blake
2020-05-26 16:42 ` [PULL 05/11] migration: add_bitmaps_to_list: check disk name once Eric Blake
2020-05-26 16:42 ` [PULL 06/11] migration: forbid bitmap migration by generated node-name Eric Blake
2020-05-26 16:42 ` [PULL 07/11] iotests: Fix test 178 Eric Blake
2020-05-26 16:42 ` [PULL 08/11] qcow2: Expose bitmaps' size during measure Eric Blake
2020-05-26 16:42 ` Eric Blake [this message]
2020-05-26 16:42 ` [PULL 10/11] qemu-img: Add convert --bitmaps option Eric Blake
2020-05-26 16:42 ` [PULL 11/11] iotests: Add test 291 to for qemu-img bitmap coverage Eric Blake
2020-05-27 20:07 ` [PULL 00/11] bitmaps patches for 2020-05-26 Peter Maydell
2020-05-27 20:32 ` 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=20200526164211.1569366-10-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/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).