Tech: Time Synchronization in Hyper-V

Ben Armstrong, Virtualization Program Manager at Microsoft posted an interesting article about how time synchronization works in Hyper-V.

Concerning time synchronization there are a couple of problems, the first one is related to virtual machines which lose track of time. This problem is related to the fact that most operating systems use the hardware clock (RTC) at boot to determine time, and once booted based on that time have a mechanism which calculates time. Problem is that this calculation is based on assumptions which aren’t valid for virtual machines, this can cause a drift in time calculations.

This is where the time synchronization integration services come in. The time synchronization integration services gets the time from the management OS en sends it to the guest OS, making it available as a Windows time provider.


The second problem is related to virtual machines and snapshots which have the wrong time when they are restored. VM’s and snapshots are restored with the time they had when they were saved. Even though the correct time is reported in the hardware clock, the guest OS isn’t aware of that at that time. For this scenario, the integration services detects the correct time and makes it available by issuing a time change request in the guest OS.

The third problem is related to the situation where there is no correct RTC value when the VM is started. VM’s use the time from the management operating system as their RTC, but this time could be in a different time zone, which the guest OS doesn’t take into account. In order to mitigate this, the time synchronization integration services does a initial user mode set of the time when it loads for the first time, making sure time is corrected as quickly as possible.

Based on the knowledge provided in the problem scenario’s Ben Armstrong then further answers some common questions related to these scenarios.

"…Question #3 – Can’t you use UTC time in the RTC so that the correct time is established when the virtual machine boots?

UTC (which is the computer techy version of saying GMT) time would solve this problem nicely with only one problem. Windows does not support UTC time in the BIOS (Linux does). So while this would solve the problem for our Linux running user base – the fact of the matter is that most of our users run Windows – and this would not work for them…"