Hi,

some additional information/thoughts:

Systemds builtin kexec.target is indeed the indended way to do kexec
reboots by the developers. See man systemctl:

kexec
 Shut down and reboot the system via kexec. This is mostly equivalent to
start kexec.target --irreversible, but also prints a wall message to all
users. If combined with --force, shutdown of all running services is
skipped, however all processes are killed and all file systems are
unmounted or mounted read-only, immediately followed by the reboot.


Thus I suggest using the intended way to do kexec reboots on systemd
enabled installations.

This also means breaking the old SysV behavior - when the current target
is kexec, imho you should _always_ load a new kernel image, regardless
of the LOAD_KEXEC value in /etc/default/kexec.

As a first step, the SysV LSB loader script could be modified (with a
slightly modified patch from my first report):

--- debian/kexec-load.init.d.org        2014-11-24 05:02:10.000000000 +0100
+++ debian/kexec-load.init.d    2015-06-25 17:16:34.152465942 +0200
@@ -102,12 +102,14 @@
        ;;
   stop)
        # If running systemd, we want kexec reboot only if current
-       # command is reboot
+       # target is kexec (determined via systemd-exec.service)
        if [ -d /run/systemd/system ]; then
-               systemctl list-jobs systemd-reboot.service | grep -q
systemd-reboot.service
+               systemctl list-jobs systemd-kexec.service | grep -q
systemd-kexec.service
                if [ $? -ne 0 ]; then
                        exit 0
                fi
+               # Override LOAD_EXEC option, because kexec target always
implies kexec reboot
+               LOAD_KEXEC="true"
        fi
        do_stop
        ;;


The SysV LSB kexec script also has to be modified, kexec invocation is
done by systemd (when everything has been properly terminated/mounted
read only), so it should be skipped in the LSB script when running
systemd. If you don't skip it, you will end up with race conditions and
possible data corruption (as explained earlier).

+++ debian/kexec.init.d 2015-06-25 17:21:02.405402935 +0200
@@ -36,7 +36,10 @@
        exit 3
        ;;
   stop)
-       do_stop
+       # Systemd has its own kexec service (which will call the kexec
binary), so skip, if running with systemd
+       if [ ! -d /run/systemd/system ]; then
+               do_stop
+       fi
        ;;
   *)
        echo "Usage: $0 start|stop" >&2



Both modifications should make kexec work reliably on systemd enabled
installations, kexec reboots will have to be performed/triggered with
'systemctl kexec' (or 'systemctl start kexec.target'), other reboot
methods will result in cold reboots, the value of LOAD_KEXEC in
/etc/default/kexec is ignored.

The old behavior will not change when running SysV as init system.


As a second step, I would suggest creating a proper systemd unit file to
do the kernel image loading, instead of relying on systemd-sysv to
autogenerate it from the SysV LSB init script.


Cheers,
Thomas


-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to