• O
    qemu: Report the offset from host UTC for RTC_CHANGE event · e31b5cf3
    Osier Yang 提交于
    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'/>
    e31b5cf3
domain_conf.h 80.1 KB