[CentOS-virt] ntp on kvm

Tue Jul 28 16:17:01 UTC 2009
Ben Montanelli <montanelli at rivint.com>

Just curious, but on Xen if I "disable/break" the hwclock, Linux guests 
apparently have no problem using system time set by host (so far) and 
may be preventing "Time goes backwards" errors too.

e.g. In a CentOS pv guest as root:

cp /sbin/hwclock /sbin/hwclock.original
echo exit 0 > /sbin/hwclock

You may have to do that again on updates.

I'm also not sure of the source of this way for Xen pv guests and have 
not tried it , but is the same principle:

Prevent "hwclock" from being used
mv /sbin/hwclock /sbin/hwclock.dist
touch /sbin/hwclock
chmod +x /sbin/hwclock

Johnny Tan wrote:
> Nigel Metheringham wrote:
>> On 21 Jul 2009, at 00:41, Johnny Tan wrote:
>>> * Setting independent_wallclock=1 (or is that a xen-only thing)?
>> [Can't comment - I'm not a Xen user]
> Ok, I've done a bit more research, it seems the above is a 
> xen-only thing, so it's a no-go for KVM.
>>> * Passing kernel parameters? If so, which? The vmware KB
>>> mentions "notsc divider=10" -- is that vmware-specific?
> This is NOT vmware-specific. In fact, it seems like 
> divider=10 is the only thing that works. "notsc" (at least 
> by itself) does not help.
>>> * Just don't run ntpd on virtual guests? And let it get its
>>> time from the host.
> This does not work. On Xen, domU's apparently get their time 
> from the physical host, so it would work for Xen. But for 
> KVM, this does not seem to be the case.
>> My suggestions, from my position of complete ignorance on Xen (but I  
>> do quite a lot under VMware) is to tweak your kernel params  
>> (definitely divider, maybe some other tweaks depending on  how the  
>> virtual hardware appears, but on our systems we use clocksource=acpi_pm)
> Yes, divider works. I tried "clocksource=acpi_pm" -- it does 
> not work for our KVM guests, at least not by itself. (We're 
> using KVM-85.)
> In summary: For KVM guests, pass "divider=10" as kernel 
> option in grub.conf for your KVM guest, then use ntp to keep 
> time (also on your KVM guest).
> (p.s. However, I believe these issues are fixed with RHEL 5.4.)
>> Hope that this helps but you have opened a very messy can of worms here!
> I figured it'd be a can of worms, but a useful one. I'm 
> surprised it's not asked more often. I'm guessing most 
> people are using Xen still, where this is less of an issue.
> Thanks Nigel.
> johnny
> _______________________________________________
> CentOS-virt mailing list
> CentOS-virt at centos.org
> http://lists.centos.org/mailman/listinfo/centos-virt