If a crash occurs repeatedly after enabling kdump, the system goes
into a crash loop and the dump target may get filled up by vmcores.
This is likely to happen especially with early kdump.
This patch introduces 'final_action' option to kdump.conf, in order
for users to be able to power off the system even after capturing
a vmcore successfully.
Signed-off-by: Kazuhito Hagio <k-hagio(a)ab.jp.nec.com>
Cc: Dave Young <dyoung(a)redhat.com>
Cc: Lianbo Jiang <lijiang(a)redhat.com>
---
kdump-lib-initramfs.sh | 13 +++++++++++++
kdump.conf | 5 +++++
kdump.conf.5 | 6 ++++++
kdumpctl | 22 +++++++++++++++++++++-
4 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index f5155a4..9f482cd 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -70,6 +70,19 @@ get_kdump_confs()
;;
esac
;;
+ final_action)
+ case $config_val in
+ reboot)
+ FINAL_ACTION="systemctl reboot -f"
+ ;;
+ halt)
+ FINAL_ACTION="halt"
+ ;;
+ poweroff)
+ FINAL_ACTION="systemctl poweroff -f"
+ ;;
+ esac
+ ;;
esac
done < $KDUMP_CONF
diff --git a/kdump.conf b/kdump.conf
index 286ad27..6643e87 100644
--- a/kdump.conf
+++ b/kdump.conf
@@ -110,6 +110,11 @@
# reboot. Useful when non-root dump target is specified.
# The default option is "reboot".
#
+# final_action <reboot | halt | poweroff>
+# - Action to perform in case dumping succeeds.
+# Each action is same as the "default" directive above.
+# The default is "reboot".
+#
# force_rebuild <0 | 1>
# - By default, kdump initrd will only be rebuilt when necessary.
# Specify 1 to force rebuilding kdump initrd every time when kdump
diff --git a/kdump.conf.5 b/kdump.conf.5
index 990076e..72995c4 100644
--- a/kdump.conf.5
+++ b/kdump.conf.5
@@ -160,6 +160,12 @@ target is specified, the default action can be set as dump_to_rootfs.
That mean
dumping to target fails, dump vmcore to rootfs from initramfs context and reboot.
.RE
+.B final_action <reboot | halt | poweroff>
+.RS
+Action to perform in case dumping to the intended target succeeds. The default is
+"reboot". Each action is same as the "default" directive above.
+.RE
+
.B force_rebuild <0 | 1>
.RS
By default, kdump initrd will only be rebuilt when necessary.
diff --git a/kdumpctl b/kdumpctl
index ca47705..992aaa8 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -228,7 +228,7 @@ check_config()
case "$config_opt" in
\#* | "")
;;
- raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes)
+ raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|final_action|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes)
# remove inline comments after the end of a directive.
config_val=$(strip_comments $config_val)
[ -z "$config_val" ] && {
@@ -248,6 +248,7 @@ check_config()
done < $KDUMP_CONFIG_FILE
check_default_config || return 1
+ check_final_action_config || return 1
check_fence_kdump_config || return 1
@@ -954,6 +955,25 @@ check_default_config()
fi
}
+check_final_action_config()
+{
+ local final_action
+
+ final_action=$(awk '$1 ~ /^final_action$/ {print $2;}' $KDUMP_CONFIG_FILE)
+ if [ -z "$final_action" ]; then
+ return 0
+ else
+ case "$final_action" in
+ reboot|halt|poweroff)
+ return 0
+ ;;
+ *)
+ echo $"Usage kdump.conf: final_action {reboot|halt|poweroff}"
+ return 1
+ esac
+ fi
+}
+
start()
{
check_dump_feasibility
--
2.18.0