[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 3/9] block: add bdrv_copy_dirty_bitmap
From: |
John Snow |
Subject: |
[Qemu-block] [PATCH 3/9] block: add bdrv_copy_dirty_bitmap |
Date: |
Thu, 4 Jun 2015 20:20:36 -0400 |
One step up from hbitmap, we need a copy primitive for
the BdrvDirtyBitmap type.
Signed-off-by: John Snow <address@hidden>
---
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
- [Qemu-block] [PATCH 0/9] block: add differential backup support, John Snow, 2015/06/04
- [Qemu-block] [PATCH 2/9] hbitmap: add hbitmap_copy, John Snow, 2015/06/04
- [Qemu-block] [PATCH 3/9] block: add bdrv_copy_dirty_bitmap,
John Snow <=
- [Qemu-block] [PATCH 1/9] qapi: Rename 'dirty-bitmap' mode to 'incremental', John Snow, 2015/06/04
- [Qemu-block] [PATCH 4/9] qapi: add Copy data type for bitmaps, John Snow, 2015/06/04
- [Qemu-block] [PATCH 7/9] block: add differential backup mode, John Snow, 2015/06/04
- [Qemu-block] [PATCH 5/9] qmp: add qmp cmd block-dirty-bitmap-copy, John Snow, 2015/06/04
- [Qemu-block] [PATCH 6/9] qmp: add block-dirty-bitmap-copy transaction, John Snow, 2015/06/04