@@ -533,12 +533,6 @@ struct BlockDriver {
bool (*bdrv_need_rw_file_child_during_reopen_rw)(BlockDriverState *bs);
- /**
- * Bitmaps should be marked as 'IN_USE' in the image on reopening image
- * as rw. This handler should realize it. It also should unset readonly
- * field of BlockDirtyBitmap's in case of success.
- */
- int (*bdrv_reopen_bitmaps_rw)(BlockDriverState *bs, Error **errp);
bool (*bdrv_can_store_new_dirty_bitmap)(BlockDriverState *bs,
const char *name,
uint32_t granularity,
@@ -4037,16 +4037,12 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
BlockDriver *drv;
BlockDriverState *bs;
BdrvChild *child;
- bool old_can_write, new_can_write;
assert(reopen_state != NULL);
bs = reopen_state->bs;
drv = bs->drv;
assert(drv != NULL);
- old_can_write =
- !bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE);
-
/* If there are any driver level actions to take */
if (drv->bdrv_reopen_commit) {
drv->bdrv_reopen_commit(reopen_state);
@@ -4090,21 +4086,6 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
}
bdrv_refresh_limits(bs, NULL);
-
- new_can_write =
- !bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE);
- if (!old_can_write && new_can_write && drv->bdrv_reopen_bitmaps_rw) {
- Error *local_err = NULL;
- if (drv->bdrv_reopen_bitmaps_rw(bs, &local_err) < 0) {
- /* This is not fatal, bitmaps just left read-only, so all following
- * writes will fail. User can remove read-only bitmaps to unblock
- * writes.
- */
- error_reportf_err(local_err,
- "%s: Failed to make dirty bitmaps writable: ",
- bdrv_get_node_name(bs));
- }
- }
}
/*
@@ -1815,6 +1815,11 @@ static int qcow2_reopen_prepare(BDRVReopenState *state,
if (ret < 0) {
goto fail;
}
+ } else {
+ ret = qcow2_reopen_bitmaps_rw(state->bs, errp);
+ if (ret < 0) {
+ goto fail;
+ }
}
return 0;
@@ -5229,7 +5234,6 @@ BlockDriver bdrv_qcow2 = {
.bdrv_detach_aio_context = qcow2_detach_aio_context,
.bdrv_attach_aio_context = qcow2_attach_aio_context,
- .bdrv_reopen_bitmaps_rw = qcow2_reopen_bitmaps_rw,
.bdrv_can_store_new_dirty_bitmap = qcow2_can_store_new_dirty_bitmap,
.bdrv_remove_persistent_dirty_bitmap = qcow2_remove_persistent_dirty_bitmap,
.bdrv_need_rw_file_child_during_reopen_rw = qcow2_has_bitmaps,
Since we have used .bdrv_need_rw_file_child_during_reopen_rw handler, and have write access to file child in reopen-prepare, and we prepared qcow2_reopen_bitmaps_rw to be called from reopening rw -> rw, we now can simple move qcow2_reopen_bitmaps_rw() call to qcow2_reopen_prepare() and handle errors as befits. Hacky handler .bdrv_reopen_bitmaps_rw is not needed more and therefore dropped. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> --- include/block/block_int.h | 6 ------ block.c | 19 ------------------- block/qcow2.c | 6 +++++- 3 files changed, 5 insertions(+), 26 deletions(-)