block: Create no_co_wrappers for open functions

Images can't be opened in coroutine context because opening needs to
change the block graph. Add no_co_wrappers so that coroutines have a
simple way of opening images in a BH instead.

At the same time, mark the wrapped functions as no_coroutine_fn.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230126172432.436111-3-kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Kevin Wolf 2023-01-26 18:24:21 +01:00
parent d6ee2e324e
commit 4bee90e9da
3 changed files with 44 additions and 13 deletions

View file

@ -23,10 +23,23 @@
*/
BlockBackend *blk_new(AioContext *ctx, uint64_t perm, uint64_t shared_perm);
BlockBackend *blk_new_with_bs(BlockDriverState *bs, uint64_t perm,
uint64_t shared_perm, Error **errp);
BlockBackend *blk_new_open(const char *filename, const char *reference,
QDict *options, int flags, Error **errp);
BlockBackend * no_coroutine_fn
blk_new_with_bs(BlockDriverState *bs, uint64_t perm, uint64_t shared_perm,
Error **errp);
BlockBackend * coroutine_fn no_co_wrapper
blk_co_new_with_bs(BlockDriverState *bs, uint64_t perm, uint64_t shared_perm,
Error **errp);
BlockBackend * no_coroutine_fn
blk_new_open(const char *filename, const char *reference, QDict *options,
int flags, Error **errp);
BlockBackend * coroutine_fn no_co_wrapper
blk_co_new_open(const char *filename, const char *reference, QDict *options,
int flags, Error **errp);
int blk_get_refcnt(BlockBackend *blk);
void blk_ref(BlockBackend *blk);
void blk_unref(BlockBackend *blk);