19 VM Guest clock settings #
Keeping the correct time in a VM Guest is one of the more difficult aspects of virtualization. Keeping the correct time is especially important for network applications and is also a prerequisite to do a live migration of a VM Guest.
It is strongly recommended to ensure the VM Host Server keeps the correct time as well, for example, by using NTP (see Kapitel 38, Zeitsynchronisierung mit NTP for more information).
19.1 KVM: using kvm_clock
#
KVM provides a paravirtualized clock which is supported via the
kvm_clock
driver. It is strongly recommended to
use kvm_clock
.
Use the following command inside a VM Guest running Linux to check
whether the driver kvm_clock
has been loaded:
>
sudo
dmesg | grep kvm-clock [ 0.000000] kvm-clock: cpu 0, msr 0:7d3a81, boot clock [ 0.000000] kvm-clock: cpu 0, msr 0:1206a81, primary cpu clock [ 0.012000] kvm-clock: cpu 1, msr 0:1306a81, secondary cpu clock [ 0.160082] Switching to clocksource kvm-clock
To check which clock source is currently used, run the following command
in the VM Guest. It should output kvm-clock
:
>
cat /sys/devices/system/clocksource/clocksource0/current_clocksource
kvm-clock
and NTP
When using kvm-clock
, it is recommended to use NTP
in the VM Guest, as well. Using NTP on the VM Host Server is also
recommended.
19.1.1 Other timekeeping methods #
The paravirtualized kvm-clock
is currently not for
Windows* operating systems. For Windows*, use the Windows Time
Service Tools
for time synchronization.
19.2 Xen virtual machine clock settings #
With Xen 4, the independent wallclock setting
/proc/sys/xen/independent_wallclock
used for time
synchronization between Xen host and guest was removed. A new
configuration option tsc_mode
was introduced. It
specifies a method of using the time stamp counter
to synchronize the guest time with the Xen server. Its default value 0
handles the most hardware and software environments.
For more details on tsc_mode
, see the
xen-tscmode
manual page (man 7
xen-tscmode
).