From ac70aafc28bec4d1014082f0c6659a368c5a95bd Mon Sep 17 00:00:00 2001 From: Alex Bligh Date: Wed, 21 Aug 2013 16:02:57 +0100 Subject: aio / timers: Use all timerlists in icount warp calculations Notify all timerlists derived from vm_clock in icount warp calculations. When calculating timer delay based on vm_clock deadline, use all timerlists. For compatibility, maintain an apparent bug where when using icount, if no vm_clock timer was set, qemu_clock_deadline would return INT32_MAX and always set an icount clock expiry about 2 seconds ahead. NB: thread safety - when different timerlists sit on different threads, this will need some locking. Signed-off-by: Alex Bligh Signed-off-by: Stefan Hajnoczi --- qemu-timer.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'qemu-timer.c') diff --git a/qemu-timer.c b/qemu-timer.c index 746ba8b7e1..b56bfde706 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -392,6 +392,22 @@ int64_t qemu_clock_deadline_ns(QEMUClock *clock) return timerlist_deadline_ns(clock->main_loop_timerlist); } +/* Calculate the soonest deadline across all timerlists attached + * to the clock. This is used for the icount timeout so we + * ignore whether or not the clock should be used in deadline + * calculations. + */ +int64_t qemu_clock_deadline_ns_all(QEMUClock *clock) +{ + int64_t deadline = -1; + QEMUTimerList *timer_list; + QLIST_FOREACH(timer_list, &clock->timerlists, list) { + deadline = qemu_soonest_timeout(deadline, + timerlist_deadline_ns(timer_list)); + } + return deadline; +} + QEMUClock *timerlist_get_clock(QEMUTimerList *timer_list) { return timer_list->clock; -- cgit v1.2.1