Clock synchronisation on kvm guests

6,641

Solution 1

Fundamentally the clock is going to drift some, I think there is a limit to what can be done at this time. You say that you don't run NTP in the guests but I think that is what you should do, just make sure that you aren't referencing the local clock (comment out server 127.x.x.x) and that tinker panic 0 is set so that it won't freak out if there are large jumps it has to correct for. Thats basically the guidelines from the VMWare timekeeping paper and I would guess largely applicable to a KVM setup as well.

Solution 2

The best option for a precise clock on the guest is to use the kvm-clock source (pvclock) which is synchronized with clock's host.

Solution 3

Here is a link to the VMware paper "Timekeeping in VMware Virtual Machines" (2008): http://www.vmware.com/pdf/vmware_timekeeping.pdf

Share:
6,641

Related videos on Youtube

DictatorBob
Author by

DictatorBob

Updated on September 17, 2022

Comments

  • DictatorBob
    DictatorBob almost 2 years

    I'm having trouble keeping the system clocks sync'd on a number of kvm guests. I've googled a fair bit, and found a lot of different options, many of which I've tried, to no avail. So here I am.

    ntpd is out of the question (the host system runs it and the clock is always correct, but if you run it on the guests, the clock goes way out of whack).

    The host is Ubuntu 9.04, kernel is 2.6.28-11-server The guests are Ubuntu 8.04, kernel 2.6.24-24-virtual

    Here's the clocksource situation on the host:

    # cat /sys/devices/system/clocksource/clocksource0/available_clocksource 
    tsc hpet acpi_pm jiffies 
    # cat /sys/devices/system/clocksource/clocksource0/current_clocksource 
    tsc
    

    And on the guest:

    # cat /sys/devices/system/clocksource/clocksource0/available_clocksource 
    tsc pit jiffies 
    # cat /sys/devices/system/clocksource/clocksource0/current_clocksource 
    pit 
    

    I've got "clock=pit divider=10" in the kernel boot parameters on the guest. It still drifts. We're not talking massive drifts, but there is some.

    Any suggestions? Has anyone had this problem and dealt with it?

  • DictatorBob
    DictatorBob over 14 years
    Hmm... I vaguely remember being told that when we did put ntp on the guests (pointing to a real ntp server, not localhost), the clock occasionally went completely haywire, setting the time backwards something like 20 years... That's all anecdotal though... maybe I'll give it another try myself and see what happens.
  • mattdm
    mattdm over 13 years
    This is a good answer for newer systems, but is not available on older ones.