aboutsummaryrefslogtreecommitdiff
path: root/main-loop.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-10-29 23:45:23 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-10-30 09:30:53 +0100
commitf627aab1ccea119fd94ca9e9df120cea6aab0c67 (patch)
treef1e4b3a2e763f40b665fdb9511e0da2f947f2fef /main-loop.c
parent9958c351eee5b34051fd8061fe24f490ceca1334 (diff)
aio: introduce AioContext, move bottom halves there
Start introducing AioContext, which will let us remove globals from aio.c/async.c, and introduce multiple I/O threads. The bottom half functions now take an additional AioContext argument. A bottom half is created with a specific AioContext that remains the same throughout the lifetime. qemu_bh_new is just a wrapper that uses a global context. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'main-loop.c')
-rw-r--r--main-loop.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/main-loop.c b/main-loop.c
index baefe413d1..40fdbd3770 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -26,6 +26,7 @@
#include "qemu-timer.h"
#include "slirp/slirp.h"
#include "main-loop.h"
+#include "qemu-aio.h"
#ifndef _WIN32
@@ -199,6 +200,8 @@ static int qemu_signal_init(void)
}
#endif
+static AioContext *qemu_aio_context;
+
int qemu_init_main_loop(void)
{
int ret;
@@ -218,6 +221,7 @@ int qemu_init_main_loop(void)
return ret;
}
+ qemu_aio_context = aio_context_new();
return 0;
}
@@ -481,7 +485,7 @@ int main_loop_wait(int nonblocking)
if (nonblocking) {
timeout = 0;
} else {
- qemu_bh_update_timeout(&timeout);
+ aio_bh_update_timeout(qemu_aio_context, &timeout);
}
/* poll any events */
@@ -510,3 +514,15 @@ int main_loop_wait(int nonblocking)
return ret;
}
+
+/* Functions to operate on the main QEMU AioContext. */
+
+QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque)
+{
+ return aio_bh_new(qemu_aio_context, cb, opaque);
+}
+
+int qemu_bh_poll(void)
+{
+ return aio_bh_poll(qemu_aio_context);
+}