hwclock not updated when I unpause guest

Discussions about using Linux guests in VirtualBox.
Post Reply
940607
Posts: 57
Joined: 24. Sep 2012, 10:32
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Archlinux
Location: Russia

hwclock not updated when I unpause guest

Post by 940607 »

Unlike Windows guests, when I unpause or restore my Archlinux guest, the clock does not update.

How to fix this? Don't suggest NTP - all should work without it.

Code: Select all

<?xml version="1.0"?>
<!--
** DO NOT EDIT THIS FILE.
** If you make changes to this file while any VirtualBox related application
** is running, your changes will be overwritten later, without taking effect.
** Use VBoxManage or the VirtualBox Manager GUI to make changes.
-->
<VirtualBox xmlns="http://www.innotek.de/VirtualBox-settings" version="1.14-windows">
  <Machine uuid="{374d6b03-6bab-4b36-8703-b710efd1184e}" name="arch" OSType="ArchLinux" snapshotFolder="Snapshots" lastStateChange="2014-03-07T08:17:16Z">
    <MediaRegistry>
      <HardDisks>
        <HardDisk uuid="{4801b5a6-d0ec-4dde-87c3-73696beac406}" location="C:/VM/linux2.vmdk" format="VMDK" type="Normal"/>
        <HardDisk uuid="{c66e568c-3d41-4017-af5e-4ed06a050870}" location="C:/VM/linux.vmdk" format="VMDK" type="Normal"/>
      </HardDisks>
      <DVDImages>
        <Image uuid="{eede9c51-a33e-499c-b380-86f5b265559d}" location="//buffalo.reksoft.ru/Soft/ByProduct/Debian/7.X/debian-7.0.0-amd64-DVD-1.iso"/>
        <Image uuid="{03785165-6149-4cda-bc83-c1aefd4659ed}" location="C:/VM/grub-rescue.iso"/>
      </DVDImages>
      <FloppyImages/>
    </MediaRegistry>
    <ExtraData>
      <ExtraDataItem name="GUI/LastCloseAction" value="SaveState"/>
      <ExtraDataItem name="GUI/LastGuestSizeHint" value="1920,1016"/>
      <ExtraDataItem name="GUI/LastNormalWindowPosition" value="1448,30,704,322,max"/>
    </ExtraData>
    <Hardware version="2">
      <CPU count="1" hotplug="false">
        <HardwareVirtEx enabled="true"/>
        <HardwareVirtExNestedPaging enabled="true"/>
        <HardwareVirtExVPID enabled="true"/>
        <HardwareVirtExUX enabled="true"/>
        <PAE enabled="false"/>
        <HardwareVirtExLargePages enabled="true"/>
        <HardwareVirtForce enabled="false"/>
      </CPU>
      <Memory RAMSize="2048" PageFusion="false"/>
      <HID Pointing="USBTablet" Keyboard="PS2Keyboard"/>
      <HPET enabled="false"/>
      <Chipset type="PIIX3"/>
      <Boot>
        <Order position="1" device="Floppy"/>
        <Order position="2" device="DVD"/>
        <Order position="3" device="HardDisk"/>
        <Order position="4" device="None"/>
      </Boot>
      <Display VRAMSize="12" monitorCount="1" accelerate3D="false" accelerate2DVideo="false"/>
      <VideoCapture enabled="false" screens="18446744073709551615" horzRes="1024" vertRes="768" rate="512" fps="25"/>
      <RemoteDisplay enabled="false" authType="Null" authTimeout="5000"/>
      <BIOS>
        <ACPI enabled="true"/>
        <IOAPIC enabled="false"/>
        <Logo fadeIn="true" fadeOut="true" displayTime="0"/>
        <BootMenu mode="MessageAndMenu"/>
        <TimeOffset value="0"/>
        <PXEDebug enabled="false"/>
      </BIOS>
      <USB>
        <Controllers>
          <Controller name="OHCI" type="OHCI"/>
        </Controllers>
        <DeviceFilters/>
      </USB>
      <Network>
        <Adapter slot="0" enabled="true" MACAddress="0800275D0C22" cable="true" speed="0" type="82540EM">
          <DisabledModes>
            <InternalNetwork name="intnet"/>
            <NATNetwork name="NatNetwork"/>
          </DisabledModes>
          <NAT>
            <DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
            <Alias logging="false" proxy-only="false" use-same-ports="false"/>
            <Forwarding name="Rule 1" proto="1" hostport="10022" guestport="22"/>
          </NAT>
        </Adapter>
        <Adapter slot="1" enabled="false" MACAddress="0800278DBE44" cable="true" speed="0" type="82540EM">
          <DisabledModes>
            <NAT>
              <DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
              <Alias logging="false" proxy-only="false" use-same-ports="false"/>
            </NAT>
          </DisabledModes>
        </Adapter>
        <Adapter slot="2" enabled="false" MACAddress="08002786DFB3" cable="true" speed="0" type="82540EM">
          <DisabledModes>
            <NAT>
              <DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
              <Alias logging="false" proxy-only="false" use-same-ports="false"/>
            </NAT>
          </DisabledModes>
        </Adapter>
        <Adapter slot="3" enabled="false" MACAddress="08002724B3E1" cable="true" speed="0" type="82540EM">
          <DisabledModes>
            <NAT>
              <DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
              <Alias logging="false" proxy-only="false" use-same-ports="false"/>
            </NAT>
          </DisabledModes>
        </Adapter>
        <Adapter slot="4" enabled="false" MACAddress="0800273D2457" cable="true" speed="0" type="82540EM">
          <DisabledModes>
            <NAT>
              <DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
              <Alias logging="false" proxy-only="false" use-same-ports="false"/>
            </NAT>
          </DisabledModes>
        </Adapter>
        <Adapter slot="5" enabled="false" MACAddress="08002711785C" cable="true" speed="0" type="82540EM">
          <DisabledModes>
            <NAT>
              <DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
              <Alias logging="false" proxy-only="false" use-same-ports="false"/>
            </NAT>
          </DisabledModes>
        </Adapter>
        <Adapter slot="6" enabled="false" MACAddress="0800274209C6" cable="true" speed="0" type="82540EM">
          <DisabledModes>
            <NAT>
              <DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
              <Alias logging="false" proxy-only="false" use-same-ports="false"/>
            </NAT>
          </DisabledModes>
        </Adapter>
        <Adapter slot="7" enabled="false" MACAddress="0800279DAFB8" cable="true" speed="0" type="82540EM">
          <DisabledModes>
            <NAT>
              <DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
              <Alias logging="false" proxy-only="false" use-same-ports="false"/>
            </NAT>
          </DisabledModes>
        </Adapter>
      </Network>
      <UART>
        <Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
        <Port slot="1" enabled="false" IOBase="0x2f8" IRQ="3" hostMode="Disconnected"/>
      </UART>
      <LPT>
        <Port slot="0" enabled="false" IOBase="0x378" IRQ="4"/>
        <Port slot="1" enabled="false" IOBase="0x378" IRQ="4"/>
      </LPT>
      <AudioAdapter controller="AC97" driver="DirectSound" enabled="true"/>
      <RTC localOrUTC="local"/>
      <SharedFolders/>
      <Clipboard mode="Bidirectional"/>
      <DragAndDrop mode="Disabled"/>
      <IO>
        <IoCache enabled="true" size="5"/>
        <BandwidthGroups/>
      </IO>
      <HostPci>
        <Devices/>
      </HostPci>
      <EmulatedUSB>
        <CardReader enabled="false"/>
      </EmulatedUSB>
      <Guest memoryBalloonSize="0"/>
      <GuestProperties>
        <GuestProperty name="/VirtualBox/GuestAdd/HostVerLastChecked" value="4.3.6" timestamp="1394180094082111100" flags=""/>
        <GuestProperty name="/VirtualBox/GuestAdd/Revision" value="76795" timestamp="1381396220798759000" flags=""/>
        <GuestProperty name="/VirtualBox/GuestAdd/Vbgl/Video/SavedMode" value="1920x1016x32" timestamp="1394179894711432200" flags=""/>
        <GuestProperty name="/VirtualBox/GuestAdd/Version" value="4.1.10" timestamp="1381396220798259001" flags=""/>
        <GuestProperty name="/VirtualBox/GuestAdd/VersionExt" value="4.1.10_OSE" timestamp="1381396220798259002" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/Net/0/MAC" value="0800275D0C22" timestamp="1381396230829759001" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/Net/0/Status" value="Up" timestamp="1381396230830259000" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/Net/0/V4/Broadcast" value="10.0.2.255" timestamp="1381396230825259000" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/Net/0/V4/IP" value="10.0.2.15" timestamp="1381396230824759000" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/Net/0/V4/Netmask" value="255.255.255.0" timestamp="1381396230829759000" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/Net/Count" value="1" timestamp="1381482545570075600" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/OS/LoggedInUsers" value="" timestamp="1381482553165094300" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/OS/LoggedInUsersList" value="" timestamp="1381482553165094301" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/OS/NoLoggedInUsers" value="" timestamp="1381482553165594400" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/OS/Product" value="Linux" timestamp="1381396220791759000" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/OS/Release" value="3.2.9-1-ARCH" timestamp="1381396220795259000" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/OS/ServicePack" value="" timestamp="1381396220798259000" flags=""/>
        <GuestProperty name="/VirtualBox/GuestInfo/OS/Version" value="#1 SMP PREEMPT Thu Mar 1 09:31:13 CET 2012" timestamp="1381396220795759000" flags=""/>
        <GuestProperty name="/VirtualBox/HostInfo/GUI/LanguageID" value="ru_RU" timestamp="1394180094062107100" flags=""/>
      </GuestProperties>
    </Hardware>
    <StorageControllers>
      <StorageController name="IDE контроллер" type="PIIX4" PortCount="2" useHostIOCache="true" Bootable="true">
        <AttachedDevice passthrough="false" type="DVD" port="1" device="0"/>
        <AttachedDevice type="HardDisk" port="0" device="0">
          <Image uuid="{c66e568c-3d41-4017-af5e-4ed06a050870}"/>
        </AttachedDevice>
      </StorageController>
      <StorageController name="SATA контроллер" type="AHCI" PortCount="1" useHostIOCache="false" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3"/>
    </StorageControllers>
  </Machine>
