System clock updating
Hyper-V provides the time synchronization integration services to do this for you.The way it does this is by getting time readings from the management operating system and sending them over to the guest operating system.But unfortunately the guest operating system has no idea that anything significant has happened – so it does not know to go and check the RTC and instead continues with its own internally calculated time.To deal with this the Hyper-V time synchronization integration service detects whenever it has come back from a saved state or snapshot, and corrects the time.There is a lot of confusion about how time synchronization works in Hyper-V – so I wanted to take the time to sit down and write up all the details.There are actually multiple problems that exist around keeping time inside of virtual machines – and Hyper-V tackles these problems in different ways.One partial mitigation we have for this issue is that when the Hyper-V time synchronization component loads for the first time – it does an initial user mode set of the time to ensure that the time gets corrected as quickly as possible (using the same technique as discussed in problem #2). So now that you understand how this all works – let’s discuss some common issues and questions around virtual machines and time synchronization. If you disable the Hyper-V time synchronization integration service you will disable all the time synchronization aspects of Hyper-V that are time zone aware – and only leave the initial RTC synchronization active – which is not time zone aware.This means that your virtual machines will go from booting in the wrong time zone, and then being corrected as soon as the Hyper-V time synchronization integration service loads to booting in the wrong time zone and staying in the wrong time zone.
In order to deal with time drift in a virtual machine – you need to have some process that regularly gets the real time from a trusted source and updates the time in a virtual machine.
This is done without the use of the Hyper-V time synchronization integration servers (it happens long before the integration services have loaded).
The downside of this approach is that this does not take into account any potential time zone differences between the management operating system and the guest operating system.
So if the snapshot was taken one month ago – the time and date will report that it is still one month ago.
Interestingly enough, at this point in time we will be reporting the correct (with some caveats) time in the systems RTC.