On Wed, Dec 08, 2021 at 10:25:32AM +0800, Coiby Xu wrote:
Add a helper function to get dump mode. The dump mode would be
- fadump if fadump=on or fadump=nocma
- kdump if fadump=off or empty fadump
Otherwise return 1.
Also add another helper function to return a kernel's dump mode.
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
kdumpctl | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/kdumpctl b/kdumpctl
index 2f05c76..f42a8c6 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1317,6 +1317,40 @@ get_grub_kernel_boot_parameter()
grubby --info="$_kernel_path" | sed -En -e
"/^args=.*$/{s/^.*(\s|\")${_para}=(\S*).*\"$/\2/p;q}"
}
+# get dump mode by fadump value
+# return
+# - fadump, if fadump=on or fadump=nocma
+# - kdump, if fadump=off or empty fadump, return kdump
+# - error if otherwise
+get_dump_mode_by_fadump_val()
+{
+ local _fadump_val=$1
+
+ if [[ -z $_fadump_val ]] || [[ $_fadump_val == off ]]; then
+ echo -n kdump
+ elif [[ $_fadump_val == on ]] || [[ $_fadump_val == nocma ]]; then
+ echo -n fadump
+ else
+ derror "invalid fadump=$_fadump_val"
+ retunr 1
+ fi
+}
+
+# get dump mode of a specific kernel
+# based on its fadump kernel cmdline parameter
+get_dump_mode_by_kernel()
Is it better named as get_dump_mode_by_kernel_cmdline()?
Or it will be confused with something in live system by polling sysfs, say,
FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered"
Thanks,
Pingfan