主机closures后,KVM可以自动挂起或closuresguest虚拟机吗?

我们有一个CentOS 5.5 KVM主机,以后会运行各种版本的CentOS和其他可能的操作系统。

我们希望能够(a)自动向所有客人发送ACPI关机,或者(b)在主机closures时将所有客人挂起到磁盘。

有没有一个标准的方法来完成其中的任何一个,或者它是一个自己的情况? 谢谢!

是。

virsh shutdown命令(或其他使用libvirt的“closures”实现,如在virt-manager )指示来宾操作系统closures干净。 从手册页:

  shutdown domain-id Gracefully shuts down a domain. This coordinates with the domain OS to perform graceful shutdown, so there is no guarantee that it will succeed, and may take a variable length of time depending on what services must be shutdown in the domain. The exact behavior of a domain when it shuts down is set by the on_shutdown parameter in the domain's XML definition. 

使用KVM,这应该发送一个ACPI system_powerdown事件。

在Fedora和RHEL 6中, libvirt-guests初始化脚本被configuration为在系统closures时挂起所有guest虚拟机。 不过这不是特别的魔术,所以可以稍微修改一下,把它复制到CentOS 5。

现在这是Fedora和RHEL 6中的一个标准function。

据我所知,CentOS没有这样的标准脚本。 这是可能的代码,但有点危险,因为你需要处理需要很长时间closures的客人。 在超时后才杀死它们可以破坏数据,而在等待它们的时候可以让你的关机挂起。

相反,最好在重启之前手动closures客人。 有一段时间我有一个脚本,取代了关机和重新启动。 那个脚本告诉我,如果有任何正在运行的guest虚拟机(在虚拟机列表中简单的lc),并且在运行guest虚拟机的时候阻塞了命令。

KVM访客只是用户空间进程。 你应该有一些过程监控到位。 最常见的似乎是libvirt(它是由RedHat开发的,所以我想它应该在CentOS上可用)。