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...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
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: ---


Attachments
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)
Details

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)
         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;
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
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
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-03-29 04:48:28 UTC
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.
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):

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