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 ? Thanks. -- Jérôme
Dominique Ramaekers
2015-Sep-23 15:34 UTC
Re: [libvirt-users] Time syncing after VM suspend/resume
> -----Oorspronkelijk bericht----- > Van: libvirt-users-bounces@redhat.com [mailto:libvirt-users- > bounces@redhat.com] Namens Jérôme > Verzonden: woensdag 23 september 2015 15:03 > Aan: libvirt-users@redhat.com > Onderwerp: [libvirt-users] Time syncing after VM suspend/resume > > 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.Linux has two methods to use ntp: ntpdate: It will run once at boot time to sync time. (This is probably installed on your system) It will not run after suspend and resume... => no correction ntpd: Continuously adjusts time. The deamon also calculates the drift to anticipate differences. I use this one and works perfectly.> > 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 ? > > Thanks. > > -- > Jérôme > > _______________________________________________ > libvirt-users mailing list > libvirt-users@redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-users
Hi. Thanks for answering. Le 2015-09-23 17:34, Dominique Ramaekers a écrit :> Linux has two methods to use ntp: > > ntpdate: > It will run once at boot time to sync time. (This is probably > installed on your system) > It will not run after suspend and resume... => no correctionNope. This is not installed on my system.> ntpd: > Continuously adjusts time. The deamon also calculates the drift to > anticipate differences. > I use this one and works perfectly.This is installed (package ntp, Debian Jessie) and runs (I see /usr/sbin/ntpd in `ps aux`). But after more than 24h, the 2'17 gap between hwclock and date has not reduced a bit. I guess this is not the place for me to debug my ntp issues, apart maybe from what could be related to the virtualization itself. I understood from my readings (can't remember where precisely) that the fact that ntp wouldn't work was "normal", but if it is not, maybe trying to have it working is the way to go, rather than searching for a way to automatize guest-set-time. -- Jérôme
Michal Privoznik
2015-Sep-29 11:48 UTC
Re: [libvirt-users] Time syncing after VM suspend/resume
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