diff --git a/cpus.c b/cpus.c index 69e21858b8090bee35fa52ee4ea39efc20929816..e9da3bcb591ed16d798361fb8324ef59f51e9b4e 100644 --- a/cpus.c +++ b/cpus.c @@ -800,6 +800,11 @@ static void qemu_cpu_kick_rr_cpu(void) } while (cpu != atomic_mb_read(&tcg_current_rr_cpu)); } +void qemu_timer_notify_cb(void *opaque, QEMUClockType type) +{ + qemu_notify_event(); +} + static void kick_tcg_thread(void *opaque) { timer_mod(tcg_kick_vcpu_timer, qemu_tcg_next_kick()); diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 91cd8c8a84b6940d24a47d933ccc628fa0663763..1441b426cdfca9a44c57365ebb466892529730ec 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -59,7 +59,7 @@ struct QEMUTimerListGroup { }; typedef void QEMUTimerCB(void *opaque); -typedef void QEMUTimerListNotifyCB(void *opaque); +typedef void QEMUTimerListNotifyCB(void *opaque, QEMUClockType type); struct QEMUTimer { int64_t expire_time; /* in nanoseconds */ @@ -776,7 +776,7 @@ static inline int64_t qemu_soonest_timeout(int64_t timeout1, int64_t timeout2) * * Initialise the clock & timer infrastructure */ -void init_clocks(void); +void init_clocks(QEMUTimerListNotifyCB *notify_cb); int64_t cpu_get_ticks(void); /* Caller must hold BQL */ diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h index e521a91661312885b79262856b2224e9cd190309..a8053f17157bf837270d5aa2537df30a90e2472d 100644 --- a/include/sysemu/cpus.h +++ b/include/sysemu/cpus.h @@ -22,6 +22,7 @@ void dump_drift_info(FILE *f, fprintf_function cpu_fprintf); /* Unblock cpu */ void qemu_cpu_kick_self(void); +void qemu_timer_notify_cb(void *opaque, QEMUClockType type); void cpu_synchronize_all_states(void); void cpu_synchronize_all_post_reset(void); diff --git a/stubs/cpu-get-icount.c b/stubs/cpu-get-icount.c index 2e8b63b225b6b2256b92bd98bd74079dddbd12a9..0b7239d72148160ff9c117ba859180eb907ca4c6 100644 --- a/stubs/cpu-get-icount.c +++ b/stubs/cpu-get-icount.c @@ -2,6 +2,7 @@ #include "qemu-common.h" #include "qemu/timer.h" #include "sysemu/cpus.h" +#include "qemu/main-loop.h" int use_icount; @@ -9,3 +10,8 @@ int64_t cpu_get_icount(void) { abort(); } + +void qemu_timer_notify_cb(void *opaque, QEMUClockType type) +{ + qemu_notify_event(); +} diff --git a/tests/test-aio-multithread.c b/tests/test-aio-multithread.c index 8b0b40ec781910d4ee1c2ed28dca9441f5532baf..549d7849157ecab6d275844e8c573ed88d8ddd8c 100644 --- a/tests/test-aio-multithread.c +++ b/tests/test-aio-multithread.c @@ -438,7 +438,7 @@ static void test_multi_mutex_10(void) int main(int argc, char **argv) { - init_clocks(); + init_clocks(NULL); g_test_init(&argc, &argv, NULL); g_test_add_func("/aio/multi/lifecycle", test_lifecycle); diff --git a/tests/test-aio.c b/tests/test-aio.c index 2754f154ced7a6b3c192b90cefb3f16051020f94..54e20d6ab1257aa478dc415e3e3093346a2e3fdf 100644 --- a/tests/test-aio.c +++ b/tests/test-aio.c @@ -835,7 +835,7 @@ int main(int argc, char **argv) Error *local_error = NULL; GSource *src; - init_clocks(); + init_clocks(NULL); ctx = aio_context_new(&local_error); if (!ctx) { diff --git a/util/async.c b/util/async.c index 7d469eb857e61b513c0ccd657c2efbb710a95580..663e297e1f590375942d897c67fc2c94569b98ea 100644 --- a/util/async.c +++ b/util/async.c @@ -351,7 +351,7 @@ void aio_notify_accept(AioContext *ctx) } } -static void aio_timerlist_notify(void *opaque) +static void aio_timerlist_notify(void *opaque, QEMUClockType type) { aio_notify(opaque); } diff --git a/util/main-loop.c b/util/main-loop.c index 7efc229e3dfb47ca3a7f5ccbbd2df78dcc5341e7..4534c8930844cf3105414d94488a32d73348b48d 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -144,7 +144,7 @@ int qemu_init_main_loop(Error **errp) GSource *src; Error *local_error = NULL; - init_clocks(); + init_clocks(qemu_timer_notify_cb); ret = qemu_signal_init(); if (ret) { diff --git a/util/qemu-timer.c b/util/qemu-timer.c index ac993403aba533536c7ac1fcffb2d78aade8babf..dc3181e9b8e605a0a1f18a98be37468ea1c29167 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -122,7 +122,7 @@ void timerlist_free(QEMUTimerList *timer_list) g_free(timer_list); } -static void qemu_clock_init(QEMUClockType type) +static void qemu_clock_init(QEMUClockType type, QEMUTimerListNotifyCB *notify_cb) { QEMUClock *clock = qemu_clock_ptr(type); @@ -134,7 +134,7 @@ static void qemu_clock_init(QEMUClockType type) clock->last = INT64_MIN; QLIST_INIT(&clock->timerlists); notifier_list_init(&clock->reset_notifiers); - main_loop_tlg.tl[type] = timerlist_new(type, NULL, NULL); + main_loop_tlg.tl[type] = timerlist_new(type, notify_cb, NULL); } bool qemu_clock_use_for_deadline(QEMUClockType type) @@ -278,7 +278,7 @@ QEMUTimerList *qemu_clock_get_main_loop_timerlist(QEMUClockType type) void timerlist_notify(QEMUTimerList *timer_list) { if (timer_list->notify_cb) { - timer_list->notify_cb(timer_list->notify_opaque); + timer_list->notify_cb(timer_list->notify_opaque, timer_list->clock->type); } else { qemu_notify_event(); } @@ -635,11 +635,11 @@ void qemu_clock_unregister_reset_notifier(QEMUClockType type, notifier_remove(notifier); } -void init_clocks(void) +void init_clocks(QEMUTimerListNotifyCB *notify_cb) { QEMUClockType type; for (type = 0; type < QEMU_CLOCK_MAX; type++) { - qemu_clock_init(type); + qemu_clock_init(type, notify_cb); } #ifdef CONFIG_PRCTL_PR_SET_TIMERSLACK