On Sat, Aug 10, 2013 at 12:21:27PM +0100, Alex Bligh wrote: > Currently we use a separate timer list group (main_loop_tlg) > for the main loop. This patch replaces this with a dummy AioContext > used just for timers in the main loop.
Things get interesting when we make main loop qemu_set_fd_handler() and timers just use AioContext. Basically, we are distilling out the main-loop.c stuff which is a low-level glib-style event loop from the AioContext fd handlers, timers, and BHs. This is a good step in that direction. I'm in favor of this although it current really is still a bit of a hack. > @@ -486,6 +499,20 @@ void init_clocks(void) > qemu_clock_init(type); > } > > + /* Make a dummy context for timers in the main loop. > + * > + * This context should not call the AioContext's > + * supplied notifier function (which calls > + * aio_notify) as it needs to call qemu_notify() > + * instead, as there's nothing actually using the > + * AioContext. This is a bit of a hack. > + */ > + qemu_dummy_timer_ctx = aio_context_new(); > + for (type = 0; type < QEMU_CLOCK_MAX; type++) { > + qemu_dummy_timer_ctx->tlg[type]->notify_cb = NULL; > + qemu_dummy_timer_ctx->tlg[type]->notify_opaque = NULL; > + } > + IIRC your previous patch series has something like: if (timer_list->notify_cb == NULL) { qemu_notify_event(); } else { timer_list->notify_cb(timer_list->notify_opaque); } So this should work.