From: John Snow <jsnow@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, John Snow <jsnow@redhat.com>,
jcody@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/9] block: add bdrv_copy_dirty_bitmap
Date: Thu, 4 Jun 2015 20:20:36 -0400 [thread overview]
Message-ID: <1433463642-21840-4-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1433463642-21840-1-git-send-email-jsnow@redhat.com>
One step up from hbitmap, we need a copy primitive for
the BdrvDirtyBitmap type.
Signed-off-by: John Snow <jsnow@redhat.com>
---
block.c | 26 ++++++++++++++++++++++++++
include/block/block.h | 4 ++++
2 files changed, 30 insertions(+)
diff --git a/block.c b/block.c
index 1eb81ac..5551f79 100644
--- a/block.c
+++ b/block.c
@@ -3114,6 +3114,32 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,
return bitmap;
}
+BdrvDirtyBitmap *bdrv_copy_dirty_bitmap(BlockDriverState *bs,
+ const BdrvDirtyBitmap *bitmap,
+ const char *name,
+ Error **errp)
+{
+ BdrvDirtyBitmap *new_bitmap;
+
+ if (name && bdrv_find_dirty_bitmap(bs, name)) {
+ error_setg(errp, "Bitmap already exists: %s", name);
+ return NULL;
+ }
+
+ new_bitmap = g_new0(BdrvDirtyBitmap, 1);
+ new_bitmap->bitmap = hbitmap_copy(bitmap->bitmap);
+ new_bitmap->size = bitmap->size;
+ new_bitmap->name = g_strdup(name);
+
+ if (bitmap->successor) {
+ /* NB: 2nd arg is read-only. */
+ hbitmap_merge(new_bitmap->bitmap, bitmap->successor->bitmap);
+ }
+
+ QLIST_INSERT_HEAD(&bs->dirty_bitmaps, new_bitmap, list);
+ return new_bitmap;
+}
+
bool bdrv_dirty_bitmap_frozen(BdrvDirtyBitmap *bitmap)
{
return bitmap->successor;
diff --git a/include/block/block.h b/include/block/block.h
index b7892d2..e88a332 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -456,6 +456,10 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,
uint32_t granularity,
const char *name,
Error **errp);
+BdrvDirtyBitmap *bdrv_copy_dirty_bitmap(BlockDriverState *bs,
+ const BdrvDirtyBitmap *bitmap,
+ const char *name,
+ Error **errp);
int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs,
BdrvDirtyBitmap *bitmap,
Error **errp);
--
2.1.0
next prev parent reply other threads:[~2015-06-05 0:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 0:20 [Qemu-devel] [PATCH 0/9] block: add differential backup support John Snow
2015-06-05 0:20 ` [Qemu-devel] [PATCH 1/9] qapi: Rename 'dirty-bitmap' mode to 'incremental' John Snow
2015-06-05 2:34 ` Eric Blake
2015-06-25 16:16 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-06-05 0:20 ` [Qemu-devel] [PATCH 2/9] hbitmap: add hbitmap_copy John Snow
2015-06-05 2:37 ` Eric Blake
2015-06-05 0:20 ` John Snow [this message]
2015-06-05 2:42 ` [Qemu-devel] [PATCH 3/9] block: add bdrv_copy_dirty_bitmap Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 4/9] qapi: add Copy data type for bitmaps John Snow
2015-06-05 2:57 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 5/9] qmp: add qmp cmd block-dirty-bitmap-copy John Snow
2015-06-05 3:04 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 6/9] qmp: add block-dirty-bitmap-copy transaction John Snow
2015-06-05 0:20 ` [Qemu-devel] [PATCH 7/9] block: add differential backup mode John Snow
2015-06-05 0:20 ` [Qemu-devel] [PATCH 8/9] iotests: 124: support differential backups John Snow
2015-06-05 0:20 ` [Qemu-devel] [PATCH 9/9] iotests: add differential backup test John Snow
2015-06-23 17:00 ` [Qemu-devel] [PATCH 0/9] block: add differential backup support John Snow
2015-06-24 14:33 ` Stefan Hajnoczi
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=1433463642-21840-4-git-send-email-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@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).