aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2-bitmap.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2017-06-28 15:05:20 +0300
committerMax Reitz <mreitz@redhat.com>2017-07-11 17:44:58 +0200
commit169b87935966791a860f59a2b17c4e0c7b953779 (patch)
tree2c76d00277ffe3d6b651737e7113b9530f117a9f /block/qcow2-bitmap.c
parent5f72826e7fc62167cf3a37383d1c1151bc9971fe (diff)
qcow2: store bitmaps on reopening image as read-only
Store bitmaps and mark them read-only on reopening image as read-only. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 20170628120530.31251-21-vsementsov@virtuozzo.com Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/qcow2-bitmap.c')
-rw-r--r--block/qcow2-bitmap.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 81c49aecdb..f82478c02a 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1366,3 +1366,25 @@ fail:
bitmap_list_free(bm_list);
}
+
+int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp)
+{
+ BdrvDirtyBitmap *bitmap;
+ Error *local_err = NULL;
+
+ qcow2_store_persistent_dirty_bitmaps(bs, &local_err);
+ if (local_err != NULL) {
+ error_propagate(errp, local_err);
+ return -EINVAL;
+ }
+
+ for (bitmap = bdrv_dirty_bitmap_next(bs, NULL); bitmap != NULL;
+ bitmap = bdrv_dirty_bitmap_next(bs, bitmap))
+ {
+ if (bdrv_dirty_bitmap_get_persistance(bitmap)) {
+ bdrv_dirty_bitmap_set_readonly(bitmap, true);
+ }
+ }
+
+ return 0;
+}