How to prevent relative time shift after restoring a snapshot in Parallels?

Discussion in 'Linux Virtual Machine' started by StefanW13, Aug 24, 2018.

  1. StefanW13

    StefanW13 Bit poster

    Messages:
    2
    (this copies my question on ServerFault which has been unanswered for three months now: https://serverfault.com/questions/9...shift-after-restoring-a-snapshot-in-parallels)

    Hi all,

    I am working with a web-based app on an Ubuntu (17.10 currently, but happened with older ubuntus similarly, but did not happen a few years ago with older Ubuntus and Parallels versions...) test/development system running in Parallels 13 (Version 13.3.2 (43368)). 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...)
    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

    So, no time sync service loaded.

    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?

    On the Ubuntu side, does anyone know what syncs the system time to the hwclock time and how to prevent that?

    On the Parallels side (Options > Synchronization is turned off), does anyone know, how I can prevent the relative time shift in the hwclock, so it is restored to the time when the snapshot was taken?

    Thank you in advance for any hints or any help whatsoever.

    Best,
    Stefan

     
  2. Dmitry@Parallels

    Dmitry@Parallels Parallels Team

    Messages:
    702
    Hi Stefan, please try the following:
    1. Shutdown your VM > locate the VM bundle > right click > Show Package Contents > open config.pvs file in TextEdit.app
    2. Locate 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>
    3. Save the changes, close the file, start the VM and check.
    Let me know if that helped for your workflow.
     
    StefanW13 likes this.
  3. StefanW13

    StefanW13 Bit poster

    Messages:
    2
    Hi Dimitry,

    thank you for your answer and sorry for the late reply.
    Yes, this change seems to fix my problem for newly created snapshots. For existing snapshots, the time shift still happened.
    I was able, however, to find out that I can make the same change to the <snapshotId>.pvc file for the respective snapshot and then it's working with those as well.
    Thank you so much! Have a great week.

    Best,
    Stefan
     
    Dmitry@Parallels likes this.
  4. Dmitry@Parallels

    Dmitry@Parallels Parallels Team

    Messages:
    702
    Was happy to help, Stefan, thank you, have a great week too!
     
  5. ChanningO

    ChanningO Bit poster

    Messages:
    1
    I was unclear on the first step thanks for the helpful information i needed to -
    1. Shutdown your VM > locate the VM bundle > right click > Show Package Contents > open config.pvs file in TextEdit.app.
    Thank Mitry
     
    Last edited by a moderator: Oct 27, 2018
  6. JoshuaJ5

    JoshuaJ5 Bit poster

    Messages:
    2
    How can I prevent time sync after a windows 10 restart? My vm changes its time to my host's time on restarts. I have tried reinstalling parallels tools but the setting within parallels "Windows 10" Configuration "more options" Time: "do not sync" do not seem to work. I have edited the config.pvs file to the settings below and several other variations but those do not seem to have an effect either.


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

Share This Page