Hypervisor 如何同步主机和来宾 VM 之间的时间?
我读了这个 博客:
经过一番研究后,我 发现这是由 事实上,默认的 Linux 内核 以 1000Hz 内部时钟运行 频率,并且 VMware 无法 按时传送时钟中断 而不失去它们。这意味着 一些时钟中断丢失而没有 请注意 Linux 内核 假设每个中断标记为 1/1000 一秒钟的时间。所以每次时钟中断 迷路会让时钟倒塌 落后 1/1000 秒。
现在,我的问题是,如果虚拟机管理程序能够处理时钟中断,那么虚拟机管理程序如何在内部同步时间?
因为当说(放大的示例,而不是现实世界):主机上的时间为 19:10:22,直到它传播到访客时,主机上的时间将是 19:10:23。
我知道这是一个难题,但我想您需要从虚拟机的角度放慢时间。这是如何实现的?
I read this blog:
After conducting a bit of research I
discovered that this is caused by the
fact that the default 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虚拟机管理程序不同步时钟。它是在来宾虚拟机中运行的软件,可保持时钟同步。
从链接 PDF 的第 15 页(解释持续到第 19 页):
VMware Tools 时钟同步工具只是每隔一段时间(可能每分钟一次)对照主机时钟检查来宾时钟,并在错误时更正来宾时钟。如果来宾时钟稍微偏离一点点,该工具将加快或减慢来宾时钟的速度,直到获得正确的时间(使用诸如
SetSystemTimeAdjustment
Windows 或adjtime
(Unix 上)。如果您想知道该工具如何访问主机时钟,VMware 工具知道如何使用一个 API。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:
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 oradjtime
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.