mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
aio-posix: add fdmon_ops->dispatch()
The ppoll and epoll file descriptor monitoring implementations rely on the event loop's generic file descriptor, timer, and BH dispatch code to invoke user callbacks. The io_uring file descriptor monitoring implementation will need io_uring-specific dispatch logic for CQE handlers for custom SQEs. Introduce a new FDMonOps ->dispatch() callback that allows file descriptor monitoring implementations to invoke user callbacks. The next patch will use this new callback. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20251104022933.618123-13-stefanha@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
committed by
Kevin Wolf
parent
a63e41f2a4
commit
87e7a0f423
@@ -107,6 +107,25 @@ typedef struct {
|
||||
*/
|
||||
bool (*need_wait)(AioContext *ctx);
|
||||
|
||||
/*
|
||||
* dispatch:
|
||||
* @ctx: the AioContext
|
||||
*
|
||||
* Dispatch any work that is specific to this file descriptor monitoring
|
||||
* implementation. Usually the event loop's generic file descriptor
|
||||
* monitoring, BH, and timer dispatching code is sufficient, but file
|
||||
* descriptor monitoring implementations offering additional functionality
|
||||
* may need to implement this function for custom behavior. Called at a
|
||||
* point in the event loop when it is safe to invoke user-defined
|
||||
* callbacks.
|
||||
*
|
||||
* This function is optional and may be NULL.
|
||||
*
|
||||
* Returns: true if progress was made (see aio_poll()'s return value),
|
||||
* false otherwise.
|
||||
*/
|
||||
bool (*dispatch)(AioContext *ctx);
|
||||
|
||||
/*
|
||||
* gsource_prepare:
|
||||
* @ctx: the AioContext
|
||||
|
||||
@@ -385,10 +385,15 @@ void aio_dispatch(AioContext *ctx)
|
||||
AioHandlerList ready_list = QLIST_HEAD_INITIALIZER(ready_list);
|
||||
|
||||
qemu_lockcnt_inc(&ctx->list_lock);
|
||||
|
||||
aio_bh_poll(ctx);
|
||||
|
||||
ctx->fdmon_ops->gsource_dispatch(ctx, &ready_list);
|
||||
|
||||
if (ctx->fdmon_ops->dispatch) {
|
||||
ctx->fdmon_ops->dispatch(ctx);
|
||||
}
|
||||
|
||||
/* block_ns is 0 because polling is disabled in the glib event loop */
|
||||
aio_dispatch_ready_handlers(ctx, &ready_list, 0);
|
||||
|
||||
@@ -707,6 +712,10 @@ bool aio_poll(AioContext *ctx, bool blocking)
|
||||
block_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - start;
|
||||
}
|
||||
|
||||
if (ctx->fdmon_ops->dispatch) {
|
||||
progress |= ctx->fdmon_ops->dispatch(ctx);
|
||||
}
|
||||
|
||||
progress |= aio_bh_poll(ctx);
|
||||
progress |= aio_dispatch_ready_handlers(ctx, &ready_list, block_ns);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user