summaryrefslogtreecommitdiff
path: root/src/core/shutdown.c
AgeCommit message (Collapse)Author
2014-11-28treewide: no need to negate errno for log_*_errno()Michal Schmidt
It corrrectly handles both positive and negative errno values.
2014-11-28treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt
As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
2014-11-26manager: log some fatal errors at emergency levelZbigniew Jędrzejewski-Szmek
This adds a new log_emergency() function, which is equivalent to log_error() for non-PID-1, and logs at the highest priority for PID 1. Some messages which occur before freezing are converted to use it.
2014-11-06shutdown: fix arguments to /run/initramfs/shutdownMichal Schmidt
Our initrd interface specifies that the verb is in argv[1]. This is where systemd passes it to systemd-shutdown, but getopt permutes argv[]. This confuses dracut's shutdown script: Shutdown called with argument '--log-level'. Rebooting! getopt can be convinced to not permute argv[] by having '-' as the first character of optstring. Let's use it. This requires changing the way non-option arguments (in our case, the verb) are processed. This fixes a bug where the system would reboot instead of powering off.
2014-11-06s/commandline/command line/gHarald Hoyer
2014-10-27shutdown: do final unmounting only if not running inside the containerMichal Sekletar
If we run in the container then we run in a mount namespace. If namespace dies then kernel should do unmounting for us, hence we skip unmounting in containers. Also, it may be the case that we no longer have capability to do umount, because we are running in the unprivileged container. See: http://lists.freedesktop.org/archives/systemd-devel/2014-October/023536.html
2014-10-24shutdown: pass own argv to /run/initramfs/shutdownMarius Tessmann
Since commit b1e90ec515408aec2702522f6f68c4920b56375b systemd passes its log settings to systemd-shutdown via command line parameters. However, systemd-shutdown doesn't pass these parameters to /run/initramfs/shutdown, causing it to fall back to the default log settings. This fixes the following bugs about the shutdown not being quiet despite "quiet" being in the kernel parameters: https://bugs.freedesktop.org/show_bug.cgi?id=79582 https://bugs.freedesktop.org/show_bug.cgi?id=57216
2014-08-28use the switch_root function in shutdownHarald Hoyer
removes code duplication also move switch-root to shared
2014-08-22core: introduce "poweroff" as new failure action typesLennart Poettering
Also, change the default action on a system start-up timeout to powering off.
2014-08-03Unify parse_argv styleZbigniew Jędrzejewski-Szmek
getopt is usually good at printing out a nice error message when commandline options are invalid. It distinguishes between an unknown option and a known option with a missing arg. It is better to let it do its job and not use opterr=0 unless we actually want to suppress messages. So remove opterr=0 in the few places where it wasn't really useful. When an error in options is encountered, we should not print a lengthy help() and overwhelm the user, when we know precisely what is wrong with the commandline. In addition, since help() prints to stdout, it should not be used except when requested with -h or --help. Also, simplify things here and there.
2014-07-07firstboot: get rid of firstboot generator again, introduce ↵Lennart Poettering
ConditionFirstBoot= instead As Zbigniew pointed out a new ConditionFirstBoot= appears like the nicer way to hook in systemd-firstboot.service on first boots (those with /etc unpopulated), so let's do this, and get rid of the generator again.
2014-07-07firstboot: add new component to query basic system settings on first boot, ↵Lennart Poettering
or when creating OS images offline A new tool "systemd-firstboot" can be used either interactively on boot, where it will query basic locale, timezone, hostname, root password information and set it. Or it can be used non-interactively from the command line when prepareing disk images for booting. When used non-inertactively the tool can either copy settings from the host, or take settings on the command line. $ systemd-firstboot --root=/path/to/my/new/root --copy-locale --copy-root-password --hostname=waldi The tool will be automatically invoked (interactively) now on first boot if /etc is found unpopulated. This also creates the infrastructure for generators to be notified via an environment variable whether they are running on the first boot, or not.
2014-06-26shutdown: rework messages during shutdownZbigniew Jędrzejewski-Szmek
When running in 'quiet' mode, the only message printed from shutdown binary would be 'Cannot finalize remaining file systems and devices, giving up.', the only log line at error level before switch back to initramfs. This is misleading, because in initramfs everything will be cleaned up properly. Avoid printing anything at error level before the attempt to switch back to initramfs. Rework the messages to contain a bit more information what is still remaining, to help people diagnose shutdown issues.
2014-03-06util: add timeout to generator executionLennart Poettering
2014-02-17Remove unused variable and two function stubsZbigniew Jędrzejewski-Szmek
2014-02-17Pass log config from systemd to systemd-shutdownZbigniew Jędrzejewski-Szmek
If PID 1 debug logging is enabled, it is nice to keep those settings when switching to systemd-shutdown binary, independently of whether this was done through /proc/cmdline options, or through runtime manipulations.
2013-12-18log: don't reopen /dev/console each time we call log_open()Lennart Poettering
Instead, force reopen it only if we really really have to.
2013-11-25shutdown: during final killing spree also send SIGHUP in addition to SIGTERM ↵Lennart Poettering
to deal with shells This makes shutdown a bit faster if debug-shell.service is enabled.
2013-11-18Remove duplicate includesKarel Zak
2013-11-08shutdown: unify handling of reboot() syscall a bitLennart Poettering
2013-11-07Support additional argument in rebootWaLyong Cho
reboot syscall can be performed with an additional argument. In some systems this functionality can be useful to modify the mode of the next boot performed by the bootloader.
2013-11-06util: unify reading of /proc/cmdlineLennart Poettering
Instead of individually checking for containers in each user do this once in a new call proc_cmdline() that read the file only if we are not in a container.
2013-11-06shutdown: trim the cgroup tree on loop iterationLennart Poettering
This way we leave the cgroup empty before exiting in a container which makes sure the container manager will get cgroup notification event https://bugs.freedesktop.org/show_bug.cgi?id=68370 https://bugzilla.redhat.com/show_bug.cgi?id=988883
2013-07-15build-sys: discover the path to kexec during build timeZbigniew Jędrzejewski-Szmek
https://bugs.freedesktop.org/show_bug.cgi?id=55248
2013-07-11shutdown: avoid malloc() if we canLennart Poettering
2013-07-11shutdown: fix /proc/cmdline reading of 'quiet'Kay Sievers
2013-07-05suppress status message output at shutdown when 'quiet' is givenKay Sievers
2013-04-09shutdown: print a nice message before returning to initrdLennart Poettering
2013-04-08shutdown: print a message when storage is finalizedLennart Poettering
2012-12-07shutdown, umount: use verbs consistentlyMichal Schmidt
Mounts are "unmounted". Swaps are "deactivated", not "turned off" nor "disabled". Loop and DM devices are "detached", not "deleted". Especially the deleting sounded a bit scary.
2012-12-07shutdown, umount: logging improvementsMichal Schmidt
In bugreports about hangs during the late shutdown we are often missing important information - what were we trying to unmount/detach when it hung. Instead of printing what we successfully unmounted, print what we are going to unmount/detach. And add messages to mark the completion of categories (mount/swap/loop/DM).
2012-12-07shutdown: downgrade a warningMichal Schmidt
All messages of the kind "not all done, %d left" are log_info, except the one for DM devices. Make it info too.
2012-11-28shutdown: don't pivot to /run/initramfs if already thereTom Gundersen
This allows systemd-shutdown to be installed as /run/initramfs/shutdown and take care of the proper teardown of the rootfs.
2012-11-16shutdown: readd explicit sync() when shutting downLennart Poettering
As it turns out reboot() doesn't actually imply a file system sync, but only a disk sync. Accordingly, readd explicit sync() invocations immediately before we invoke reboot(). This is much less dramatic than it might sounds as we umount all disks/read-only remount them anyway before going down.
2012-09-05shutdown: in containers, invoke reboot(2), too. Then fallback to exit() if ↵Lennart Poettering
CAP_SYS_BOOT is missing The kernel's PID namespaces support reboot(2) just fine, so let's make use of it if possible.
2012-09-05shutdown: remove explicit sync() invocationsLennart Poettering
The kernel implicitly does sync() anyway, hence there is no need to do that in userspace explicitly. This makes the "-n" switch to halt(8) a noop.
2012-08-12switch-root: remount to MS_PRIVATELennart Poettering
The kernel does not allow switching roots if things are mounted MS_SHARED. As a work-around, remount things MS_PRIVATE before switching roots. This should be fixed in the kernel for good. https://bugzilla.redhat.com/show_bug.cgi?id=847418
2012-08-10shutdown: recursively mark root as private before pivotDave Reisner
Because root is now recursively marked as shared on bootup, we need to recursively mark root as private. This prevents a pivot_root failure on shutdown: Cannot finalize remaining file systems and devices, giving up. pivot failed: Invalid argument
2012-07-17switch-root: don't wait for processesLennart Poettering
When we transition from the initrd to the main system, don't reap processes, so that they can be handled normally after deserialization.
2012-07-16Spelling fixes.Ville Skyttä
2012-07-13shutdown: add missing includeLennart Poettering
2012-07-13container: when shutting down in a container don't detach loop devicesLennart Poettering
We don't do device handling in containers, hence no loop devices either.
2012-07-13core: go on a killing spree when transitioning from initrd to main systemLennart Poettering
2012-07-10switch-root: reopen /dev/console before we switch rootLennart Poettering
2012-05-31mkdir: append _label to all mkdir() calls that explicitly set the selinux ↵Kay Sievers
context
2012-05-08sleep: implement suspend/hibernate as first class targetsLennart Poettering
2012-04-24shutdown: don't complain if we cannot lock memory, to make container ↵Lennart Poettering
shutdowns clean
2012-04-22shutdown: don't try to shut down DM devices in a containerLennart Poettering
2012-04-12shutdown: move shutdown to core since it replaces PID 1Lennart Poettering