qemu-timer: fix off-by-one
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 3 Mar 2017 10:37:57 +0000 (11:37 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 14 Mar 2017 12:26:42 +0000 (13:26 +0100)
If the first timer is exactly at the current value of the clock, the
deadline is met and the timer should fire.  This fixes itself on the next
iteration of the loop without icount; with icount, however, execution
of instructions will stop exactly at the deadline and won't proceed.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
util/qemu-timer.c

index 6cf70b96f6336f97514fbfa402cedcc13a44ba1a..2f201512dff30772637f7196a6374b09fa27f7df 100644 (file)
@@ -199,7 +199,7 @@ bool timerlist_expired(QEMUTimerList *timer_list)
     expire_time = timer_list->active_timers->expire_time;
     qemu_mutex_unlock(&timer_list->active_timers_lock);
 
-    return expire_time < qemu_clock_get_ns(timer_list->clock->type);
+    return expire_time <= qemu_clock_get_ns(timer_list->clock->type);
 }
 
 bool qemu_clock_expired(QEMUClockType type)