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 <prudo@redhat.com>
Reviewed-by: Pingfan Liu <piliu@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
Coiby Xu 2021-11-16 06:48:40 +08:00
parent 796d0f6fd2
commit fb9e6838ab
1 changed files with 11 additions and 0 deletions

View File

@ -1280,6 +1280,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