-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add -k option to shutdown for kexec functionality #436
base: master
Are you sure you want to change the base?
Conversation
In principle I'm fine with adding this feature (though in general: please remember to discuss new features before implementing them, eg. open a discussion or issue or send an email). I think in general the handling of (and documentation for) unsupported shutdown types needs to be tightened up. If I'm reading the changes correctly:
There are a few other minor niggles as well but these points are the main ones to be addressed, I think. |
Sorry about that; I implemented this for my own convenience initially (on a Dell with the world's slowest EFI), then thought I might as well share the changes if they work.
The "Unsupported shutdown type" is followed by The existing default on receiving an unrecognised shutdown_type from the socket was to poweroff, which probably isn't what the user meant. Should dinit reject an unsupported
Will fix
I don't know, I presumed so because the |
Maybe "accept" is ambiguous, what I meant was that it recognises the option. Anyway, I guess that's ok.
Ah right, they are indeed already there in the actual shutdown. But there they degrade more gracefully: if a requested shutdown type isn't supported, it falls back to a reboot, so the changes in the PR do change that: there would no longer be such a fallback.
Right; if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a thorough review this time. There shouldn't be anything else other than what I've highlighted here. Thanks
doc/manpages/shutdown.8.m4
Outdated
without firmware reinitialisation. This only works on Linux 2.6.13 or later with | ||
\fBCONFIG_KEXEC=y\fR; if you're unsure, most distribution kernels qualify. Don't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will nitpick a bit with the wording here:
"Don't forget to load a kernel image with \fBkexec\fR(8) first!" is not really the right tone. Better would be something like:
A suitable kernel image must be loaded first; see \fBkexec\fR(8).
Similarly, "only works" (on Linux 2.6.13 ...) would be better as "is only supported" (...). Rather than with \fBCONFIG_KEXEC=y\fR
I think it would be better with something like built with suitable support
(the CONFIG_KEXEC mention is probably meaningless to someone who hasn't built a kernel).
Can we remove or rephrase "if you're unsure, most distribution kernels qualify" - it's not really helpful (and the tone also doesn't match).
Ends of sentences should be followed by a newline (the other cases in this man page aren't correct either; I'll fix them separately). Apparently it can affect spacing when the man pages are converted to a printable format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, my tone isn't typically manpage-worthy (:
Rather than
with \fBCONFIG_KEXEC=y\fR
I think it would be better with something likebuilt with suitable support
(the CONFIG_KEXEC mention is probably meaningless to someone who hasn't built a kernel).
I feel the issue with 'suitable support' is that it's too vague: for those who don't know what CONFIG_KEXEC means, they can easily search for it, whereas 'suitable support' gives them nowhere to go.
Will fix the rest
@@ -36,13 +36,14 @@ enum class service_event_t { | |||
}; | |||
|
|||
/* Shutdown types */ | |||
enum class shutdown_type_t { | |||
enum class shutdown_type_t: char { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this, unless there's a good reason for it that I can't see?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is that shutdown_type_t
is cast to char
to be piped to the daemon, and the default cast is narrowing from enum: int
. I thought this was a good middle ground rather than ditching all type checking with the cast, and good to be reminded of what the type will be used for. But it isn't essential
Have implemented this for |
Adds a -k option to 'shutdown', analogous to that of systemd and OpenRC. Am daily driving this and it gets a nice speedup on reboot. Also tried to make the ifdef-ing out of shutdown code based on RB_* constants more consistent, so the user can clearly see which shutdown modes are supported (since kexec may not be available at compile time on very old environments).
The only real downside that I can see is if the user has neglected to load an image before calling 'reboot -k', then reboot will return -1 with EINVAL, init will exit and the kernel will panic. I can't see an easy way to avoid this, since we only find out that the user has remembered to load an image when we call reboot() and it doesn't return.