Hi, Paolo
This is another patch arround RTC. Would you please have a review.
------------------separation-------------------------------------------------
MC146818 RTC: Get correct guest time when irq coalesced
When irq coalesce occurred, irq_coalesced actually store the seconds
that the time sawn in guest lags behind real guest virtual time.
At this time , if guest read cmos for virtual time, it shouldn't see
those delayed seconds, so we must substract irq_coalesced from guest
virtual time. Otherwise, after seconds queued in irq_coalesced applied
to guest, time in guest will go ahead of time it should be.
---
hw/timer/mc146818rtc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 1df17af..4cb8e5e 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -549,6 +549,8 @@ static void rtc_set_time(RTCState *s)
rtc_get_time(s, &tm);
s->base_rtc = mktimegm(&tm);
s->last_update = qemu_clock_get_ns(rtc_clock);
+ s->irq_coalesced = 0;
+ s->irq_reinject_on_ack_count = 0;
qapi_event_send_rtc_change(qemu_timedate_diff(&tm), &error_abort);
}
@@ -585,6 +587,7 @@ static void rtc_update_time(RTCState *s)
guest_nsec = get_guest_rtc_ns(s);
guest_sec = guest_nsec / NANOSECONDS_PER_SECOND;
+ guest_sec -= s->irq_coalesced;
gmtime_r(&guest_sec, &ret);
/* Is SET flag of Register B disabled? */
--
2.9.0.windows.1