From e3713e001fb7d4d82f6de82800c1463e758e4289 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 24 Sep 2012 14:57:41 +0200 Subject: aio: make AioContexts GSources This lets AioContexts be used (optionally) with a glib main loop. Signed-off-by: Paolo Bonzini --- qemu-aio.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'qemu-aio.h') diff --git a/qemu-aio.h b/qemu-aio.h index ac24896..aedf66c 100644 --- a/qemu-aio.h +++ b/qemu-aio.h @@ -44,6 +44,8 @@ typedef void QEMUBHFunc(void *opaque); typedef void IOHandler(void *opaque); typedef struct AioContext { + GSource source; + /* The list of registered AIO handlers */ QLIST_HEAD(, AioHandler) aio_handlers; @@ -75,6 +77,22 @@ typedef int (AioFlushEventNotifierHandler)(EventNotifier *e); AioContext *aio_context_new(void); /** + * aio_context_ref: + * @ctx: The AioContext to operate on. + * + * Add a reference to an AioContext. + */ +void aio_context_ref(AioContext *ctx); + +/** + * aio_context_unref: + * @ctx: The AioContext to operate on. + * + * Drop a reference to an AioContext. + */ +void aio_context_unref(AioContext *ctx); + +/** * aio_bh_new: Allocate a new bottom half structure. * * Bottom halves are lightweight callbacks whose invocation is guaranteed @@ -188,6 +206,11 @@ void aio_set_event_notifier(AioContext *ctx, EventNotifierHandler *io_read, AioFlushEventNotifierHandler *io_flush); +/* Return a GSource that lets the main loop poll the file descriptors attached + * to this AioContext. + */ +GSource *aio_get_g_source(AioContext *ctx); + /* Functions to operate on the main QEMU AioContext. */ void qemu_aio_flush(void); -- cgit v1.1