From: Paolo Bonzini <pbonzini@redhat.com>
To: "zhongjun@sangfor.com.cn" <zhongjun@sangfor.com.cn>,
qemu-devel <qemu-devel@nongnu.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2]MC146818 RTC: coordinate guest clock base to destination host after migration
Date: Mon, 26 Sep 2016 09:07:05 +0200 [thread overview]
Message-ID: <bb1fc6a0-58cb-cfd5-4e33-fa78bf12b703@redhat.com> (raw)
In-Reply-To: <20160926113748142744182@sangfor.com.cn>
On 26/09/2016 05:37, zhongjun@sangfor.com.cn wrote:
> Hi, Paolo
> This is a simplified patch according to your advice. Would you please reiview it again.
>
>
> ------------------------------------separation line--------------------------------------------
>
>
> MC146818 RTC: coordinate guest clock base to destination host after migration
>
> 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 <zhongjun@sangfor.com.cn>
> ---
> hw/timer/mc146818rtc.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
> index ea625f2..1df17af 100644
> --- a/hw/timer/mc146818rtc.c
> +++ b/hw/timer/mc146818rtc.c
> @@ -717,15 +717,20 @@ 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) {
> - rtc_set_time(s);
> - s->offset = 0;
> - check_update_timer(s);
> - }
> + rtc_set_time(s);
> + s->offset = 0;
> + check_update_timer(s);
This is wrong if rtc_clock is not QEMU_CLOCK_REALTIME.
Paolo
next prev parent reply other threads:[~2016-09-26 7:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <201609201519044580729@sangfor.com.cn>
2016-09-20 8:17 ` [Qemu-devel] [PATCH]MC146818 RTC: coordinate guest clock base to destination host after migration Paolo Bonzini
2016-09-20 8:34 ` zhongjun
2016-09-20 8:38 ` Paolo Bonzini
2016-09-20 12:54 ` zhongjun
2016-09-20 13:12 ` Paolo Bonzini
2016-09-21 7:36 ` zhongjun
2016-09-21 9:38 ` zhongjun
2016-09-21 15:15 ` Paolo Bonzini
2016-09-22 7:00 ` zhongjun
2016-09-26 3:37 ` [Qemu-devel] [PATCH v2]MC146818 " zhongjun
2016-09-26 7:07 ` Paolo Bonzini [this message]
2016-09-26 8:42 ` [Qemu-devel] [PATCH v3]MC146818 " zhongjun
2016-09-26 8:59 ` Paolo Bonzini
2016-09-26 10:54 ` [Qemu-devel] [PATCH v4]MC146818 " zhongjun
2016-09-26 11:22 ` Paolo Bonzini
2016-09-26 4:37 ` [Qemu-devel] [PATCH]MC146818 RTC: Get correct guest time when irq coalesced zhongjun
2016-09-26 7:14 ` Paolo Bonzini
2016-09-27 3:13 ` zhongjun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bb1fc6a0-58cb-cfd5-4e33-fa78bf12b703@redhat.com \
--to=pbonzini@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zhongjun@sangfor.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).