Chapter 11. KVM guest timing management
KVM uses the constant Time Stamp Counter (TSC) feature of many modern CPUs. Some CPUs do not have a constant Time Stamp Counter which will affect the way guests running on KVM keep time. Guest's running without accurate timekeeping can have serious affects on some networked applications as your guest will run faster or slower than the actual time.
Guests can have several problems caused by inaccurate clocks and counters:
Clocks can fall out of synchronization with the actual time which invalidates sessions and affects networks.
Guests with slower clocks may have issues migrating.
Guests may stop or crash.
These problems exist on other virtualization platforms and timing should always be tested.
NTP
The Network Time Protocol (NTP) daemon should be running on the host and the guests. Enable the ntpd
service:
# service ntpd start
Add the ntpd service to the default startup sequence:
# chkconfig ntpd on
Using the ntpd
service should minimize the affects of clock skew in all cases.
Your CPU has a constant Time Stamp Counter if the constant_tsc
flag is present. To determine if your CPU has the constant_tsc
flag run the following command:
$ cat /proc/cpuinfo | grep constant_tsc
If any output is given your CPU has the constant_tsc
bit. If no output is given follow the instructions below.
Systems without constant time stamp counters require additional configuration. Power management features interfere with accurate time keeping and must be disabled for guests to accurately keep time with KVM.
Note
These instructions are for AMD revision F cpus only.
If the CPU lacks the
constant_tsc
bit, disable all power management features (
BZ#513138). Each system has several timers it uses to keep time. The TSC is not stable on the host, which is sometimes caused by
cpufreq
changes, deep C state, or migration to a host with a faster TSC. To stop deep C states, which cam stop the TSC, add "
processor.max_cstate=1
" to the kernel boot options in grub on the host:
term Fedora (vmlinuz-2.6.29.6-217.2.3.fc11)
root (hd0,0)
kernel /vmlinuz-vmlinuz-2.6.29.6-217.2.3.fc11 ro root=/dev/VolGroup00/LogVol00 rhgb quiet processor.max_cstate=1
Disable cpufreq
(only necessary on hosts without the constant_tsc
) by editing the /etc/sysconfig/cpuspeed
configuration file and change the MIN_SPEED
and MAX_SPEED
variables to the highest frequency available. Valid limits can be found in the /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies
files.
For certain Red Hat Enterprise Linux guests, additional kernel parameters are required. These parameters can be set by appending them to the end of the /kernel line in the /boot/grub/grub.conf file of the guest.
The table below lists versions of Red Hat Enterprise Linux and the parameters required for guests on systems without a constant Time Stamp Counter.
Red Hat Enterprise Linux | Additional guest kernel parameters |
---|
5.4 AMD64/Intel 64 with the para-virtualized clock | Additional parameters are not required |
5.4 AMD64/Intel 64 without the para-virtualized clock | divider=10 notsc lpj=n |
5.4 x86 with the para-virtualized clock | Additional parameters are not required |
5.4 x86 without the para-virtualized clock | divider=10 clocksource=acpi_pm lpj=n |
5.3 AMD64/Intel 64 | divider=10 notsc |
5.3 x86 | divider=10 clocksource=acpi_pm |
4.8 AMD64/Intel 64 | notsc divider=10 |
4.8 x86 | clock=pmtmr divider=10 |
3.9 AMD64/Intel 64 | Additional parameters are not required |
3.9 x86 | Additional parameters are not required |
Enable the para-virtualized clock on Window guests by editing the boot parameters. Windows boot settings are stored in the boot.ini file. To enable the para-virtualized clock add the following line:
/use pmtimer