#define IOTHREAD_POLL_MAX_NS_DEFAULT 0ULL
#endif
-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;
* in this new thread uses glib.
*/
g_main_context_push_thread_default(iothread->worker_context);
- my_iothread = iothread;
+ qemu_set_current_aio_context(iothread->ctx);
iothread->thread_id = qemu_get_thread_id();
qemu_sem_post(&iothread->init_done_sem);
{
return IOTHREAD(object_resolve_path_type(id, TYPE_IOTHREAD, NULL));
}
+
+bool qemu_in_iothread(void)
+{
+ return qemu_get_current_aio_context() == qemu_get_aio_context() ?
+ false : true;
+}