summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy2018-06-11 20:53:32 +0200
committerJohn Snow2018-06-11 20:53:32 +0200
commitb598e531f1123d2fb72615f1161c66093be751ea (patch)
tree0b49f40ac59b8c19d6f46efb5a4875058b48742a /block
parentqmp: transaction support for x-block-dirty-bitmap-enable/disable (diff)
downloadqemu-b598e531f1123d2fb72615f1161c66093be751ea.tar.gz
qemu-b598e531f1123d2fb72615f1161c66093be751ea.tar.xz
qemu-b598e531f1123d2fb72615f1161c66093be751ea.zip
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')
-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);
+}