(the cover letter from V1 has been preserved here with small updates)
This patch series is all about:
https://bugzilla.redhat.com/show_bug.cgi?id=964177
which points out a flaw in qemu's RTC_CHANGE event when the base for
the guest's real time clock was given as an explicit date (rather than
as 'utc' or 'localtime'). Patch 3/4 explains what qemu does, and how
this patch fixes it (for the case of basis='utc' - an additional fix
to properly support basis='localtime', both for RTC_CHANGE and when
migrating across timezone/DST boundaries, is in Patch 4/4). (NB: the
flawed RTC_CHANGE offset has been in QEMU for so long now that it has
been documented and cannot be changed, so libvirt must work around it)
In the meantime, the fix for basis='localtime' required that we learn
the offset of localtime from utc, and that seems like something we
might want to do for other reasons, so Patch 1/4 adds a new utility
function do get that value that is (I hope!) POSIX compliant.
Since the original patch to fix this problem was incorrect, and the
new patch doesn't use any of its code, Patch 2/4 reverts that patch
completely.
Note that I have tested this patch by starting a domain with several
variations of <clock> parameters (in a locale that is currently at
UTC+3) and using the following short script to add and remove seconds
from the guest's RTC while watching both the <clock> line in
/var/run/libvirt/qemu/$domain.xml and the offset value sent in
libvirt's VIR_DOMAIN_EVENT_ID_RTC_CHANGE event (using
examples/domain-events/events-c/event-test from a libvirt source tree
that has been built). All cases appear to maintain the adjustment in
the status properly, as well as sending the correct value to any event
handler.
Here is the script I used to add/remove time from the RTC:
#!/bin/sh
old=$(hwclock --show | cut -f1-7 -d' ')
oldabs=$(date +%s --date="$old")
newabs=$(expr $oldabs + $1)
new=$(date --date="@$newabs")
echo Old: $oldabs $old
echo New: $newabs $new
hwclock --set --date="@$newabs"
Laine Stump (4):
util: new function virTimeLocalOffsetFromUTC
Revert "qemu: Report the offset from host UTC for RTC_CHANGE event"
qemu: fix RTC_CHANGE event for <clock offset='variable'
basis='utc'/>
qemu: fix <clock offset='variable' basis='localtime'/>
src/conf/domain_conf.c | 32 +++++++++++++-------------------
src/conf/domain_conf.h | 8 +++++---
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 43 ++++++++++++++++++++++++++++++-------------
src/qemu/qemu_process.c | 34 +++++++++++++++++++---------------
src/util/virtime.c | 41 ++++++++++++++++++++++++++++++++++++++++-
src/util/virtime.h | 5 +++--
tests/virtimetest.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 155 insertions(+), 53 deletions(-)
--
1.9.0