As far as I understand, qemu-server (from Proxmox as for me) call /sbim/shutdown on guest Gentoo to shutdown it. But Gentoo with openrc /sbin/shutdown correctly operates with "-hP now" additional params to shutdown the guest. Without any params /sbin/shutdown reports only help options and it is impossible to shutdown guest Gentoo vm from server side.
Is this true? I mean, executing the following shut off the domain instantly for me: virsh qemu-agent-command --pretty --block gentoo '{"execute":"guest-shutdown", "arguments":{"mode":"powerdown"}}' Maybe you're missing the proper mode (which is powerdown anyway)? Here's the code that runs shutdown command: https://git.qemu.org/?p=qemu.git;a=blob;f=qga/commands-posix.c;h=93474ff7701e2e176e0dc38290f8f91df9233ce1;hb=HEAD#l83
I had this same problem. The issue is that Gentoo's /sbin/shutdown from sys-apps/sysvinit (openrc) doesn't accept the "+0" argument, instead requiring "now", for an immediate shutdown. I don't know much about systemd, but I'm guessing it provides a version of /sbin/shutdown that accepts "+0" ? As a workaround, I renamed /sbin/shutdown to /sbin/shutdowno and wrote a simple bash script wrapper for /sbin/shutdown that changes "+0", if present as $3, to "now", and then calls shutdowno. Probably the right approach for Gentoo is to simply patch commands-posix.c to call shutdown with "now" instead of "+0", when openrc is in use?
Created attachment 624662 [details, diff] Add NOW for shutdown command /sbin/shutdown from sysvinit-2.96 requires "now", but qemu-ga run /sbin/shutdown without "now"...
Option "now" worked with other packages, e.g. systemd, openrc etc...
(In reply to slawan from comment #4) > Option "now" worked with other packages, e.g. systemd, openrc etc... It's works for me on proxmox-ve (with openrc on vm). Thank you for a patch.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8b8e82850dc8818b97f8bafc3ccc7982142f1cea commit 8b8e82850dc8818b97f8bafc3ccc7982142f1cea Author: Matthias Maier <tamiko@gentoo.org> AuthorDate: 2020-04-18 19:28:23 +0000 Commit: Matthias Maier <tamiko@gentoo.org> CommitDate: 2020-04-18 19:28:23 +0000 app-emulation/qemu-guest-agent: fix shutdown command Closes: https://bugs.gentoo.org/681874 Package-Manager: Portage-2.3.99, Repoman-2.3.22 Signed-off-by: Matthias Maier <tamiko@gentoo.org> .../files/qemu-guest-agent-4.2.0-fix-shutdown.patch | 11 +++++++++++ ...st-agent-4.2.0.ebuild => qemu-guest-agent-4.2.0-r1.ebuild} | 1 + 2 files changed, 12 insertions(+)
I'm still experiencing this with both 4.2.0-r1 and 5.0.0. I get the following error messages logged /var/log/messages in the guest when I signal the guest to shutdown or reboot, but no shutdown or reboot occurs: May 30 01:23:04 guest qemu-ga[5813]: info: guest-shutdown called, mode: reboot May 30 01:23:04 guest /etc/init.d/qemu-guest-agent[5871]: openrc-shutdown: Select one of --cancel, --halt, --kexec, --poweroff, --reexec, --reboot, --single or --write-only May 30 01:23:12 guest qemu-ga[5813]: info: guest-shutdown called, mode: reboot May 30 01:23:12 guest /etc/init.d/qemu-guest-agent[5874]: openrc-shutdown: Select one of --cancel, --halt, --kexec, --poweroff, --reexec, --reboot, --single or --write-only May 30 01:23:18 guest qemu-ga[5813]: info: guest-shutdown called, mode: reboot May 30 01:23:18 guest /etc/init.d/qemu-guest-agent[5876]: openrc-shutdown: Select one of --cancel, --halt, --kexec, --poweroff, --reexec, --reboot, --single or --write-only May 30 01:23:22 guest qemu-ga[5813]: info: guest-shutdown called, mode: powerdown May 30 01:23:25 guest qemu-ga[5813]: info: guest-shutdown called, mode: powerdown May 30 01:23:29 guest qemu-ga[5813]: info: guest-shutdown called, mode: powerdown Also running sys-apps/openrc-0.42.1[sysv-utils] in the guest and not using a init= kernel parameter. Please reopen?