If GRUB_ETC_DEFAULT use crashkernel=auto or
crashkernel=OLD_DEFAULT_CRASHKERNEL, it should be updated as well.
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
kdumpctl | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/kdumpctl b/kdumpctl
index 42730cb..5027f47 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1562,6 +1562,34 @@ reset_crashkernel()
fi
}
+# update the crashkernel value in GRUB_ETC_DEFAULT if necessary
+#
+# called by reset_crashkernel_after_update and inherit its array variable
+# _crashkernel_vals
+update_crashkernel_in_grub_etc_default_after_update()
+{
+ local _crashkernel _fadump_val
+ local _dump_mode _old_default_crashkernel _new_default_crashkernel
+
+ _crashkernel=$(_read_kernel_cmdline_in_grub_etc_default crashkernel)
+
+ if [[ -z $_crashkernel ]]; then
+ return
+ fi
+
+ _fadump_val=$(read_kernel_cmdline_in_grub_etc_default fadump)
+ _dump_mode=$(get_dump_mode_by_fadump_val "$_fadump_val")
+
+ _old_default_crashkernel=${_crashkernel_vals[old_${_dump_mode}]}
+ _new_default_crashkernel=${_crashkernel_vals[new_${_dump_mode}]}
+
+ if [[ $_crashkernel == auto ]] ||
+ [[ $_crashkernel == "$_old_default_crashkernel" &&
+ $_new_default_crashkernel != "$_old_default_crashkernel" ]]; then
+ _update_kernel_cmdline_in_grub_etc_default crashkernel
"$_new_default_crashkernel"
+ fi
+}
+
# shellcheck disable=SC2154 # false positive when dereferencing an array
reset_crashkernel_after_update()
{
@@ -1590,6 +1618,8 @@ reset_crashkernel_after_update()
fi
fi
done
+
+ update_crashkernel_in_grub_etc_default_after_update
}
# read the value of an environ variable from given environ file path
--
2.34.1