Subversion hosting, CVS hosting, Trac hosting, Bugzilla hosting and software collaboration Providing hosted Subversion, CVS, Trac and Bugzilla repositories
 

August 4, 2008

Host CPU Frequency Control And Too-Fast Guest Clocks

Filed under: Operating Systems — Tags: , , — Greg Larkin @ 5:23 pm

Hi everyone,

Every now and again, a strange problem crops up with VMware Server. In this case, the VMs on one host began running with a very fast clock, even though the .vmx files contained the following line:

tools.syncTime = "TRUE"

Apparently, this setting helps keep the VM clock from slowing down too much, but it doesn’t do much when it’s going 1.5x faster than it should – whoa, Nelly! Running ntpdate every few seconds showed the clock resetting backwards 5-10 seconds each time. That’s going to play havoc with everything – log file messages, email timestamps, Makefiles and many other things.

I searched around Google for solutions, and 99% of the posts say “set kern.hz=100 in your /boot/loader.conf for a FreeBSD guest OS“. That’s great if your clock is slow, but it doesn’t fix this problem. A quick check showed that I had already added that setting a long time ago.

After more and more in-depth searching, a solution emerged. The host OS is RHEL4, and it enables CPU frequency scaling by default with the cpuspeed service. The idea behind this service is great, as it saves power, but it just wrecks the VMware timekeeping accuracy. Disabling the service fixes the problem for good:

# /etc/rc.d/init.d/cpuspeed stop
# cd /etc/rc.d/init.d/
# /sbin/chkconfig --del cpuspeed

Easy!

One final problem – the VM clock still runs fast until you reboot the host and the VMs on it. To get around the problem temporarily if you are running a high-availability service, add the following lines to your VM /etc/crontab file:

*/5 * * * * root /usr/sbin/ntpdate -s us.pool.ntp.org

I hope this posting makes the solution easier for someone else to find in the future!


Call me - Greg Larkin: error

Powered by WordPress