[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 082/100] qcow2: store bitmaps on reopening image as r
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 082/100] qcow2: store bitmaps on reopening image as read-only |
Date: |
Fri, 7 Jul 2017 19:08:37 +0200 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Store bitmaps and mark them read-only on reopening image as read-only.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
block/qcow2-bitmap.c | 22 ++++++++++++++++++++++
block/qcow2.c | 5 +++++
block/qcow2.h | 1 +
3 files changed, 28 insertions(+)
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 5f53486..7912a82 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1365,3 +1365,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;
+}
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 @@ static int qcow2_reopen_prepare(BDRVReopenState *state,
/* 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;
diff --git a/block/qcow2.h b/block/qcow2.h
index 308cefd..1f80b5d 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -648,5 +648,6 @@ int qcow2_check_bitmaps_refcounts(BlockDriverState *bs,
BdrvCheckResult *res,
bool qcow2_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **errp);
int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp);
void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp);
+int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp);
#endif
--
1.8.3.1
- [Qemu-block] [PULL 071/100] block/dirty-bitmap: fix comment for BlockDirtyBitmap.disabled field, (continued)
- [Qemu-block] [PULL 071/100] block/dirty-bitmap: fix comment for BlockDirtyBitmap.disabled field, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 072/100] block/dirty-bitmap: add readonly field to BdrvDirtyBitmap, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 070/100] qcow2: add bitmaps extension, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 074/100] block: refactor bdrv_reopen_commit, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 073/100] qcow2: autoloading dirty bitmaps, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 078/100] block: bdrv_close: release bitmaps after drv->bdrv_close, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 075/100] block: new bdrv_reopen_bitmaps_rw interface, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 077/100] block/dirty-bitmap: add autoload field to BdrvDirtyBitmap, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 076/100] qcow2: support .bdrv_reopen_bitmaps_rw, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 079/100] block: introduce persistent dirty bitmaps, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 082/100] qcow2: store bitmaps on reopening image as read-only,
Kevin Wolf <=
- [Qemu-block] [PULL 080/100] block/dirty-bitmap: add bdrv_dirty_bitmap_next(), Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 081/100] qcow2: add persistent dirty bitmaps support, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 083/100] block: add bdrv_can_store_new_dirty_bitmap, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 087/100] qmp: add x-debug-block-dirty-bitmap-sha256, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 084/100] qcow2: add .bdrv_can_store_new_dirty_bitmap, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 086/100] qmp: add autoload parameter to block-dirty-bitmap-add, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 088/100] iotests: test qcow2 persistent dirty bitmap, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 085/100] qmp: add persistent flag to block-dirty-bitmap-add, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 089/100] block/dirty-bitmap: add bdrv_remove_persistent_dirty_bitmap, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 093/100] iotests: skip 159 & 170 with luks format, Kevin Wolf, 2017/07/07