any "reference time" in a Hyper-V virtual machine? RRS feed

  • Question



    Due to the clock skew issue in virtualization world (, the clock value from Win32 API in parent or guest partition may not be the "correct", from a viewer outside of the physical Hyper-V host (however, the clock value is "correct" within each VM).  I am looking for a way in VM to read a "reference time" that is perfectly in sync, possibly with constant/fixed offset, with physical clock (wall clock) outside of a VM.

    This should give an application running on a virtual machine a better measurement of response time from the perspective of physical/wall clock outside of the VM (e.g., NOT from the perspective within the VM).


    As we know, the clock in Windows (VM or not) is based on counting number of timer interrupts received, and timer interrupt can be delivered faster in order to "catch up" (timer period modulation) in VM (  Therefore when the physical clock (wall clock) is T, the clock on VM could be N seconds less than T (their offset is N); and when the physical clock is T plus 1 second, the current time on VM could catch up to T plus 1 second as well (their offset is changed to 0).

    I do agree that the clock read from VM using win32 API is valid, from the perspective of the VM.  But what I am looking for is a time reference that is NOT subject to any timer period modulation in any HyperV VM.  That is, when the physical clock reads T, the reference time on VM reads X (their offset if X-T), and when a physical clock reads T plus 1 second, the reference time on VM also reads X plus 1 second (their offset remains constant at X-T).

    Of course within a VM I could always query a remote time source (NTP server) as the reference time.  But I am hoping to find a less expensive solution.

    Since the clock in parent partition and guest partitions in Hyper-V are virtualized, I am thinking perhaps there is such a reference time in hypervisor.  Does not need to be the actual real time clock in BIOS.

    Among various hypervisor timers (, do you think "Reference Time Count" ( and "Reference Count MSR" ( are the ones I am looking for?

    I have browsed the Hyper-V WMI classes for such an API without any luck.

    Any suggestions?  Thanks.



    Friday, November 14, 2008 7:57 PM