</VirtualBox>
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: hwclock not updated when I unpause guest

Post by mpack »

940607 wrote:How to fix this? Don't suggest NTP - all should work without it.
Really? Then you must know something I don't, since I was under the impression that it's up to the guest when and how it updates its own clock.
940607
Posts: 57
Joined: 24. Sep 2012, 10:32
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Archlinux
Location: Russia

Re: hwclock not updated when I unpause guest

Post by 940607 »

mpack wrote:it's up to the guest when and how it updates its own clock.
Compare with mouse and keyboard. RTC is a virtual device too and should be set by the host. Maybe linux is being too smart and updates hwclock when woken, but I don't have any confirmation of that
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: hwclock not updated when I unpause guest

Post by Perryg »

The update of the guest "hwclock" with VirtualBox requires the guest additions being installed ( in the guest ).
This also depends on how long the guest is paused. If say it was paused a matter of a few minutes. It can take hours for the guest to sync.
You can also control this.

I found that setting the threshold to 1000 actually makes VBox reset the clock sooner. ( YMMV )

Code: Select all

As su/sudo on guest to test
VBoxService --timesync-set-threshold 1000

Or run this on the host to make permanent 
VBoxManage guestproperty set <guests name> "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold" 1000
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: hwclock not updated when I unpause guest

