Skip to content

Commit

Permalink
qemu-timer: fix off-by-one
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Edgar E. Iglesias <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
bonzini committed Mar 14, 2017
1 parent c0d24e7 commit 33bef0b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion util/qemu-timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 33bef0b

Please sign in to comment.