2

I have an Ubuntu 9.10 server running as a KVM host with ntpd installed on it. The host system has the correct system time. At the moment I only have a single KVM guest, also Ubuntu 9.10 server. I do not have ntpd installed on it, and I just discovered the clock is about 6 minutes slow. It wasn't that way when it was installed about a month ago.

I thought that I only needed to keep the host clock synchronized and that the guests used the host clock. But maybe that is a memory from using OpenVZ. I believe the reasoning was related to only the host could modify the physical system clock.

Is running ntpd on both the host and all the guests the correct thing to do? Or is there something else that is preferred? How should I keep the guest clocks in sync?

4

Check what clocksource that you are using:

$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource

Check which ones that are available:

$ cat /sys/devices/system/clocksource/clocksource0/available_clocksource

If you got a "kvm-clock" entry in "available_clocksource" try to use it by setting kernel parameter:

clocksource=kvm-clock

Pretty good document here (general) why it's so tricky to get the clock right.

  • @rkthkr: looks like current_clocksource is already set to kvm-clock, but the guest is still minutes off from the host. – Tauren Apr 14 '10 at 15:28
0

I've encountered numerous problems with timekeeping in VMs, and across several different virtualization platforms, I've also had problems with the native Host-VM time sync tools.

My advice is to have an authoritative source of time that is based on a physical piece of hardware (in this case, your KVM host server) and sync your VMs using the standard OS time sync methods (in your case, ntpd) back to that server. Often a shorter resync interval is necessary if the vm guests are drifting excessively. In short, I think you're on the right track with ntpd.

As an example on VMWare, we found that the VMWare Tools time sync will only correct time if it drifts backwards on the VMs. It wouldn't correct the time if a VM got ahead of its host.

0

There are reports that kvm-clock causes time jumps (measured in hours) and may even cause system freezes. You may have to disable it, like so:

https://patchwork.kernel.org/patch/104597/ (either the patch itself, or LD_PRELOAD wrapper kvm-noclock).

  • Given that this comment is 8 years old,I don't really trust it it still truly an issue. – delimiter69 Jul 11 '18 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.