Xen HVM guest has severe clock drift
I am seeing a very severe clock drift on my Xen HVM VPS, rented from a hosting provider, so I don't have access to the dom0 system. I continuously run ntpd, but the clock drifts by as much as 30 seconds in 5 minutes and NTP cannot keep up. Has anyone experienced this?
Here are some details:
$ dmesg | grep clock
[ 0.160000] Measured 347 cycles TSC warp between CPUs, turning off TSC clock.
[ 0.396000] * this clock source is slow. Consider trying other clock sources
[ 0.550448] Switching to clocksource acpi_pm
[ 0.653135] rtc_cmos 00:05: setting system clock to 2011-03-09
02:45:40 UTC (1299638740)
$ cat /sys/devices/system/clocksource/clocksource0/available_clocksource
acpi_pm
$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
acpi_pm
Solution 1:
Add this line to the beginning of ntpd.conf:
tinker panic 0
That will help it keep up. Here is a link to the vmware best practices for timekeeping. I know you're not using vmware, but much of it should still be applicable.
Solution 2:
I recall that being an issue in guests some time back, but I couldn't recall how to get around it or fix it. So I googled and got this solution.
Uninstall openntpd
Then create a cron job with the following script.
#! /bin/bash
# This is a DIRTY hack to allow have time settings correctly on Xen guests
# [email protected]
echo 1 > /proc/sys/xen/independent_wallclock
ntpdate -b pool.ntp.org 0.debian.pool.ntp.org hora.roa.es
echo 0 > /proc/sys/xen/independent_wallclock
This is based on the advice from this link: http://blog.neutrino.es/2010/workaround-for-the-time-drift-issue-on-xen-keep-your-guests-synced/
Let me know if it works for you.
Solution 3:
On XEN 4.4.x server host, you can set the property tsc_mode="native" for your vm guest in file /etc/xen/vm.conf. Then, you can startup your vm and inside your vm os make a cronjob to perform a periodically synchronize time from an external ntp server.
This worked for me.