Debian – How to Prevent Time Drift in a Guest on CentOS KVM Host?

clockdebiankvm

I know I can install ntp in the guest, but my confused understanding of what I've Googled so far suggests this shouldn't be necessary.

The Host is CentOS 6.3 and guest is Debian Wheezy, which seems to be using the kvm clock as a time source:

# cat /sys/devices/system/clocksource/clocksource0/current_clocksource
kvm-clock

Is there something special I need to do to make the guest use the host clock?

Best Answer

The guest has no direct access to the host clock. Instead, it uses kvm-clock which points to a memory region updated by the host, from the host's clock. As such, the guest is using the host clock. The issue is that this memory region isn't updated constantly, it's only updated when there's a VM 'event', and as such, guests can drift and then lurch back to the correct time.

The general advice, as far as I can see, is ensure the VM is doing something on a regular basis, so that it re-reads the host clock on a regular basis.

Some sources,

Related Question