diff options
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 27 |
1 files changed, 18 insertions, 9 deletions
@@ -1438,13 +1438,19 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file, bs->read_only = !(bs->open_flags & BDRV_O_RDWR); if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) { - error_setg(errp, - !bs->read_only && bdrv_is_whitelisted(drv, true) - ? "Driver '%s' can only be used for read-only devices" - : "Driver '%s' is not whitelisted", - drv->format_name); - ret = -ENOTSUP; - goto fail_opts; + if (!bs->read_only && bdrv_is_whitelisted(drv, true)) { + ret = bdrv_apply_auto_read_only(bs, NULL, NULL); + } else { + ret = -ENOTSUP; + } + if (ret < 0) { + error_setg(errp, + !bs->read_only && bdrv_is_whitelisted(drv, true) + ? "Driver '%s' can only be used for read-only devices" + : "Driver '%s' is not whitelisted", + drv->format_name); + goto fail_opts; + } } /* bdrv_new() and bdrv_close() make it so */ @@ -3725,6 +3731,7 @@ static void bdrv_check_co_entry(void *opaque) { CheckCo *cco = opaque; cco->ret = bdrv_co_check(cco->bs, cco->res, cco->fix); + aio_wait_kick(); } int bdrv_check(BlockDriverState *bs, @@ -3743,7 +3750,7 @@ int bdrv_check(BlockDriverState *bs, bdrv_check_co_entry(&cco); } else { co = qemu_coroutine_create(bdrv_check_co_entry, &cco); - qemu_coroutine_enter(co); + bdrv_coroutine_enter(bs, co); BDRV_POLL_WHILE(bs, cco.ret == -EINPROGRESS); } @@ -4690,6 +4697,7 @@ static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, if (parent->role->activate) { parent->role->activate(parent, &local_err); if (local_err) { + bs->open_flags |= BDRV_O_INACTIVE; error_propagate(errp, local_err); return; } @@ -4708,6 +4716,7 @@ static void coroutine_fn bdrv_invalidate_cache_co_entry(void *opaque) InvalidateCacheCo *ico = opaque; bdrv_co_invalidate_cache(ico->bs, ico->errp); ico->done = true; + aio_wait_kick(); } void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) @@ -4724,7 +4733,7 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) bdrv_invalidate_cache_co_entry(&ico); } else { co = qemu_coroutine_create(bdrv_invalidate_cache_co_entry, &ico); - qemu_coroutine_enter(co); + bdrv_coroutine_enter(bs, co); BDRV_POLL_WHILE(bs, !ico.done); } } |