安装了 acpi 的 KVM 客户机无法关闭

安装了 acpi 的 KVM 客户机无法关闭

我在 Debian 7.1 主机上安装了 KVM 并开始运行,主机上有两个 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

以下是我的 Debian 客户机上的 acpid 事件:

:/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 客户虚拟机,没有出现关机问题。有问题的 Debian 虚拟机已从 VirtualBox 移至 KVM,并且是较旧的 Debian 7 安装。

答案1

我最近通过安装 acpid 和编辑解决了当前 Ubuntu 上的问题/etc/acpi/events/powerbtn包含装有操作=/sbin/poweroff

详细说明

答案2

我在旧的 vmware 映像上遇到了同样的问题,我将其转换为 libvirt/KVM。它经历了许多 Debian 版本升级。我尝试了所有常规方法,检查客户机中是否启用了 acpi,并在 /etc/acpi/events 中创建了事件脚本。但都不起作用。最后我清除了该软件包。

aptitude 清除 acpid

然后我还删除了我自己创建的其余脚本。然后我进行了全新的数据包安装

aptitude 安装 acpid

安装过程中可以看到的内容是:

将安装以下新软件包:acpi-support-base{a} acpid consolekit{a} libck-connector0{a} libpam-ck-connector{a} libpolkit-gobject-1-0{a}

奇怪的、新的依赖关系......而且它有效!

希望这对你有用!

相关内容