[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 04/12] aio: provide platform-independent API
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 04/12] aio: provide platform-independent API |
Date: |
Mon, 16 Jul 2012 12:42:49 +0200 |
This adds to aio.c a platform-independent API based on EventNotifiers, that
can be used by the portable thread pool.
Signed-off-by: Paolo Bonzini <address@hidden>
---
aio.c | 9 +++++++++
qemu-aio.h | 19 ++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/aio.c b/aio.c
index 0a9eb10..417ceb4 100644
--- a/aio.c
+++ b/aio.c
@@ -97,6 +97,15 @@ int qemu_aio_set_fd_handler(int fd,
return 0;
}
+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);
+}
+
void qemu_aio_flush(void)
{
while (qemu_aio_wait());
diff --git a/qemu-aio.h b/qemu-aio.h
index bfdd35f..89c766c 100644
--- a/qemu-aio.h
+++ b/qemu-aio.h
@@ -16,6 +16,7 @@
#include "qemu-common.h"
#include "qemu-char.h"
+#include "event_notifier.h"
typedef struct BlockDriverAIOCB BlockDriverAIOCB;
typedef void BlockDriverCompletionFunc(void *opaque, int ret);
@@ -39,7 +40,7 @@ void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs,
void qemu_aio_release(void *p);
/* Returns 1 if there are still outstanding AIO requests; 0 otherwise */
-typedef int (AioFlushHandler)(void *opaque);
+typedef int (AioFlushEventNotifierHandler)(EventNotifier *e);
/* Flush any pending AIO operation. This function will block until all
* outstanding AIO operations have been completed or cancelled. */
@@ -53,6 +54,10 @@ void qemu_aio_flush(void);
* Return whether there is still any pending AIO operation. */
bool qemu_aio_wait(void);
+#ifdef CONFIG_POSIX
+/* Returns 1 if there are still outstanding AIO requests; 0 otherwise */
+typedef int (AioFlushHandler)(void *opaque);
+
/* Register a file descriptor and associated callbacks. Behaves very similarly
* to qemu_set_fd_handler2. Unlike qemu_set_fd_handler2, these callbacks will
* be invoked when using either qemu_aio_wait() or qemu_aio_flush().
@@ -65,5 +70,17 @@ int qemu_aio_set_fd_handler(int fd,
IOHandler *io_write,
AioFlushHandler *io_flush,
void *opaque);
+#endif
+
+/* Register an event notifier and associated callbacks. Behaves very similarly
+ * to event_notifier_set_handler. Unlike event_notifier_set_handler, these
callbacks
+ * will be invoked when using either qemu_aio_wait() or qemu_aio_flush().
+ *
+ * Code that invokes AIO completion functions should rely on this function
+ * instead of event_notifier_set_handler.
+ */
+void qemu_aio_set_event_notifier(EventNotifier *notifier,
+ EventNotifierHandler *io_read,
+ AioFlushEventNotifierHandler *io_flush);
#endif
--
1.7.10.4
- [Qemu-devel] [PATCH 00/12] Portable thread-pool/AIO, Win32 emulated AIO, Paolo Bonzini, 2012/07/16
- [Qemu-devel] [PATCH 01/12] event_notifier: enable it to use pipes, Paolo Bonzini, 2012/07/16
- [Qemu-devel] [PATCH 02/12] event_notifier: add Win32 implementation, Paolo Bonzini, 2012/07/16
- [Qemu-devel] [PATCH 04/12] aio: provide platform-independent API,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 03/12] main-loop: use event notifiers, Paolo Bonzini, 2012/07/16
- [Qemu-devel] [PATCH 05/12] aio: add Win32 implementation, Paolo Bonzini, 2012/07/16
- [Qemu-devel] [PATCH 06/12] linux-aio: use event notifiers, Paolo Bonzini, 2012/07/16
- [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore, Paolo Bonzini, 2012/07/16