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>
diff --git a/block/qcow2.c b/block/qcow2.c
index 790b5b1..1a31f1d 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1555,6 +1555,11 @@
/* We need to write out any unwritten data if we reopen read-only. */
if ((state->flags & BDRV_O_RDWR) == 0) {
+ ret = qcow2_reopen_bitmaps_ro(state->bs, errp);
+ if (ret < 0) {
+ goto fail;
+ }
+
ret = bdrv_flush(state->bs);
if (ret < 0) {
goto fail;