KVM 可以在主机关闭时自动挂起或关闭来宾吗?

And*_*egg 18 virtualization linux centos acpi kvm-virtualization

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

我们希望能够 (a) 自动向所有来宾发送 ACPI 关闭或 (b) 在主机关闭时将所有来宾挂起到磁盘。

是否有标准方法可以完成其中任何一个,还是您自己动手的情况?谢谢!

mat*_*tdm 6

是的。

virsh shutdown命令(或“关断”使用libvirt的,如在其它实施方案中virt-manager)指示客户OS到完全关闭。从手册页:

   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.
Run Code Online (Sandbox Code Playgroud)

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

在 Fedora 和 RHEL 6 中,一个libvirt-guests开箱即用的init 脚本配置为在系统关闭时挂起所有来宾。不过,这并不是特别神奇,因此只需稍作修改即可将其复制到 CentOS 5。