3

I am working with a web-based app on an Ubuntu test/development system running in Parallels. At specific dates and times (taken from the system time) some events happen and things are changed in the database. (e.g., a user account is locked, if password was not changed for a certain time, or the status of an object is changed, if a deadline is passed etc.)

To be able to test specific scenarios, I work with snapshots in Parallels to store the state of the system at several key points in time. It can happen that after several months I need to return to a specific point in time to test a specific scenario on the state back then.

My problem is that after restoring the snapshot, the system date is as I want it to be (namely equal to the datetime when the snapshot was taken).

But after several seconds to minutes, the system time changes to some point in time between the real time and the expected (snapshot) time. I have the impression that it is set to the time that has passed relatively. E.g., if I took the snapshot on 2018-02-01 (real time) with the system date of the Ubuntu guest being 2018-01-01 (guest time) and I restore the snapshot on 2018-03-01 (real time), then the Ubuntu guest will eventually be set to 2018-02-01 (guest time) after some minutes.

What I have done so far:

  • Switched off Parallels time sync (according to https://kb.parallels.com/113271)
  • Uninstalled ntp and ntpdate
  • Disabled Automatic Date&Time and Automatic Timezone in Ubuntu desktop settings

The problem seems to be related to hwclock. As an example, I have restored a snapshot from 2018-01-25 (guest time) yesterday, on 2018-05-25 (real time). I executed (immediately after restoring the snapshot):

date ; \
hwclock --show ; \
date -s 2018-01-26 ; \
hwclock --systohc ; \
hwclock --set --date 2018-01-26 ; \
hwclock --show ;

This results in the following output:

Thu Jan 25 18:17:49 CET 2018
2018-03-09 01:01:27.249216+0100
Fri Jan 26 00:00:00 CET 2018
2018-03-09 01:01:27.775701+0100

If I wait some time, the system time will eventually change to the hwclock time - I have not found out why. I also don't understand why the attempts to set the hwclock time does not work (no error is shown, but the new time is ignored...)

Finally, I also have checked the syslog but there is no hint about the changed date. It just prints an entry for the old date and the next entry is with the new date, no indication what caused the date change.

What have I missed?


P.S.

This is the output of systemctl | grep time

rtkit-daemon.service        loaded active running   RealtimeKit Scheduling Policy Service     
systemd-timedated.service   loaded active running   Time & Date Service                                               
timers.target               loaded active active    Timers                                                            
anacron.timer               loaded active running   Trigger anacron every hour                                        
apt-daily-upgrade.timer     loaded active waiting   Daily apt upgrade and clean activities                            
apt-daily.timer             loaded active waiting   Daily apt download activities                                     
motd-news.timer             loaded active elapsed   Message of the Day                                                
snapd.refresh.timer         loaded active waiting   Timer to automatically refresh installed snaps                    
systemd-tmpfiles-clean.timer loaded active waiting   Daily Cleanup of Temporary Directories                            

1 Answers1

0

Thanks to the Parallels User Forum, I was able to solve this issue.

  1. Shutdown the VM
  2. Locate the VM bundle > right click > Show Package Contents > open config.pvs file in a text editor
  3. Locate the TimeSync key and edit as follows:

<TimeSync SyncInterval_patch="1" dyn_lists="">
<Enabled>0</Enabled>
<SyncInterval>60</SyncInterval>
<KeepTimeDiff>0</KeepTimeDiff>
<SyncHostToGuest>0</SyncHostToGuest>
<SyncTimezoneDisabled>1</SyncTimezoneDisabled>
</TimeSync>

  1. Save the changes and close the file.
  2. Start the VM again. All snapshots afterwards will not have the time sync problem anymore.

If you need to make it work with an existing snapshot, then locate the Snapshots folder within the VM bundle (where the config.pvs file was located). There you can find the snapshot files. To find the correct snapshot you can use the creation date and the screenshots in the PNG files as a hint. The {id}.pvc file contains the snapshot-specific copy of the config.pvs file. Make the same adjustment as in Step 3. above.

Now the time shift should be disabled for that snapshot as well.

Thanks to Dmitry at Parallels Support for the answer in the Parallels Support Forum.