I’ve got virtual machines (with Debian or occasionally *buntu guests, GNU/Linux) running in libvirt/qemu/kvm, and I have discovered the feature to pause/unpause a VM.

After unpausing (virsh resume), the guest clock is, obviously, off. How can I trigger a call to, say, /usr/sbin/rdate when the VM unpauses to do a one-shot update (openntpd will do the rest later)?

I have acpi-support-base installed on the guests so virsh shutdown works cleanly, but neither dmesg nor syslog show any events being triggert from pausing/unpausing.

1 Answer 1


Fortunately you found this obvious, wrong time on VM resume causes lots of confusion...

Ensure host time is accurate, configure hosts to use the same NTP servers that the rest of your devices do.

Install the qemu-guest-agent in the guest. Attach the host to the guest's VirtIO serial channel. Resume or virsh domtime now can control guest clock.

Or, load ptp_kvm kernel module into Linux guests. chrony can then use PTP to get precise time from the host.

echo ptp_kvm > /etc/modules-load.d/ptp_kvm.conf
echo "refclock PHC /dev/ptp0 poll 2" >> /etc/chrony.conf
  • Sorry, no, the guest clock is controlled by OpenNTPD in the guest. Changing that to host-controlled is out of scope (and possibly wrong).
    – mirabilos
    Feb 17, 2022 at 18:23
  • Feel free to write your own resume hook if you want to do something else. This host sync thing is how some libvirt scripts do it when SYNC_TIME=1 github.com/libvirt/libvirt/blob/v8.0.0/tools/… Feb 17, 2022 at 18:49
  • I can trigger it easily manually (ssh vmname sudo rdate -nv ntp.example.com), but I thought the VM was getting some (ACPI?) signals, like when virsh shutdown is run, and could do that itself.
    – mirabilos
    Feb 17, 2022 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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