Skip to content

Commit

Permalink
qemu-timer: properly arm alarm timer for timers set by device initial…
Browse files Browse the repository at this point in the history
…ization

QEMU will hang when fed the following command-line

  qemu-system-mips -kernel vmlinux-2.6.32-5-4kc-malta -append "console=ttyS0" -nographic -net none

The -net none is important otherwise it seems some events are generated
causing the things to work. When it doesn't work, the guest hangs when
measuring the CPU frequency, after the following line:

  [    0.000000] NR_IRQS:256

Pressing a key on the serial port unblocks it, hinting that the problem
is due to the recent elimination of the 1 second timeout in the main
loop.

The problem is that because init_timer_alarm sets the timer's pending
flag to true, the alarm timer is never armed until after the first time
through the main loop.  Thus the bug started when QEMU started testing
the pending flag in qemu_mod_timer (commit 1828be3, more alarm timer
cleanup, 2010-03-10).

But actually, it isn't true at all that a timer is pending when the
alarm timer is created, and the real bug has been latent forever: the
fix is to remove the bogus setting of pending flag.

Reported-by: Aurelien Jarno <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Jan Kiszka <[email protected]>
Tested-by: Aurelien Jarno <[email protected]>
Tested-by: Michael Tokarev <[email protected]>
Signed-off-by: Aurelien Jarno <[email protected]>
(cherry picked from commit de18875)

Signed-off-by: Michael Roth <[email protected]>
  • Loading branch information
bonzini authored and mdroth committed Sep 5, 2012
1 parent 5a16dd9 commit f965d23
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions qemu-timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,11 +759,8 @@ int init_timer_alarm(void)
goto fail;
}

/* first event is at time 0 */
atexit(quit_timers);
t->pending = true;
alarm_timer = t;

return 0;

fail:
Expand Down

0 comments on commit f965d23

Please sign in to comment.