aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2017-06-28 15:05:13 +0300
committerMax Reitz <mreitz@redhat.com>2017-07-11 17:44:58 +0200
commitcb9ff6c25a25179736b7d8d9ddf00d45e5112a2b (patch)
tree9d6b63a3d0f69e031b4bc5e5987b6959626c2d46 /block.c
parent50bf65bab69aa6d01f759732927fbbf1c8abfe15 (diff)
block: new bdrv_reopen_bitmaps_rw interface
Add format driver handler, which should mark loaded read-only bitmaps as 'IN_USE' in the image and unset read_only field in corresponding BdrvDirtyBitmap's. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 20170628120530.31251-14-vsementsov@virtuozzo.com Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/block.c b/block.c
index 15a4e75ff5..3ec6624cb7 100644
--- a/block.c
+++ b/block.c
@@ -2983,12 +2983,16 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
{
BlockDriver *drv;
BlockDriverState *bs;
+ 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);
@@ -3002,6 +3006,21 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
bs->read_only = !(reopen_state->flags & BDRV_O_RDWR);
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));
+ }
+ }
}
/*