aio: add I/O handlers to the AioContext interface

With this patch, I/O handlers (including event notifier handlers) can be
attached to a single AioContext.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2012-09-13 12:28:51 +02:00
parent f627aab1cc
commit a915f4bc97
4 changed files with 101 additions and 48 deletions

View file

@ -526,3 +526,36 @@ int qemu_bh_poll(void)
{
return aio_bh_poll(qemu_aio_context);
}
void qemu_aio_flush(void)
{
aio_flush(qemu_aio_context);
}
bool qemu_aio_wait(void)
{
return aio_wait(qemu_aio_context);
}
void qemu_aio_set_fd_handler(int fd,
IOHandler *io_read,
IOHandler *io_write,
AioFlushHandler *io_flush,
void *opaque)
{
aio_set_fd_handler(qemu_aio_context, fd, io_read, io_write, io_flush,
opaque);
qemu_set_fd_handler2(fd, NULL, io_read, io_write, opaque);
}
#ifdef CONFIG_POSIX
void qemu_aio_set_event_notifier(EventNotifier *notifier,
EventNotifierHandler *io_read,
AioFlushEventNotifierHandler *io_flush)
{
qemu_aio_set_fd_handler(event_notifier_get_fd(notifier),
(IOHandler *)io_read, NULL,
(AioFlushHandler *)io_flush, notifier);
}
#endif