This patch introduce a new kdump-capture.service which is used to run
kdump.sh.
kdump-capture.service has OnFailure=emergency.target and
OnFailureIsolate=yes set. When kdump.sh fails, the kdump emergency
service will be triggered and enter the error handling path.
In 2nd kernel, the default target for systemd is initrd.target, so we
put kdump-capture.service in initrd.target.wants/ and by that, system
will start kdump-capture as part of the boot process.
kdump.sh used to run in dracut-pre-pivot hook. Now kdump-capture.service
is placed after dracut-pre-pivot.service and other dependencies are all
copied from dracut-pre-pivot.service. So the start point of
kdump.sh will be almost the same as it used to be.
Signed-off-by: WANG Chao <chaowang(a)redhat.com>
---
dracut-kdump-capture.service | 23 +++++++++++++++++++++++
dracut-kdump.sh | 5 ++---
dracut-module-setup.sh | 4 +++-
kexec-tools.spec | 2 ++
4 files changed, 30 insertions(+), 4 deletions(-)
create mode 100644 dracut-kdump-capture.service
diff --git a/dracut-kdump-capture.service b/dracut-kdump-capture.service
new file mode 100644
index 0000000..febe2eb
--- /dev/null
+++ b/dracut-kdump-capture.service
@@ -0,0 +1,23 @@
+[Unit]
+Description=Kdump Vmcore Save Service
+After=initrd.target initrd-parse-etc.service sysroot.mount
+After=dracut-initqueue.service dracut-pre-mount.service dracut-mount.service
dracut-pre-pivot.service
+Before=initrd-cleanup.service
+ConditionPathExists=/etc/initrd-release
+OnFailure=emergency.target
+OnFailureIsolate=yes
+
+[Service]
+Environment=DRACUT_SYSTEMD=1
+Environment=NEWROOT=/sysroot
+Type=oneshot
+ExecStart=/bin/kdump.sh
+StandardInput=null
+StandardOutput=syslog
+StandardError=syslog+console
+KillMode=process
+RemainAfterExit=yes
+
+# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
+# terminates cleanly.
+KillSignal=SIGHUP
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 1960b7e..d092e04 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -165,8 +165,7 @@ fence_kdump_notify
get_host_ip
if [ $? -ne 0 ]; then
echo "kdump: get_host_ip exited with non-zero status!"
- do_default_action
- do_final_action
+ exit 1
fi
if [ -z "$DUMP_INSTRUCTION" ]; then
@@ -188,7 +187,7 @@ if [ $? -ne 0 ]; then
fi
if [ $DUMP_RETVAL -ne 0 ]; then
- do_default_action
+ exit 1
fi
do_final_action
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index bd7722c..9e099a9 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -553,9 +553,11 @@ install() {
inst "/bin/cut" "/bin/cut"
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
- inst_hook pre-pivot 9999 "$moddir/kdump.sh"
inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
inst "$moddir/kdump-lib-2.sh" "/lib/kdump-lib-2.sh"
+ inst "$moddir/kdump.sh" "/usr/bin/kdump.sh"
+ inst "$moddir/kdump-capture.service"
"$systemdsystemunitdir/kdump-capture.service"
+ ln_r "$systemdsystemunitdir/kdump-capture.service"
"$systemdsystemunitdir/initrd.target.wants/kdump-capture.service"
inst "$moddir/kdump-error-handler.sh"
"/usr/bin/kdump-error-handler.sh"
# Replace existing emergency service
cp "$moddir/kdump-emergency.service"
"$initdir/$systemdsystemunitdir/emergency.service"
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 21cfe6e..b327f75 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -38,6 +38,7 @@ Source102: dracut-monitor_dd_progress
Source103: dracut-kdump-lib-2.sh
Source104: dracut-kdump-error-handler.sh
Source105: dracut-kdump-emergency.service
+Source106: dracut-kdump-capture.service
Requires(post): systemd-units
Requires(preun): systemd-units
@@ -204,6 +205,7 @@ cp %{SOURCE102}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpb
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 %{SOURCE105}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE105}}
+cp %{SOURCE106}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE106}}
chmod 755
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE100}}
chmod 755
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE101}}
--
1.9.3