mc146818rtc: Reset the periodic timer on load
commitae46e23964ad45d5bc72374040e87d8f52ac2178
authorPaul Donohue <qemu-devel@PaulSD.com>
Fri, 12 Jun 2015 14:10:14 +0000 (12 10:10 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 19 Jun 2015 10:27:14 +0000 (19 12:27 +0200)
treef33f22a3d54807a496cdc552736cb31f59c50b40
parentfb1a3a051d89975f26296163066bb0745ecca49d
mc146818rtc: Reset the periodic timer on load

When loading a VM from a snapshot or migration, clock changes can cause
the periodic timer to stall or loop rapidly.

qemu-timer has a reset notifier mechanism that is used to avoid timer
stalls or loops if the host clock changes while the VM is running when
using QEMU_CLOCK_HOST.  However, when loading a snapshot or migration,
qemu-timer is initialized and fires the reset notifier before
mc146818rtc is initialized and has registered its reset handler.  In
addition, this mechanism isn't used when using QEMU_CLOCK_REALTIME,
which might also change when loading a snapshot or migration.

To correct that problem, this commit resets the periodic timer after
loading from a snapshot or migration if the clock has either jumped
backward or has jumped forward by more than the clock jump limit that
is used by the reset notifier code in qemu-timer.

Signed-off-by: Paul Donohue <qemu-git@PaulSD.com>
Message-Id: <20150612141013.GE2749@TopQuark.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/timer/mc146818rtc.c