@@ -3070,7 +3070,8 @@
# Emitted when the guest changes the RTC time.
#
# @offset: offset between base RTC clock (as specified by -rtc base), and
-# new RTC clock value
+# new RTC clock value. Note that value will be different depending
+# on clock chosen to drive RTC (specified by -rtc clock).
#
# Note: This event is rate-limited.
#
@@ -788,10 +788,10 @@ void qemu_system_vmstop_request(RunState state)
/***********************************************************/
/* RTC reference time/date access */
-static time_t qemu_ref_timedate(void)
+static time_t qemu_ref_timedate(QEMUClockType clock)
{
- time_t value = qemu_clock_get_ms(rtc_clock) / 1000;
- switch (rtc_clock) {
+ time_t value = qemu_clock_get_ms(clock) / 1000;
+ switch (clock) {
case QEMU_CLOCK_REALTIME:
value -= rtc_realtime_clock_offset;
/* no break */
@@ -811,7 +811,7 @@ static time_t qemu_ref_timedate(void)
void qemu_get_timedate(struct tm *tm, int offset)
{
- time_t ti = qemu_ref_timedate();
+ time_t ti = qemu_ref_timedate(rtc_clock);
ti += offset;
@@ -849,7 +849,7 @@ int qemu_timedate_diff(struct tm *tm)
break;
}
- return seconds - qemu_ref_timedate();
+ return seconds - qemu_ref_timedate(QEMU_CLOCK_HOST);
}
static void configure_rtc_base_datetime(const char *startdate)
Return value of qemu_timedate_diff(), used for calculation offset in QAPI 'RTC_CHANGE' event, restored to keep compatibility. Since it wasn't documented that difference is relative to host clock advancement, this change also adds important note to 'RTC_CHANGE' event description to highlight established implementation specifics. Signed-off-by: Artem Pisarenko <artem.k.pisarenko@gmail.com> --- qapi/misc.json | 3 ++- vl.c | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-)