kvmclock: clock should count only if vm is running
commit00f4d64ee76e873be881a82d893a591487aa7950
authorMarcelo Tosatti <mtosatti@redhat.com>
Tue, 18 Jun 2013 23:38:25 +0000 (18 20:38 -0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 3 Jul 2013 08:41:32 +0000 (3 10:41 +0200)
tree8175716bcd820616bc2fa278d98536de50aa2595
parentbd50cbaa0f34e47c5b82eba1cd1e88143018fa19
kvmclock: clock should count only if vm is running

kvmclock should not count while vm is paused, because:

1) if the vm is paused for long periods, timekeeping
math can overflow while converting the (large) clocksource
delta to nanoseconds.

2) Users rely on CLOCK_MONOTONIC to count run time, that is,
time which OS has been in a runnable state (see CLOCK_BOOTTIME).

Change kvmclock driver so as to save clock value when vm transitions
from runnable to stopped state, and to restore clock value from stopped
to runnable transition.

Cc: qemu-stable@nongnu.org
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/i386/kvm/clock.c