From 13a24c49ab397b968732b2740bf9f3f40a28fd1c Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Nov 09 2021 13:45:31 +0000 Subject: Merge kdump-error-handler.sh into kdump.sh upstream: fedora resolves: bz2003832 conflict: none commit e7118d1de84b604b25b2f6332f4ae071a9dc08fd Author: Kairui Song Date: Mon Aug 2 00:50:22 2021 +0800 Merge kdump-error-handler.sh into kdump.sh kdump-error-handler.sh does nothing except calling three functions, it can be easily merged into kdump.sh by using a parameter to run the error handling routine. kdump-lib-initramfs.sh was created to hold the three shared functions and related code, so by merging these two files, kdump-lib-initramfs.sh can be simplified by a lot. Following up commits will clean up kdump-lib-initramfs.sh. Signed-off-by: Kairui Song Acked-by: Philipp Rudo Signed-off-by: Tao Liu --- diff --git a/dracut-kdump-emergency.service b/dracut-kdump-emergency.service index f2f6fad..0cf7051 100644 --- a/dracut-kdump-emergency.service +++ b/dracut-kdump-emergency.service @@ -12,7 +12,7 @@ Environment=HOME=/ Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot WorkingDirectory=/ -ExecStart=/bin/kdump-error-handler.sh +ExecStart=/bin/kdump.sh --error-handler ExecStopPost=-/bin/rm -f -- /.console_lock Type=oneshot StandardInput=tty-force diff --git a/dracut-kdump-error-handler.sh b/dracut-kdump-error-handler.sh deleted file mode 100755 index fc2b932..0000000 --- a/dracut-kdump-error-handler.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -. /lib/kdump-lib-initramfs.sh - -set -o pipefail -export PATH=$PATH:$KDUMP_SCRIPT_DIR - -get_kdump_confs -do_failure_action -do_final_action diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 3c165b3..352cad5 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -1,9 +1,7 @@ #!/bin/sh - -# continue here only if we have to save dump. -if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then - exit 0 -fi +# +# The main kdump routine in capture kernel +# . /lib/dracut-lib.sh . /lib/kdump-lib-initramfs.sh @@ -288,6 +286,19 @@ fence_kdump_notify() fi } +if [ "$1" = "--error-handler" ]; then + get_kdump_confs + do_failure_action + do_final_action + + exit $? +fi + +# continue here only if we have to save dump. +if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then + exit 0 +fi + read_kdump_confs fence_kdump_notify diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4fb013d..d6011ee 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1039,7 +1039,6 @@ install() { inst "$moddir/kdump.sh" "/usr/bin/kdump.sh" inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service" systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service - inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh" # Replace existing emergency service and emergency target cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service" cp "$moddir/kdump-emergency.target" "$initdir/$systemdsystemunitdir/emergency.target" diff --git a/kexec-tools.spec b/kexec-tools.spec index dc3e814..ea1b8e0 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -51,7 +51,6 @@ Source35: supported-kdump-targets.txt Source100: dracut-kdump.sh Source101: dracut-module-setup.sh Source102: dracut-monitor_dd_progress -Source103: dracut-kdump-error-handler.sh Source104: dracut-kdump-emergency.service Source106: dracut-kdump-capture.service Source107: dracut-kdump-emergency.target @@ -236,7 +235,6 @@ mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpba cp %{SOURCE100} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} cp %{SOURCE101} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE102}} -cp %{SOURCE103} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE103}} cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE104}} cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE106}} cp %{SOURCE107} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE107}}