acpid trickiness

Ran into an issue last night with one of my KVM VMs not registering a shutdown command from the host server.

This typically happens because the guest isn’t listening (or is configured to ignore) ACPI power “button” presses, so the guest doesn’t get told that it should shutdown.

In the case of my CentOS (RHEL) 5 VM, the acpid daemon wasn’t installed/running so the ACPI events were being ignored and the VM would just stay running. :-(

To install, start and configure to run at boot:

# yum install -y acpid
# /etc/init.d/acpid start
# chkconfig --level 345 acpid on

If acpid wasn’t originally running, it appears that HAL daemon can grab control of the /proc/acpi/event file and you may end up with the following error upon starting acpid:

Starting acpi daemon: acpid: can't open /proc/acpi/event: Device or resource bus

The reason can quickly be established with a ps aux:

[root@basestar ~]# ps aux | grep acpi
root        17  0.0  0.0      0     0 ?        S<   03:16   0:00 [kacpid]
68        2121  0.0  0.3   2108   812 ?        S    03:18   0:00 hald-addon-acpi: listening on acpi kernel interface /proc/acpi/event
root      3916  0.0  0.2   5136   704 pts/0    S+   03:24   0:00 grep acpi

Turns out HAL grabs the proc file for itself if acpid isn’t running, but if acpid is running, it will talk to acpid to get it’s information. This would self-correct on a reboot, but we can just do:

# /etc/init.d/haldaemon stop
# /etc/init.d/acpid start
# /etc/init.d/haldaemon start

And sorted:

[root@basestar ~]# ps aux | grep acpi
root        17  0.0  0.0      0     0 ?        S<   03:16   0:00 [kacpid]
root      3985  0.0  0.2   1760   544 ?        Ss   03:24   0:00 /usr/sbin/acpid
68        4014  0.0  0.3   2108   808 ?        S    03:24   0:00 hald-addon-acpi: listening on acpid socket /var/run/acpid.socket
root     16500  0.0  0.2   5136   704 pts/0    S+   13:24   0:00 grep acpi

 

3 thoughts on “acpid trickiness

  1. Jethro Carr Post author

    Incase you’re wondering why I would have a RHEL-based VM without acpid installed when it’s part of the base install, it’s because I customize the base install down a lot from what is considered base by the distribution.

    A base install includes things like smartcard readers, avahi detection of network hosts, and other programs that aren’t required for a VM. (do an rpm -qa and see all the junk that gets included in a base install)

    In this specific example, the VM was originally from a Xen host that had been converted to KVM, and IIRC, Xen didn’t require acpid to be able to send a shutdown to the OS, thanks to the paravirtualised kernel.

    Reply
  2. Pedantic corrector of websites

    correction:

    Minor typo, transposed letters in one line of your example
    “chkconfig –level 345 apcid on”
    should be
    “chkconfig –level 345 acpid on”

    If you correct it, do please delete this comment :)

    And I like your writing style by the way.

    Cheers

    Reply

Leave a Reply