app-emulation/qemu-guest-agent fails to shutdown the guest because the gentoo provided shutdown command needs an additional parameter. Attached patch adds this one. Reproducible: Always Steps to Reproduce: 1. Start a guest with qemu-guest-agent 2. Shutdown the guest via libvirt Actual Results: Nothing happens Expected Results: Guest should shut down --- a/qemu-1.2.0/qga/commands-posix.c +++ b/qemu-1.2.0/qga/commands-posix.c @@ -73,8 +73,13 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err) reopen_fd_to_null(1); reopen_fd_to_null(2); - execle("/sbin/shutdown", "shutdown", shutdown_flag, "+0", - "hypervisor initiated shutdown", (char*)NULL, environ); + if (strcmp(mode, "powerdown") == 0 || strcmp(mode, "halt") == 0) { + execle("/sbin/shutdown", "shutdown", shutdown_flag, "-h", "+0", + "hypervisor initiated shutdown", (char*)NULL, environ); + } else { + execle("/sbin/shutdown", "shutdown", shutdown_flag, "+0", + "hypervisor initiated shutdown", (char*)NULL, environ); + } _exit(EXIT_FAILURE); } else if (pid < 0) { goto exit_err;
Have you sent this upstream?
(In reply to comment #1) > Have you sent this upstream? No, not so far. I guess some other distributions use the shutdown commando not from the sysvinit package and therefore mustn't set the additional parameter.
Realistically we want to match the behavior of other distros and not be a unique snowflake.
Created attachment 342716 [details] Patch to sysvinit to remove -h + -P/-H requirement
i don't particularly care, but this isn't specific to Gentoo. sysvinit (afaik) has always behaved this way. so changing qemu upstream also sounds reasonable.
should be all set now in the tree; thanks for the report! Commit message: Make shutdown -h work the same as other inits http://sources.gentoo.org/sys-apps/sysvinit/files/sysvinit-2.88-shutdown-h.patch?rev=1.1 http://sources.gentoo.org/sys-apps/sysvinit/sysvinit-2.88-r5.ebuild?rev=1.1
This was fixed upstream in QEMU in https://github.com/qemu/qemu/commit/485e741cd15655b4032b07b8a912aa5c7a4f2028. The patch no longer applies and I don't want to rebase it given that they now have man page translations (and our patch touches the man page) and there's no real need for it anymore.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=43da0ef9e9ba894ef97788623be1b1d104da6c35 commit 43da0ef9e9ba894ef97788623be1b1d104da6c35 Author: Sam James <sam@gentoo.org> AuthorDate: 2022-03-29 04:48:50 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2022-03-29 05:29:18 +0000 sys-apps/sysvinit: add 3.02 Note this drops the 'shutdown' patch given QEMU has been fixed (the impetus for the original bug) and the patch no longer applies -- to rebase it, we'd need to adapt the new translations and then always have to regenerate them too. Not worth it given the original problem is gone. (Although, that said, it looks like the translations aren't bundled generated anyway, so we ended up adding USE=nls for po4a for now.) Bug: https://bugs.gentoo.org/449354 Signed-off-by: Sam James <sam@gentoo.org> sys-apps/sysvinit/Manifest | 2 + sys-apps/sysvinit/metadata.xml | 19 ++-- sys-apps/sysvinit/sysvinit-3.02.ebuild | 175 +++++++++++++++++++++++++++++++++ 3 files changed, 188 insertions(+), 8 deletions(-)