[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/39] MC146818 RTC: coordinate guest clock base to d
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 02/39] MC146818 RTC: coordinate guest clock base to destination host after migration |
Date: |
Fri, 7 Oct 2016 18:57:26 +0200 |
From: Junlian Bell <address@hidden>
qemu tracks guest time based on vector [base_rtc, last_update], in which
last_update stands for a monotonic tick which is actually uptime of the
host.
according to rtc implementation codes of recent releases and upstream,
after
migration, the time base vector [base_rtc, last_update] isn't updated to
coordinate with the destionation host, ie. qemu doesnt update last_update
to
uptime of the destination host.
what problem have we got because of this bug? after migration, guest time
may
jump back to several days ago, that will make some critical business
applications,
such as lotus notes, malfunction.
this patch is trying to fix the problem. first, when vmsave in progress,
we
rtc_update_time to refresh time stamp in cmos array, then during
vmrestore,
we rtc_set_time to update qemu base_rtc and last_update variable according
to time
stamp in cmos array.
Signed-off-by: Junlian Bell <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/timer/mc146818rtc.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index ea625f2..da209d0 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -717,11 +717,18 @@ static void rtc_set_date_from_host(ISADevice *dev)
rtc_set_cmos(s, &tm);
}
+static void rtc_pre_save(void *opaque)
+{
+ RTCState *s = opaque;
+
+ rtc_update_time(s);
+}
+
static int rtc_post_load(void *opaque, int version_id)
{
RTCState *s = opaque;
- if (version_id <= 2) {
+ if (version_id <= 2 || rtc_clock == QEMU_CLOCK_REALTIME) {
rtc_set_time(s);
s->offset = 0;
check_update_timer(s);
@@ -764,6 +771,7 @@ static const VMStateDescription vmstate_rtc = {
.name = "mc146818rtc",
.version_id = 3,
.minimum_version_id = 1,
+ .pre_save = rtc_pre_save,
.post_load = rtc_post_load,
.fields = (VMStateField[]) {
VMSTATE_BUFFER(cmos_data, RTCState),
--
2.7.4
- [Qemu-devel] [PULL 00/39] Misc patches for 2016-10-07, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 02/39] MC146818 RTC: coordinate guest clock base to destination host after migration,
Paolo Bonzini <=
- [Qemu-devel] [PULL 01/39] hw/iommu: Fix problems reported by Coverity scan, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 03/39] hw/misc/edu: support MSI interrupt, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 04/39] intc: add an interface to gather statistics/informations on interrupt controllers, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 05/39] intc/i8259: implement InterruptStatsProvider interface, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 06/39] intc/slavio_intctl: implement InterruptStatsProvider interface, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 07/39] intc/lm32_pic: implement InterruptStatsProvider interface, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 08/39] intc: make HMP 'info irq' and 'info pic' commands use InterruptStatsProvider interface, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 09/39] intc: make HMP 'info irq' and 'info pic' commands available on all targets, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 10/39] atomic.h: fix __SANITIZE_THREAD__ build, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 11/39] atomic.h: comment on use of atomic_read/set, Paolo Bonzini, 2016/10/07