Re: [libvirt-users] Time syncing after VM suspend/resume

Michal Privoznik
2015-09-29T11:48:43Z

On 23.09.2015 15:03, Jérôme wrote:
> Hi all.
>
> When resuming guest after suspend, the time is wrong (because the guest
> doesn't know it has been suspended).
>
> Apparently, ntp running on the guest doesn't solve this. At least on
> Linux system. I read it works on Windows guests. I don't understand
why,
> so I'd appreciate a link to an explanation, but I understand it is out
> of scope for this list.
>
> The HW clock is correct and the guest agent is setup to use kvm-clock.
>
> Using the guest-set-time command does set the clock on the guest
> according to the host. But this is not triggered automatically on
> resume.
>
> I found discussions about this, even a patch proposal to call
> guest-set-time on resume, but all of this is one year old and I can't
> find any newer information.
>
>
http://serverfault.com/questions/334698/how-to-keep-time-on-resumed-kvm-guest-with-libvirt
> https://www.redhat.com/archives/libvirt-users/2014-October/msg00009.html
> https://www.redhat.com/archives/libvir-list/2014-February/msg00520.html
>
> Is there any fresher information I have missed ?

You can use "virsh resume $dom && virsh domtime --sync $dom"
which will
resume and resync the domain's clock from domain RTC. There were some
attempts to wrap these into a single API, however, I was persuaded that
it's a wrong idea. Wrapping two distinct operations into a single API is
always wrong.

Michal