kdump-lib-initramfs.sh: using -force option when poweroff

If default action is poweroff, we can observe that the machine is
rebooted, instead of poweroff. That is due to the following two race
processes:
    systemctl poweroff
    systemctl reboot -f
which is launched by kdump-error-handle.sh.

Unfortunately, although both of them are executed in systemd block
mode, but due to poweroff will tear down some internal things in
systemd, there is no guarantee for the block mode. As we can see
the msg "Failed to execute operation: Connection reset by peer",
which is thrown by "systemctl reboot -f".

poweroff and reboot share most of code, if one fails, then the other
should also fails, so it is meaningless to use reboot as the backup of
poweroff. Using "systemctl poweroff -f", the sdbus will teared down
immediately, which prevent the following "systemctl reboot -f" from
executing. Meanwhile, as man systemctl says:
    -f, --force
        When used with enable, overwrite any existing conflicting symlinks.

        When used with halt, poweroff, reboot or kexec, execute the selected
        operation without shutting down all units. However, all processes will
        be killed forcibly and all file systems are unmounted or remounted read-only.

Hence, replacing the 'poweroff' with 'systemctl poweroff -f'

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Pingfan Liu 2018-12-04 11:09:43 +08:00 committed by Kairui Song
parent 9c2dc28713
commit 89565289c6

View File

@ -63,7 +63,7 @@ get_kdump_confs()
DEFAULT_ACTION="halt"
;;
poweroff)
DEFAULT_ACTION="poweroff"
DEFAULT_ACTION="systemctl poweroff -f"
;;
dump_to_rootfs)
DEFAULT_ACTION="dump_to_rootfs"