Skip to content

Let RTC follow backward jumps of host clock immediately

Jan Kiszka qemu-devel 2 versions – Applied

Status from this message: Applied. Thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 1 replyApplied
  2. v13 patches 0 repliesSuperseded

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/3notifier: Pass data argument to callbackhw/fw_cfg.c input.c migration.c +9 more+22 -220 replies
2/3qemu-timer: Introduce clock reset notifierqemu-timer.c qemu-timer.h+33 -10 replies
3/3mc146818rtc: Handle host clock resetshw/mc146818rtc.c+20 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 0/3] Let RTC follow backward jumps of host clock immediately

Just noticed that this issue is still unfixed because my series was somehow forgotten. So I've rebased it over current master, refactored it to use the generic Notifier infrastructure and renamed it to "clock reset notifier" to avoid confusion with icount related "warping". Please review / apply before 0.15-rc0, it fixes a relevant issue.

Original series description:

By default, we base the mc146818 RTC on the host clock (CLOCK_REALTIME). This works fine if only the frequency of the host clock is tuned (e.g. by NTP) or if it is set to a future time. However, if the host is tuned backward, e.g. because NTP obtained the correct time after the guest was already started or the admin decided to tune the local time, we see an unpleasant effect in the guest: The RTC will stall for the period the host clock is set back. We identified that one prominent guest affected by this is Windows which relies on the periodic RTC interrupt for time keeping.

This series address the issue by detecting those warps and providing a callback mechanism to device models. The RTC is enabled to update its timers and register content immediately. Tested successfully both with hwclock in a Linux guest and by monitoring the Windows clock while fiddling with the host time.

Note that if this kind of RTC adjustment is not wanted, the user is still free to decouple the RTC from the host clock and base it on the VM clock - just like before.

Jan Kiszka (3):
notifier: Pass data argument to callback
qemu-timer: Introduce clock reset notifier
mc146818rtc: Handle host clock resets

 hw/fw_cfg.c      |    2 +-
 hw/mc146818rtc.c |   20 ++++++++++++++++++++
 input.c          |    2 +-
 migration.c      |   12 ++++++------
 notify.c         |    4 ++--
 notify.h         |    4 ++--
 qemu-timer.c     |   29 ++++++++++++++++++++++++++++-
 qemu-timer.h     |    5 +++++
 ui/sdl.c         |    2 +-
 ui/spice-core.c  |    2 +-
 ui/spice-input.c |    4 ++--
 ui/vnc.c         |    4 ++--
 usb-linux.c      |    2 +-
 vl.c             |    4 ++--
 xen-all.c        |    2 +-
 15 files changed, 75 insertions(+), 23 deletions(-)