Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 449354 - sys-apps/sysvinit: shutdown requires -h + -P/-H which differs from other init systems
Summary: sys-apps/sysvinit: shutdown requires -h + -P/-H which differs from other init...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
Keywords: PATCH
Depends on:
Reported: 2012-12-30 21:24 UTC by David Weber
Modified: 2022-03-29 05:29 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---

Patch to sysvinit to remove -h + -P/-H requirement (shutdown-P-H-flags.patch,1.72 KB, text/plain)
2013-03-20 15:07 UTC, Doug Goldstein (RETIRED)

Note You need to log in before you can comment on or make changes to this bug.
Description David Weber 2012-12-30 21:24:25 UTC
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)
-        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);
+       }
     } else if (pid < 0) {
         goto exit_err;
Comment 1 Doug Goldstein (RETIRED) gentoo-dev 2012-12-31 18:20:10 UTC
Have you sent this upstream?
Comment 2 David Weber 2013-01-01 20:32:37 UTC
(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.
Comment 3 Doug Goldstein (RETIRED) gentoo-dev 2013-03-20 15:06:33 UTC
Realistically we want to match the behavior of other distros and not be a unique snowflake.
Comment 4 Doug Goldstein (RETIRED) gentoo-dev 2013-03-20 15:07:29 UTC
Created attachment 342716 [details]
Patch to sysvinit to remove -h + -P/-H requirement
Comment 5 SpanKY gentoo-dev 2013-03-20 23:08:36 UTC
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.
Comment 6 SpanKY gentoo-dev 2013-05-04 04:57:13 UTC
should be all set now in the tree; thanks for the report!

Commit message: Make shutdown -h work the same as other inits
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-03-29 04:48:28 UTC
This was fixed upstream in QEMU in

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.
Comment 8 Larry the Git Cow gentoo-dev 2022-03-29 05:29:34 UTC
The bug has been referenced in the following commit(s):

commit 43da0ef9e9ba894ef97788623be1b1d104da6c35
Author:     Sam James <>
AuthorDate: 2022-03-29 04:48:50 +0000
Commit:     Sam James <>
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.)
    Signed-off-by: Sam James <>

 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(-)