From 27b5ab3cbb63923f92bd67ca9fa00edf45767931 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 5 Jan 2022 11:53:09 +0800 Subject: [PATCH] add a helper function to read kernel cmdline parameter from grubby --info Resolves: bz1895258 Upstream: Fedora Conflict: None commit fb9e6838abef1e3a2ba43966f58a1f146989b148 Author: Coiby Xu Date: Tue Nov 16 06:48:40 2021 +0800 add a helper function to read kernel cmdline parameter from grubby --info This helper function will be used to retrieve the value of kernel cmdline parameters including crashkernel, fadump, swiotlb and etc. Suggested-by: Philipp Rudo Reviewed-by: Pingfan Liu Signed-off-by: Coiby Xu Signed-off-by: Coiby Xu --- kdumpctl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kdumpctl b/kdumpctl index 8b56fc6..85efaa1 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1306,6 +1306,17 @@ get_default_crashkernel() kdump_get_arch_recommend_crashkernel "$_dump_mode" } +# Read kernel cmdline parameter for a specific kernel +# $1: kernel path, DEFAULT or kernel path, ALL not accepted +# $2: kernel cmldine parameter +get_grub_kernel_boot_parameter() +{ + local _kernel_path=$1 _para=$2 + + [[ $_kernel_path == ALL ]] && derror "kernel_path=ALL invalid for get_grub_kernel_boot_parameter" && return 1 + grubby --info="$_kernel_path" | sed -En -e "/^args=.*$/{s/^.*(\s|\")${_para}=(\S*).*\"$/\2/p;q}" +} + reset_crashkernel() { local kernel=$1 entry crashkernel_default