@@ -2113,6 +2113,11 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
} while ((entry = qdict_next(reopen_state->options, entry)));
}
+ reopen_state->was_locked = reopen_state->bs->image_locked;
+ if (reopen_state->was_locked) {
+ bdrv_unlock_image(reopen_state->bs);
+ }
+
ret = 0;
error:
@@ -2137,6 +2142,9 @@ static void bdrv_reopen_commit(BDRVReopenState *reopen_state)
if (drv->bdrv_reopen_commit) {
drv->bdrv_reopen_commit(reopen_state);
}
+ if (reopen_state->was_locked) {
+ bdrv_lock_image(reopen_state->bs);
+ }
/* set BDS specific flags now */
QDECREF(reopen_state->bs->explicit_options);
@@ -2163,6 +2171,9 @@ static void bdrv_reopen_abort(BDRVReopenState *reopen_state)
if (drv->bdrv_reopen_abort) {
drv->bdrv_reopen_abort(reopen_state);
}
+ if (reopen_state->was_locked) {
+ bdrv_lock_image(reopen_state->bs);
+ }
QDECREF(reopen_state->explicit_options);
}
@@ -157,6 +157,7 @@ typedef struct BDRVReopenState {
QDict *options;
QDict *explicit_options;
void *opaque;
+ bool was_locked;
} BDRVReopenState;
/*
Stash the locking state into BDRVReopenState. If it was locked, unlock in prepare, and lock it again when commit or abort. Signed-off-by: Fam Zheng <famz@redhat.com> --- block.c | 11 +++++++++++ include/block/block.h | 1 + 2 files changed, 12 insertions(+)