Author Topic: Time sync in VirtualBox guest off by 1 hour  (Read 8860 times)

Alex Taylor

  • Sr. Member
  • ****
  • Posts: 395
  • Karma: +5/-0
    • View Profile
Time sync in VirtualBox guest off by 1 hour
« on: July 16, 2021, 04:19:36 am »
I'm setting up an OS/2 (ArcaOS 5.0.6) guest in VirtualBox 6.1.22 running on Windows 10. 

I've installed the OS/2 Guest Additions, which (among other things) keeps the guest time synced to the host. Except... it insists on setting the guest's time to 1 hour behind the correct time. I assume that it's failing to take DST into account.

My guest TZ value is:

TZ=EST5EDT,3,2,0,7200,11,1,0,7200,3600

which is correct, and works fine for native OS/2 time sync programs like DAYTIME.

My host (Win) is set to the UTC-5 (Eastern US & Canada) zone with daylight saving time enabled. It does show the correct time (which is one hour ahead of what the guest shows).

Has anyone seen this before, and have any ideas how to fix it? This is a real problem. I've temporarily had to disable Additions entirely but that's obviously a terrible workaround.

rdunkle

  • Guest
Re: Time sync in VirtualBox guest off by 1 hour
« Reply #1 on: July 16, 2021, 09:34:19 am »
I often set the time sync of the VM to be independent of the host operating system.  To disable time sync:
Use a command line:
"C:\Program Files\Oracle\VirtualBox\VBoxManage" setextradata "arca_vm" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

Olafur Gunnlaugsson

  • Sr. Member
  • ****
  • Posts: 253
  • Karma: +6/-0
    • View Profile
Re: Time sync in VirtualBox guest off by 1 hour
« Reply #2 on: July 16, 2021, 11:26:54 am »
The VM reads and presents the system time as the host operating system presents it, this means that when you install a guest system you should always instruct the guest operating system not to adjust to daylight savings time, and not to use internet time correction/lookup. It is getting the correct time from the host anyway.

Otherwise both the systems will correct themselves during DST changeovers.

Alex Taylor

  • Sr. Member
  • ****
  • Posts: 395
  • Karma: +5/-0
    • View Profile
Re: Time sync in VirtualBox guest off by 1 hour
« Reply #3 on: July 17, 2021, 01:45:10 am »
I often set the time sync of the VM to be independent of the host operating system.  To disable time sync:
Use a command line:
"C:\Program Files\Oracle\VirtualBox\VBoxManage" setextradata "arca_vm" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

Unfortunately, I assume that will have much the same effect on the clock as disabling additions, meaning I can't set it up to sync when resuming the VM from pause state.  The nice thing about the additions is that the clock is constantly kept in sync and doesn't rely on running a remote sync tool at regular intervals like daytime.

It's not good to set up a remote sync tool to run every minute (or less), which is what would be needed to simulate this function in the guest.

The VM reads and presents the system time as the host operating system presents it, this means that when you install a guest system you should always instruct the guest operating system not to adjust to daylight savings time, and not to use internet time correction/lookup. It is getting the correct time from the host anyway.

Otherwise both the systems will correct themselves during DST changeovers.

OS/2 doesn't adjust to daylight saving time anyway. Of course, I can set daytime (if I run it) to take DST into account, but I wasn't running daytime while using the additions.

Olafur Gunnlaugsson

  • Sr. Member
  • ****
  • Posts: 253
  • Karma: +6/-0
    • View Profile
Re: Time sync in VirtualBox guest off by 1 hour
« Reply #4 on: July 18, 2021, 10:15:16 am »

OS/2 doesn't adjust to daylight saving time anyway. Of course, I can set daytime (if I run it) to take DST into account, but I wasn't running daytime while using the additions.

Mine does, what am I doing right?

Alex Taylor

  • Sr. Member
  • ****
  • Posts: 395
  • Karma: +5/-0
    • View Profile
Re: Time sync in VirtualBox guest off by 1 hour
« Reply #5 on: July 19, 2021, 03:40:54 am »
OS/2 doesn't adjust to daylight saving time anyway. Of course, I can set daytime (if I run it) to take DST into account, but I wasn't running daytime while using the additions.

Mine does, what am I doing right?

Presumably, you're running either an add-on program which does this, like DSTswitch, or a network time sync utility like CLKMGR or daytime.


In any case, there has been some progress in identifying the problem here. It seems the VBox additions are not the only affected program: https://github.com/bitwiseworks/libc/issues/109

Alex Taylor

  • Sr. Member
  • ****
  • Posts: 395
  • Karma: +5/-0
    • View Profile
Re: Time sync in VirtualBox guest off by 1 hour
« Reply #6 on: July 20, 2021, 03:44:14 am »
FWIW, Dmitry seems to have isolated the problem in libcn and has provided a test build (link in the quoted ticket) which appears to fix the problem here.