我已经安装了 KVM,并在我的 Debian 7.1 主机上运行,其中有两个 Debian 7.1 来宾和一些 Windows XP 来宾。当我使用命令 'virsh shutdown' 关闭或点击 virt-manager 中的关闭按钮时,Debian 来宾进入 pmsuspended 状态。
我可以正确关闭的唯一方法是通过 ssh 连接到这些客人并输入“shutdown -h now”命令。
在两个 debian 客户机上,我都安装并运行了这些软件包:
ii acpi 1.6-1 amd64 displays information on ACPI devices
ii acpi-fakekey 0.140-5 amd64 tool to generate fake key events
ii acpi-support 0.140-5 all scripts for handling many ACPI events
ii acpi-support-base 0.140-5 all scripts for handling base ACPI events such as the power button
ii acpid 1:2.0.16-1+deb7u1 amd64 Advanced Configuration and Power Interface event daemon
这是我的 acpid 在我的 debian 客户机上的事件:
:/etc/acpi/events$ cat powerbtn-acpi-support
event=button[ /]power
action=/etc/acpi/powerbtn-acpi-support.sh
/etc/acpi/powerbtn-acpi-support.sh
#!/bin/sh
# This script initiates a shutdown when the power putton has been
# pressed. Loosely based on the sample that ships with the acpid package.
# If the acpid sample is present as a real config file (as it was in earlier
# versions of acpid), we skip this script. (Purging and reinstalling acpid
# resolves this situation, or simply deleting /etc/acpi/events/powerbtn.)
if [ -f /etc/acpi/events/powerbtn -o -f /etc/acpi/events/powerbtn.dpkg-bak ] ; then
logger Acpi-support not handling power button, acpid handler exists at /etc/acpi/events/powerbtn or /etc/acpi/events/powerbtn.dpkg-bak.
exit 0
fi
[ -e /usr/share/acpi-support/policy-funcs ] || exit 0
. /usr/share/acpi-support/policy-funcs
if CheckPolicy; then
exit 0
fi
if [ -x /etc/acpi/powerbtn.sh ] ; then
# Compatibility with old config script from acpid package
/etc/acpi/powerbtn.sh
elif [ -x /etc/acpi/powerbtn.sh.dpkg-bak ] ; then
# Compatibility with old config script from acpid package
# which is still around because it was changed by the admin
/etc/acpi/powerbtn.sh.dpkg-bak
else
# Normal handling.
/sbin/shutdown -h -P now "Power button pressed"
fi
更新
上周安装了一个新的 Debian 来宾 VM,它没有关机问题。确实存在问题的 Debian VM 已从 VirtualBox 移至 KVM,并且是 Debian 7 的较旧安装。
我在转换为 libvirt/KVM 的旧 vmware 映像上遇到了同样的问题。它在许多 Debian 版本升级中幸存下来。我尝试了所有常规方法,检查来宾中是否启用了 acpi,并在 /etc/acpi/events 中创建了事件脚本。没有任何效果。最后我清除了包裹。
能力清除酸
然后我还删除了我自己创建的剩余脚本。然后我做了一个全新的数据包安装
aptitude 安装 acpid
在安装过程中可以看到的是:
奇怪的,新的依赖...而且它奏效了!
希望这对你有用!
我最近通过安装 acpid 并编辑/etc/acpi/events/powerbtn以包含action=/sbin/poweroff解决了当前 Ubuntu 上的问题。
详细说明