aboutsummaryrefslogtreecommitdiff
path: root/block/dirty-bitmap.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2018-06-11 14:53:32 -0400
committerJohn Snow <jsnow@redhat.com>2018-06-11 14:53:32 -0400
commitb598e531f1123d2fb72615f1161c66093be751ea (patch)
tree0b49f40ac59b8c19d6f46efb5a4875058b48742a /block/dirty-bitmap.c
parentc6490447402f574bbe45f45c318e0bdd19121baf (diff)
qapi: add x-block-dirty-bitmap-merge
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Message-id: 20180606182449.1607-5-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'block/dirty-bitmap.c')
-rw-r--r--block/dirty-bitmap.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 59b38b2671..383d742cdb 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -728,3 +728,21 @@ int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap *bitmap, uint64_t offset)
{
return hbitmap_next_zero(bitmap->bitmap, offset);
}
+
+void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src,
+ Error **errp)
+{
+ /* only bitmaps from one bds are supported */
+ assert(dest->mutex == src->mutex);
+
+ qemu_mutex_lock(dest->mutex);
+
+ assert(bdrv_dirty_bitmap_enabled(dest));
+ assert(!bdrv_dirty_bitmap_readonly(dest));
+
+ if (!hbitmap_merge(dest->bitmap, src->bitmap)) {
+ error_setg(errp, "Bitmaps are incompatible and can't be merged");
+ }
+
+ qemu_mutex_unlock(dest->mutex);
+}