Re: [PATCH 1/2] kvm: kvmclock: apply kvmclock offset to guest wall clock time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 >>> On 8/1/2012 at 02:21 PM, Marcelo Tosatti <mtosatti@xxxxxxxxxx> wrote: 
> On Mon, Jul 23, 2012 at 09:44:54PM -0300, Marcelo Tosatti wrote:
>> 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@xxxxxxxxxx>
>> > Cc: Zachary Amsden <zamsden@xxxxxxxxx>
>> > Signed-off-by: Bruce Rogers <brogers@xxxxxxxx>
>> > ---
>> >  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.
> 
> Your patch is correct, sorry (applied to master).
> 
> Patch 2 still makes no sense.

I'm fine with dropping the second patch.

Thanks

Bruce

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux