mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
aio: introduce qemu_get_current_aio_context
This will be used by BDRV_POLL_WHILE (and thus by bdrv_drain) to choose how to wait for I/O completion. Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1477565348-5458-12-git-send-email-pbonzini@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com>
This commit is contained in:
parent
f11672dbc0
commit
e437016511
4 changed files with 36 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
|||
#include "qmp-commands.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/rcu.h"
|
||||
#include "qemu/main-loop.h"
|
||||
|
||||
typedef ObjectClass IOThreadClass;
|
||||
|
||||
|
@ -28,6 +29,13 @@ typedef ObjectClass IOThreadClass;
|
|||
#define IOTHREAD_CLASS(klass) \
|
||||
OBJECT_CLASS_CHECK(IOThreadClass, klass, TYPE_IOTHREAD)
|
||||
|
||||
static __thread IOThread *my_iothread;
|
||||
|
||||
AioContext *qemu_get_current_aio_context(void)
|
||||
{
|
||||
return my_iothread ? my_iothread->ctx : qemu_get_aio_context();
|
||||
}
|
||||
|
||||
static void *iothread_run(void *opaque)
|
||||
{
|
||||
IOThread *iothread = opaque;
|
||||
|
@ -35,6 +43,7 @@ static void *iothread_run(void *opaque)
|
|||
|
||||
rcu_register_thread();
|
||||
|
||||
my_iothread = iothread;
|
||||
qemu_mutex_lock(&iothread->init_done_lock);
|
||||
iothread->thread_id = qemu_get_thread_id();
|
||||
qemu_cond_signal(&iothread->init_done_cond);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue