Skip to content

Commit e669e80

Browse files
stefanhaRHkevmw
authored andcommitted
aio: warn about iohandler_ctx special casing
The main loop has two AioContexts: qemu_aio_context and iohandler_ctx. The main loop runs them both, but nested aio_poll() calls on qemu_aio_context exclude iohandler_ctx. Which one should qemu_get_current_aio_context() return when called from the main loop? Document that it's always qemu_aio_context. This has subtle effects on functions that use qemu_get_current_aio_context(). For example, aio_co_reschedule_self() does not work when moving from iohandler_ctx to qemu_aio_context because qemu_get_current_aio_context() does not differentiate these two AioContexts. Document this in order to reduce the chance of future bugs. Signed-off-by: Stefan Hajnoczi <[email protected]> Message-ID: <[email protected]> Reviewed-by: Kevin Wolf <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent 719c681 commit e669e80

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

include/block/aio.h

+6
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ void aio_co_schedule(AioContext *ctx, Coroutine *co);
629629
*
630630
* Move the currently running coroutine to new_ctx. If the coroutine is already
631631
* running in new_ctx, do nothing.
632+
*
633+
* Note that this function cannot reschedule from iohandler_ctx to
634+
* qemu_aio_context.
632635
*/
633636
void coroutine_fn aio_co_reschedule_self(AioContext *new_ctx);
634637

@@ -661,6 +664,9 @@ void aio_co_enter(AioContext *ctx, Coroutine *co);
661664
* If called from an IOThread this will be the IOThread's AioContext. If
662665
* called from the main thread or with the "big QEMU lock" taken it
663666
* will be the main loop AioContext.
667+
*
668+
* Note that the return value is never the main loop's iohandler_ctx and the
669+
* return value is the main loop AioContext instead.
664670
*/
665671
AioContext *qemu_get_current_aio_context(void);
666672

0 commit comments

Comments
 (0)