block: Introduce bdrv_coroutine_enter
Signed-off-by: Fam Zheng <famz@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
diff --git a/block.c b/block.c
index a995a8e..086a12d 100644
--- a/block.c
+++ b/block.c
@@ -4324,6 +4324,11 @@
return bs->aio_context;
}
+void bdrv_coroutine_enter(BlockDriverState *bs, Coroutine *co)
+{
+ aio_co_enter(bdrv_get_aio_context(bs), co);
+}
+
static void bdrv_do_remove_aio_context_notifier(BdrvAioNotifier *ban)
{
QLIST_REMOVE(ban, list);
diff --git a/include/block/block.h b/include/block/block.h
index 488a07e..97d4330 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -558,6 +558,11 @@
AioContext *bdrv_get_aio_context(BlockDriverState *bs);
/**
+ * Transfer control to @co in the aio context of @bs
+ */
+void bdrv_coroutine_enter(BlockDriverState *bs, Coroutine *co);
+
+/**
* bdrv_set_aio_context:
*
* Changes the #AioContext used for fd handlers, timers, and BHs by this