Hypervisor 如何同步主机和来宾 VM 之间的时间?

发布于 2024-10-07 08:33:01 字数 646 浏览 3 评论 0原文

我读了这个 博客:

经过一番研究后,我 发现这是由 事实上,默认的 Linux 内核 以 1000Hz 内部时钟运行 频率,并且 VMware 无法 按时传送时钟中断 而不失去它们。这意味着 一些时钟中断丢失而没有 请注意 Linux 内核 假设每个中断标记为 1/1000 一秒钟的时间。所以每次时钟中断 迷路会让时钟倒塌 落后 1/1000 秒。

现在,我的问题是,如果虚拟机管理程序能够处理时钟中断,那么虚拟机管理程序如何在内部同步时间?

因为当说(放大的示例,而不是现实世界):主机上的时间为 19:10:22,直到它传播到访客时,主机上的时间将是 19:10:23。

我知道这是一个难题,但我想您需要从虚拟机的角度放慢时间。这是如何实现的?

VMWare 计时

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?

VMWare timekeeping

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神魇的王 2024-10-14 08:33:01

虚拟机管理程序不同步时钟。它是在来宾虚拟机中运行的软件,可保持时钟同步。

从链接 PDF 的第 15 页(解释持续到第 19 页):

有两个主要选项可用于客户机操作系统时钟同步: VMware Tools 定期时钟同步
或者如果您直接在物理上运行来宾操作系统,则可以将其与来宾操作系统一起使用的本机同步软件
硬件。本机同步软件的一些示例包括适用于 Windows 的 Microsoft W32Time 和适用于 Linux 的 NTP。

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:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文