Add an AioContext pointer to QEMUClock so it knows what to notify on a timer change.
Signed-off-by: Alex Bligh <a...@alex.org.uk> --- async.c | 1 + include/qemu/timer.h | 3 +++ qemu-timer.c | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/async.c b/async.c index 0d41431..2968c68 100644 --- a/async.c +++ b/async.c @@ -217,6 +217,7 @@ AioContext *aio_context_new(void) (EventNotifierHandler *) event_notifier_test_and_clear, NULL); ctx->clock = qemu_new_clock(QEMU_CLOCK_REALTIME); + qemu_clock_set_ctx(ctx->clock, ctx); return ctx; } diff --git a/include/qemu/timer.h b/include/qemu/timer.h index a1f2ac8..29817ab 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -16,6 +16,7 @@ #define QEMU_CLOCK_HOST 2 typedef struct QEMUClock QEMUClock; +typedef struct AioContext AioContext; typedef void QEMUTimerCB(void *opaque); /* The real time clock should be used only for stuff which does not @@ -38,6 +39,8 @@ extern QEMUClock *host_clock; QEMUClock *qemu_new_clock(int type); void qemu_free_clock(QEMUClock *clock); +AioContext *qemu_clock_get_ctx(QEMUClock *clock); +void qemu_clock_set_ctx(QEMUClock *clock, AioContext * ctx); int64_t qemu_get_clock_ns(QEMUClock *clock); int64_t qemu_clock_has_timers(QEMUClock *clock); int64_t qemu_clock_expired(QEMUClock *clock); diff --git a/qemu-timer.c b/qemu-timer.c index 714bc92..6efd1b4 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -29,6 +29,7 @@ #include "hw/hw.h" #include "qemu/timer.h" +#include "block/aio.h" #ifdef CONFIG_POSIX #include <pthread.h> #endif @@ -50,6 +51,7 @@ struct QEMUClock { QEMUTimer *active_timers; + AioContext *ctx; NotifierList reset_notifiers; int64_t last; @@ -252,6 +254,16 @@ void qemu_free_clock(QEMUClock *clock) g_free(clock); } +AioContext *qemu_clock_get_ctx(QEMUClock *clock) +{ + return clock->ctx; +} + +void qemu_clock_set_ctx(QEMUClock *clock, AioContext * ctx) +{ + clock->ctx = ctx; +} + void qemu_clock_enable(QEMUClock *clock, bool enabled) { bool old = clock->enabled; -- 1.7.9.5