Post by mpack »

940607 wrote:Compare with mouse and keyboard. RTC is a virtual device too and should be set by the host.
That's correct - and like the RTC, it's also up to the guest when it reads the keyboard, and what keyboard map it applies. Just because the VM simulated hardware is available doesn't guarantee that the guest will use it as you expect.

In particular, some guests don't read their RTC continuously, instead they init a counter on startup and thereafter use a timer int to update it, and derive their clock from that too. If the timer int stops mysteriously, e.g. because the VM was suspended, then the clock will be off. Whether Arch Linux works this way I can't say.

I think if you install the GAs then VirtualBox may do something to force the guest to update quicker, but I don't even know if official GAs are available for Arch Linux - it's barely mentioned in the manual.
940607
Posts: 57
Joined: 24. Sep 2012, 10:32
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Archlinux
Location: Russia

Re: hwclock not updated when I unpause guest

Post by 940607 »

The additions are installed. I think I found the reason:
--timesync-set-threshold

The absolute drift threshold, given as milliseconds where to start setting the time instead of trying to smoothly adjust it. The default is 20 minutes.
However, on Windows the time is set even after a small pause, e.g. 2 minutes.
$ VBoxManage guestproperty get "win2003-1" /VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold
No value set!
$ VBoxManage guestproperty get "arch" /VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold
No value set!
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: hwclock not updated when I unpause guest

Post by Perryg »

I posted the fix above. Did you try it or are you thinking it is incorrect?
940607
Posts: 57
Joined: 24. Sep 2012, 10:32
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Archlinux
Location: Russia

Re: hwclock not updated when I unpause guest

Post by 940607 »

Yes, your fix works. What bothers me now is why Windows guests don't need this fix.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: hwclock not updated when I unpause guest

Post by Perryg »

Since it was never broken I did not spend any time trying to figure out why it worked.
Post Reply