From: Marcelo Tosatti <mtosatti@redhat.com>
To: Bruce Rogers <brogers@suse.com>
Cc: kvm@vger.kernel.org, Zamsden@gmail.com, glommer@redhat.com
Subject: Re: [PATCH 1/2] kvm: kvmclock: apply kvmclock offset to guest wall clock time
Date: Mon, 23 Jul 2012 21:44:54 -0300 [thread overview]
Message-ID: <20120724004454.GA3184@amt.cnet> (raw)
In-Reply-To: <5009368802000048000C6E42@novprvoes0310.provo.novell.com>
On Fri, Jul 20, 2012 at 10:44:24AM -0600, Bruce Rogers wrote:
> When a guest migrates to a new host, the system time difference from the
> previous host is used in the updates to the kvmclock system time visible
> to the guest, resulting in a continuation of correct kvmclock based guest
> timekeeping.
>
> The wall clock component of the kvmclock provided time is currently not
> updated with this same time offset. Since the Linux guest caches the
> wall clock based time, this discrepency is not noticed until the guest is
> rebooted. After reboot the guest's time calculations are off.
>
> This patch adjusts the wall clock by the kvmclock_offset, resulting in
> correct guest time after a reboot.
>
> Cc: Glauber Costa <glommer@redhat.com>
> Cc: Zachary Amsden <zamsden@gmail.com>
> Signed-off-by: Bruce Rogers <brogers@suse.com>
> ---
> arch/x86/kvm/x86.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index be6d549..14c290d 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -907,6 +907,10 @@ static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock)
> */
> getboottime(&boot);
>
> + if (kvm->arch.kvmclock_offset) {
> + struct timespec ts = ns_to_timespec(kvm->arch.kvmclock_offset);
> + boot = timespec_sub(boot, ts);
> + }
kvmclock_offset is signed (both directions). Must check the sign and use
_sub and _add_safe accordingly.
next prev parent reply other threads:[~2012-07-24 0:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-20 16:44 [PATCH 1/2] kvm: kvmclock: apply kvmclock offset to guest wall clock time Bruce Rogers
2012-07-24 0:44 ` Marcelo Tosatti [this message]
2012-08-01 20:21 ` Marcelo Tosatti
2012-08-01 20:36 ` Marcelo Tosatti
2012-08-01 20:53 ` Bruce Rogers
-- strict thread matches above, loose matches on Subject: below --
2012-07-19 15:21 Bruce Rogers
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=20120724004454.GA3184@amt.cnet \
--to=mtosatti@redhat.com \
--cc=Zamsden@gmail.com \
--cc=brogers@suse.com \
--cc=glommer@redhat.com \
--cc=kvm@vger.kernel.org \
/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