@@ -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;
}
@@ -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);
@@ -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;
Add an AioContext pointer to QEMUClock so it knows what to notify on a timer change. Signed-off-by: Alex Bligh <alex@alex.org.uk> --- async.c | 1 + include/qemu/timer.h | 3 +++ qemu-timer.c | 12 ++++++++++++ 3 files changed, 16 insertions(+)