[kexec-tools] Introduce kdump capture service

WANG Chao wangchao at fedoraproject.org
Tue Aug 5 06:04:02 UTC 2014


commit 2276b8561cccbab4c51b437692a709c1c2c5213a
Author: WANG Chao <chaowang at redhat.com>
Date:   Thu May 8 19:37:16 2014 +0800

    Introduce kdump capture service
    
    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 at redhat.com>
    Acked-by: Vivek Goyal <vgoyal at redhat.com>
    Acked-by: Dave Young <dyoung at redhat.com>

 dracut-kdump-capture.service |   30 ++++++++++++++++++++++++++++++
 dracut-kdump.sh              |    5 ++---
 dracut-module-setup.sh       |    4 +++-
 kexec-tools.spec             |    2 ++
 4 files changed, 37 insertions(+), 4 deletions(-)
---
diff --git a/dracut-kdump-capture.service b/dracut-kdump-capture.service
new file mode 100644
index 0000000..57139c9
--- /dev/null
+++ b/dracut-kdump-capture.service
@@ -0,0 +1,30 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+[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 83c1e96..600e84e 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -179,8 +179,7 @@ fi
 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
@@ -202,7 +201,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 9e73f53..365d8f6 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -577,9 +577,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 "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.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"
     inst "$moddir/kdump-error-handler.service" "$systemdsystemunitdir/kdump-error-handler.service"
     # Replace existing emergency service
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 7d64852..e3774e2 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -39,6 +39,7 @@ Source102: dracut-monitor_dd_progress
 Source103: dracut-kdump-error-handler.sh
 Source104: dracut-kdump-emergency.service
 Source105: dracut-kdump-error-handler.service
+Source106: dracut-kdump-capture.service
 
 Requires(post): systemd-units
 Requires(preun): systemd-units
@@ -216,6 +217,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}}
 


More information about the scm-commits mailing list