Re: Synchronized time with kvm_clock

John Buswell
2010-04-26T14:32:53Z

Alex,

You don't need to run ntp on each guest. You can enable rtc support in
the guest kernel and on the hypervisor. Run ntp client on the hypervisor
via cron, and use hwclock -w on the hypervisor after you run ntp, to
sync the hardware clock to the system clock (which is now updated by
ntpdate). On the guests, periodically run hwclock -s to set the system
clock from the hw clock.

This seems to work extremely well, the clocksource on the guests as
kvm_clock, and as long as you have the clocksource as hpet or acpi_pm on
the hypervisor, there doesn't seem to be any problems with keeping time.

The only thing I've noticed is that when you reboot, the very first
guest will have the wrong time on boot, so the uptime is messed up.

Regards

Alex Hermann wrote:
> On Monday 26 April 2010, I wrote:
>
>> host:
>> cat /sys/devices/system/clocksource/clocksource0/current_clocksource
>> tsc
>>
>> guest:
>> cat /sys/devices/system/clocksource/clocksource0/current_clocksource
>> kvm-clock
>>
>
> Forgotten some info which might be essential:
>
> Kernel (host and guest): 2.6.32-trunk-amd64
> qemu-kvm: 0.12.3+dfsg-4
>
>
> Please keep me on the cc, I'm not on the list.
>

--
John Buswell
CEO, Carbon Mountain LLC