ACPI shutdown does nothing Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
ingenium
Posts: 3
Joined: Sun Jul 14, 2019 12:53 am

ACPI shutdown does nothing

Post by ingenium »

I have DietPi installed in qemu / kvm, and everything seems to work except ACPI events. I cannot initiate a clean shutdown from the VM host, the only way to do it is to SSH in and issue a shutdown command. I have tried installed qemu guest additions and setting that up as a workaround, but it didn't help.

Installing and running evtest on DietPi shows "Power Button" as /dev/input/event4". Monitoring this input and issuing a shutdown command from the VM host shows that DietPi is receiving it:

Code: Select all

root@DietPi:~# evtest 
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:	AT Translated Set 2 keyboard
/dev/input/event1:	VirtualPS/2 VMware VMMouse
/dev/input/event2:	VirtualPS/2 VMware VMMouse
/dev/input/event3:	QEMU QEMU USB Tablet
/dev/input/event4:	Power Button
/dev/input/event5:	PC Speaker
Select the device event number [0-5]: 4
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x0 product 0x1 version 0x0
Input device name: "Power Button"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 116 (KEY_POWER)
Properties:
Testing ... (interrupt to exit)
Event: time 1563058630.608071, type 1 (EV_KEY), code 116 (KEY_POWER), value 1
Event: time 1563058630.608071, -------------- SYN_REPORT ------------
Event: time 1563058630.608073, type 1 (EV_KEY), code 116 (KEY_POWER), value 0
Event: time 1563058630.608073, -------------- SYN_REPORT ------------
However it does not initiate a shutdown. Is there a way to fix this so that DietPi properly shuts down when I receives an ACPI shutdown command?
hd888
Posts: 21
Joined: Fri Apr 06, 2018 2:56 pm

Re: ACPI shutdown does nothing

Post by hd888 »

It's essentially a RPi, which doesn't even have an on/off switch - and no acpi shutdown. I just use shutdown -h now on my VM.
ingenium
Posts: 3
Joined: Sun Jul 14, 2019 12:53 am

Re: ACPI shutdown does nothing

Post by ingenium »

That doesn't help though. As it is now, when the host shuts down or restarts, the dietpi VM makes the host wait 2 minutes before it times out force destroys the VM to continue shutting down. That's the issue I'm ultimately trying to solve.

Is there a way to install ACPI? Or perhaps setup a udev rule to shutdown when the "power button" is pressed? I'm just not sure how to setup the appropriate udev rule to match the button press
hd888
Posts: 21
Joined: Fri Apr 06, 2018 2:56 pm

Re: ACPI shutdown does nothing

Post by hd888 »

I created a vm.service file in my systemd to handle this (improperly) to keep me from waiting. I probably need to look at it a little harder cause it's "yanking the plug" however I dont have to wait. It's not a huge deal to me because if it corrupts I usually have a recent backup... That's what VMs are good at anyway!

Code: Select all

[Unit]
Description=Dietpi VM service
After=network.target virtualbox.service

[Service]
User=xxx
ExecStart=/usr/lib/virtualbox/VBoxHeadless -s DietPi2
ExecStop=/usr/lib/virtualbox/VBoxManage controlvm DietPi2 poweroff

[Install]
WantedBy=multi-user.target
Then you can just enable the service file and it will shut it down when the machine shuts down and boot it when it boots without having to worry about it.
ingenium
Posts: 3
Joined: Sun Jul 14, 2019 12:53 am

Re: ACPI shutdown does nothing

Post by ingenium »

I solved it. Make sure acpid is installed, then create /etc/acpi/events/power_button with the following:

Code: Select all

event=button/power PBTN 00000080 00000000
action=/sbin/poweroff
Your event may differ, but you can look it up by running acpi_listen and then sending the ACPI shutdown command.
hd888
Posts: 21
Joined: Fri Apr 06, 2018 2:56 pm

Re: ACPI shutdown does nothing

Post by hd888 »

Thanks that's fantastic! Works for me and better than my solution. FYI I'm going to keep my service file and change it to send a acpi signal to properly shut my VM down on restarts now.
Post Reply