mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
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>
This commit is contained in:
parent
9958c351ee
commit
f627aab1cc
11 changed files with 119 additions and 72 deletions
18
main-loop.c
18
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue