]> xenbits.xensource.com Git - libvirt.git/commit
qemu: Report the offset from host UTC for RTC_CHANGE event
authorOsier Yang <jyang@redhat.com>
Wed, 5 Jun 2013 10:32:59 +0000 (18:32 +0800)
committerOsier Yang <jyang@redhat.com>
Fri, 7 Jun 2013 06:45:08 +0000 (14:45 +0800)
commite31b5cf393857a6ca78d148c19393e28dfb39de1
treece24f6116313acad4b8b8000e180f27042078747
parentd60570b315d21f06bd28a869bbaf61e423d09569
qemu: Report the offset from host UTC for RTC_CHANGE event

https://bugzilla.redhat.com/show_bug.cgi?id=964177

Though both libvirt and QEMU's document say RTC_CHANGE returns
the offset from the host UTC, qemu actually returns the offset
from the specified date instead when specific date is provided
(-rtc base=$date).

It's not safe for qemu to fix it in code, it worked like that
for 3 years, changing it now may break other QEMU use cases.
What qemu tries to do is to fix the document:

http://lists.gnu.org/archive/html/qemu-devel/2013-05/msg04782.html

And in libvirt side, instead of replying on the value from qemu,
this converts the offset returned from qemu to the offset from
host UTC, by:

  /*
   * a: the offset from qemu RTC_CHANGE event
   * b: The specified date (-rtc base=$date)
   * c: the host date when libvirt gets the RTC_CHANGE event
   * offset: What libvirt will report
   */

  offset = a + (b - c);

The specified date (-rtc base=$date) is recorded in clock's def as
an internal only member (may be useful to exposed outside?).

Internal only XML tag "basetime" is introduced to not lose the
guest's basetime after libvirt restarting/reloading:

<clock offset='variable' adjustment='304' basis='utc' basetime='1370423588'/>
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_command.c
src/qemu/qemu_process.c