@@ -613,3 +613,15 @@ BdrvDirtyBitmap *bdrv_load_dirty_bitmap(BlockDriverState *bs, const char *name,
}
return NULL;
}
+
+bool bdrv_has_dirty_bitmap(BlockDriverState *bs, const BdrvDirtyBitmap *bitmap)
+{
+ BdrvDirtyBitmap *bm, *next;
+ QLIST_FOREACH_SAFE(bm, &bs->dirty_bitmaps, list, next) {
+ if (bm == bitmap) {
+ return true;
+ }
+ }
+
+ return false;
+}
@@ -881,6 +881,11 @@ void qcow2_bitmap_store(BlockDriverState *bs,
uint32_t table_size;
uint64_t *bitmap_table;
+ if (!bdrv_has_dirty_bitmap(bs, bitmap)) {
+ error_setg(errp, "Can't store bitmap to the other node.");
+ return;
+ }
+
/* find/create dirty bitmap */
bmh = find_bitmap_by_name(bs, bm_name);
if (bmh != NULL) {
@@ -84,4 +84,6 @@ void bdrv_finalize_persistent_dirty_bitmaps(BlockDriverState *bs);
BdrvDirtyBitmap *bdrv_load_dirty_bitmap(BlockDriverState *bs, const char *name,
Error **errp);
+bool bdrv_has_dirty_bitmap(BlockDriverState *bs, const BdrvDirtyBitmap *bitmap);
+
#endif
Check, that bitmap is stored to the owning bs. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> --- block/dirty-bitmap.c | 12 ++++++++++++ block/qcow2-bitmap.c | 5 +++++ include/block/dirty-bitmap.h | 2 ++ 3 files changed, 19 insertions(+)