Wrong System Time in OS/2 Guest
Wrong System Time in OS/2 Guest
Hello,
there is a problem with the system clock in my OS/2 guest.
I am running VirtualBox 6.1.24 on a Windows 10 (version 20H2) host. The system clock is running at local time with timezone "Europe/Berlin" and automatically switching to DST enabled. Actually my local time is GMT+2h, without DST it is GMT+1h
The guest is OS/2 Version 4.50 with guest additions 6.1.24 installed. Since the system clock on OS/2 is always running at local time it should be the same time as on the host.
The TZ environment variable for the guest is set to
TZ=MET-1DST,3,-1,0,7200,10,-1,0,10800,3600
meaning that the standard time zone is Middle European Time (MET) with a time zone offset of -1 (1h east of GMT). There is a daylight saving time (DST) starting in March (3) on the last (-1) sunday (0) at 2:00 (7200 sec after midnight). It is ending in October (10) on the last (-1) sunday (0) at 3:00 (10800 sec after midnight), and the offset to the standard time is 1h (3600s).
This is working for most OS/2 applications and also e.g. with gcc/emx.
When I am starting the guest with this TZ variable, the system time is wrong. When it is 10:00 (local time in DST) on the host, the time on the guest is 9:00. It is not possible to fix this by setting the correct time inside the guest, because vboxservice.exe is changing the clock back to the wrong value immediately.
When I am starting the guest without TZ set, the guest's time is back 2h. So at 10:00 on the host it is 8:00 for the guest.
To get the correct time for the guest, I have to set TZ=-2 now in summer and manually change it to TZ=-1 in winter.
It does not make a difference if 'Hardware Clock in UTC' in the VM's settings is checked or not!
Earlier versions of VirtualBox did not have this problem.
IMO the Guest Additions should not change the guest's clock at all. But if they do, they should treat TZ correctly also in the long format.
there is a problem with the system clock in my OS/2 guest.
I am running VirtualBox 6.1.24 on a Windows 10 (version 20H2) host. The system clock is running at local time with timezone "Europe/Berlin" and automatically switching to DST enabled. Actually my local time is GMT+2h, without DST it is GMT+1h
The guest is OS/2 Version 4.50 with guest additions 6.1.24 installed. Since the system clock on OS/2 is always running at local time it should be the same time as on the host.
The TZ environment variable for the guest is set to
TZ=MET-1DST,3,-1,0,7200,10,-1,0,10800,3600
meaning that the standard time zone is Middle European Time (MET) with a time zone offset of -1 (1h east of GMT). There is a daylight saving time (DST) starting in March (3) on the last (-1) sunday (0) at 2:00 (7200 sec after midnight). It is ending in October (10) on the last (-1) sunday (0) at 3:00 (10800 sec after midnight), and the offset to the standard time is 1h (3600s).
This is working for most OS/2 applications and also e.g. with gcc/emx.
When I am starting the guest with this TZ variable, the system time is wrong. When it is 10:00 (local time in DST) on the host, the time on the guest is 9:00. It is not possible to fix this by setting the correct time inside the guest, because vboxservice.exe is changing the clock back to the wrong value immediately.
When I am starting the guest without TZ set, the guest's time is back 2h. So at 10:00 on the host it is 8:00 for the guest.
To get the correct time for the guest, I have to set TZ=-2 now in summer and manually change it to TZ=-1 in winter.
It does not make a difference if 'Hardware Clock in UTC' in the VM's settings is checked or not!
Earlier versions of VirtualBox did not have this problem.
IMO the Guest Additions should not change the guest's clock at all. But if they do, they should treat TZ correctly also in the long format.
-
- Posts: 24
- Joined: 7. Sep 2008, 02:12
- Primary OS: openSUSE
- VBox Version: OSE self-compiled
- Guest OSses: OS/2, Windows, Linux, Android, NetWare
Re: Wrong System Time in OS/2 Guest
Indeed, this is a known issue with a fixed libc (not yet packaged and released to netlabs-exp, as yet). See:
https://github.com/bitwiseworks/libc/issues/109
HTH
https://github.com/bitwiseworks/libc/issues/109
HTH
Lewis
--------
Lewis G Rosenthal, CNA, CLE, CLP, CWTS
Arca Noae, LLC
--------
Lewis G Rosenthal, CNA, CLE, CLP, CWTS
Arca Noae, LLC
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: Wrong System Time in OS/2 Guest
They don't, unless you explicitly chose to set a time offset.mipri wrote: IMO the Guest Additions should not change the guest's clock at all.
The time comes from the Real Time Clock (RTC), a piece of virtual hardware - not Guest Addition software. The RTC in turn of course gets current wall clock time from the host OS, and turns it into UTC.
If your guest OS ignores the RTC and reads a network time server, that's up to you to fix. Likewise if you configure an incorrect time zone in host or guest. These (plus the explicit offset) are the only possible ways for the guest time to differ from the host time.
-
- Posts: 24
- Joined: 7. Sep 2008, 02:12
- Primary OS: openSUSE
- VBox Version: OSE self-compiled
- Guest OSses: OS/2, Windows, Linux, Android, NetWare
Re: Wrong System Time in OS/2 Guest
The problem here affects VMs as well as bare metal systems. The calculation of the TZ offset is incorrect beginning in 2021, as a result of a previous Y2038 bug. The following post in the previously-referenced ticket summarizes the problem nicely:
https://github.com/bitwiseworks/libc/is ... -882764025
So, no, it's not an issue with the Guest Additions per se. Rather, it's a problem with all modern kLIBC applications which rely on the offset calculation. So, even if using a NTP server, the OS/2 system's offset will be "off" as a result of this issue.
https://github.com/bitwiseworks/libc/is ... -882764025
So, no, it's not an issue with the Guest Additions per se. Rather, it's a problem with all modern kLIBC applications which rely on the offset calculation. So, even if using a NTP server, the OS/2 system's offset will be "off" as a result of this issue.
Lewis
--------
Lewis G Rosenthal, CNA, CLE, CLP, CWTS
Arca Noae, LLC
--------
Lewis G Rosenthal, CNA, CLE, CLP, CWTS
Arca Noae, LLC
Re: Wrong System Time in OS/2 Guest
Thank you both for your answers.
For me, the solution is to disable this "TimeSync Service" until libc gets fixed. This can be done by starting vboxservice.exe (in startup.cmd) with command line parameter --disable-timesync.
With this information I was able to fix the problem for the moment (see below).LewisR wrote:this is a known issue with a fixed libc
Neither my guest is using a network time server nor did I configure an incorrect time zone anywhere. And in both cases it should be possible to correct the clock manually. But instead I observed this:mpack wrote:If your guest OS ignores the RTC and reads a network time server, that's up to you to fix. Likewise if you configure an incorrect time zone in host or guest.
- After booting the guest, the system clock was wrong by 1h (and 1h different to the host clock).
- Then I opened an OS/2 command window and tried to set the correct time using the 'time' command.
- While vboxservice.exe was running, the clock was changed back to the wrong time after a few seconds. I also tried "net time" to get the time from another machine, with the same result.
- However, after killing vboxservice.exe it was possible to set the correct time permanently.
After digging a bit through the source code I found the following: there is a "Guest Additions TimeSync Service" as part of VBoxService (see /src/VBox/Additions/common/VBoxService/VBoxServiceTimeSync.cpp) which periodically(!) synchronizes the guest OS walltime with the host. Because of this the Guest Addditions have big impact on the guest's clock, and they also prevent any changes to the guest's system clock. Now obviously in the Guest Additions for OS/2 this TimeSync Service is affected the the bug in libc and (periodically) sets the guest's time wrong.mpack wrote:The time comes from the Real Time Clock (RTC), a piece of virtual hardware - not Guest Addition software.
For me, the solution is to disable this "TimeSync Service" until libc gets fixed. This can be done by starting vboxservice.exe (in startup.cmd) with command line parameter --disable-timesync.
-
- Volunteer
- Posts: 5678
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: Wrong System Time in OS/2 Guest
An alternative way to do this is by changing the VM configuration with the following command, while the VM is not running:mipri wrote:This can be done by starting vboxservice.exe (in startup.cmd) with command line parameter --disable-timesync.
Code: Select all
VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: Wrong System Time in OS/2 Guest
Are you sure about that? That sounds like it would leave the RTC uninitialized entirely, rather than just disable the resync part of it.fth0 wrote:Code: Select all
VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1
I see this command is taken from section 9.11.4 of the user manual. That section doesn't really answer my question either. According to it, the effect of that config is to "forbid the guest service from reading the host clock".
-
- Volunteer
- Posts: 2561
- Joined: 30. May 2007, 18:05
- Primary OS: Fedora other
- VBox Version: PUEL
- Guest OSses: XP, Win7, Win10, Linux, OS/2
Re: Wrong System Time in OS/2 Guest
What happens if you configure the OS/2 timezone to a zone one hour later?
Re: Wrong System Time in OS/2 Guest
Then the walltime would be correct, but applications not using the buggy version of libc would use the wrong time zone and therefore calculate a wrong value for GMT. Remember: in OS/2 the RTC runs local time, not UTC, and OS/2 itself does not really care about time zones.
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: Wrong System Time in OS/2 Guest
I'm pretty sure the simulated RTC in VirtualBox returns UTC, i.e. the host clock is automatically compensated for time zone before passing it to the VM, otherwise time zone would never be treated correctly in any VM - except when the time is GMT+0.mipri wrote:Remember: in OS/2 the RTC runs local time, not UTC
-
- Volunteer
- Posts: 5678
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: Wrong System Time in OS/2 Guest
We'll have to split some hairs here:mpack wrote:Are you sure about that? That sounds like it would leave the RTC uninitialized entirely, rather than just disable the resync part of it.
The VBoxService - Guest Additions TimeSync Service is implemented in VBoxServiceTimeSync.cpp, and its workhorse vgsvcTimeSyncWorker() is the only function (indirectly) calling vmmdevReqHandler_GetHostTime() in VMMDev.cpp, which has the only code evaluating GetHostTimeDisabled.
In consequence, I'm pretty sure that this setting has more or less the same effect as running VBoxService without TimeSync. But: Although vgsvcTimeSyncWorker() contains an initial time synchronization before looping forever, there could be another previous first initialization somewhere else, so it doesn't follow if the RTC is left uninitialized or not.
Last edited by fth0 on 12. Aug 2021, 21:56, edited 1 time in total.
-
- Volunteer
- Posts: 5678
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: Wrong System Time in OS/2 Guest
What's doing System > Motherboard > Hardware Clock in UTC Time then?mpack wrote:I'm pretty sure the simulated RTC in VirtualBox returns UTC
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: Wrong System Time in OS/2 Guest
Are you asking what that setting does? I dunno. I convinced myself as above that if the host does TZ correction, and then the VM applies the same correction again (*), then the VM clock would always be wrong (double offset always applied). I can't see how else it could work.fth0 wrote:What's doing System > Motherboard > Hardware Clock in UTC Time then?
(*) ISTM to that someone living (say) in Paris will choose the Paris TZ in host, guest, and every other PC in their vicinity: so the host would apply an offset, and then the VM would apply the same offset again. If the host time was already correct the VM time can't be.
All my VMs are set up to use network time, and I'm not willing to mess with that to examine this: too many things can get upset if they see clock tampering.
-
- Volunteer
- Posts: 5678
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: Wrong System Time in OS/2 Guest
No, I'm not really asking what that setting does, it was rather meant as a hint or reminder, because I couldn't imagine that you don't really know. Also, I forgot to put in the smiley, which I usually use to mark friendly hinting. I'll try and explain:
On a physical PC, a Linux host interprets the time in the RTC as UTC and adds the local time offset (UTC + TZ + DST) itself. When it acquires the network time via NTP, it subtracts TZ + DST before writing the result to the RTC. A Windows host however interprets the RTC as local time and writes the network time to the RTC unmodified.
In the VirtualBox configuration templates, System > Motherboard > Hardware Clock in UTC Time is set for Linux guests and unset for Windows and OS/2 guests, and VirtualBox provides the virtual RTC to the guest OS accordingly.
On a physical PC, a Linux host interprets the time in the RTC as UTC and adds the local time offset (UTC + TZ + DST) itself. When it acquires the network time via NTP, it subtracts TZ + DST before writing the result to the RTC. A Windows host however interprets the RTC as local time and writes the network time to the RTC unmodified.
In the VirtualBox configuration templates, System > Motherboard > Hardware Clock in UTC Time is set for Linux guests and unset for Windows and OS/2 guests, and VirtualBox provides the virtual RTC to the guest OS accordingly.
Last edited by fth0 on 12. Aug 2021, 22:50, edited 1 time in total.
-
- Volunteer
- Posts: 5678
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: Wrong System Time in OS/2 Guest
@mipri, @LewisR:
Since I know that Oracle prefers static linking in some places, a question about the VBoxService.exe from the VirtualBox GA for OS/2, just to be sure:
Is the VBoxService.exe dynamically linked to the OS/2 C library and you're waiting for the fix in OS/2, or is the VBoxService.exe statically linked to its own C library and you're waiting for a fix from Oracle?
Since I know that Oracle prefers static linking in some places, a question about the VBoxService.exe from the VirtualBox GA for OS/2, just to be sure:
Is the VBoxService.exe dynamically linked to the OS/2 C library and you're waiting for the fix in OS/2, or is the VBoxService.exe statically linked to its own C library and you're waiting for a fix from Oracle?