How does a Hypervisor synchronize time between Host and Guest VM?
I read this blog:
After conducting a bit of research I discovered that this is caused by the fact that the 开发者_如何学Cdefault Linux kernel runs at a 1000Hz internal clock frequency and that VMware is unable to deliver the clock interrupts on time without losing them. This means that some clock interrupts are lost without notice to the Linux kernels which assumes each interrupt marks 1/1000th of a second. So each clock interrupt that gets lost makes the clock fall behind a 1/1000th of a second.
Now, my question is, how does the hypervisor sync time internally if the hypervisor is capable of handling the clock interrupts?
Because when say (scaled up example, not real world): its 19:10:22 on Host, till it propagates to the guest, it will be 19:10:23 on the host.
I understand this is a hard problem, but I guess you need to slow the time from the VMs prespective. How is that achieved?
VMWare timekeeping
The hypervisor does not synchronize the clocks. It is software running in the guest VM that keeps the clocks in sync.
From page 15 (with the explanation continuing on through page 19) of your linked PDF:
There are two main options available for guest operating system clock synchronization: VMware Tools periodic clock synchronization or the native synchronization software that you would use with the guest operating system if you were running it directly on physical hardware. Some examples of native synchronization software are Microsoft W32Time for Windows and NTP for Linux.
The VMware Tools clock sync tool just checks the guest clock against the host clock every so often (probably once per minute) and corrects the guest clock if it's wrong. If the guest clock is off by just a little bit the tool will speed up or slow down the guest clock until it has the correct time (using an API like SetSystemTimeAdjustment
on Windows or adjtime
on Unix). If you're wondering how the tool accesses the host's clock, there's just an API for it that the VMware tool knows how to use.
精彩评论