Skip to content

Clock unstable in KVM VMs

Jan Poctavek edited this page Dec 19, 2019 · 2 revisions

There's an issue in SmartOS kvm-clock implementation that with some CPUs under (un)certain circumstances causes an OS clock to jump forward and then quickly backwards.

$ date
Thu Dec 19 16:03:58 UTC 2019
$ date
Thu Dec 19 16:18:43 UTC 2019
$ date
Thu Dec 19 16:03:59 UTC 2019
$ date
Thu Dec 19 16:04:00 UTC 2019

One workaround is to set OS clocksource inside VM to HPET.

Quick example:

echo hpet > /sys/devices/system/clocksource/clocksource0/current_clocksource

How to persist it across reboots

sudo apt-get install sysfsutils
echo devices/system/clocksource/clocksource0/current_clocksource = hpet >> /etc/sysfs.d/clocksource.conf
sudo systemctl enable sysfsutils.service
sudo systemctl start sysfsutils.service
You can’t perform that action at this time.