On Wed, Dec 01, 2021 at 02:15:26PM +0100, Philipp Rudo wrote:
Hi Coiby,
On Fri, 19 Nov 2021 11:23:03 +0800
Coiby Xu <coxu(a)redhat.com> wrote:
> This helper function will be used to retrieve the value of kernel
> cmdline parameters including crashkernel, fadump, swiotlb and etc.
>
> Signed-off-by: Coiby Xu <coxu(a)redhat.com>
> ---
> kdumpctl | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/kdumpctl b/kdumpctl
> index 1938968..6f1afad 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -1304,6 +1304,15 @@ get_default_crashkernel()
> local _dump_mode=$1
>
> echo -n "$(kdump_get_arch_recommend_crashkernel
"$_dump_mode")"
> + }
wrong indentation
Corrected in v2, thanks!
> +
> +# Read kernel cmdline parameter for a specific kernel
> +# $1: kernel path, DEFAULT or kernel path
> +# $2: kernel cmldine parameter
> +get_grub_kernel_boot_parameter() {
> + local _kernel_path=$1 _para=$2
> +
> + grubby --info="$_kernel_path" | sed -n
's/^args="\(.*\)"$/\1/p' | sed -n
"s/^.*${_para}=\(\S*\).*/\1/p"
1. what happens with $_kernel_path=ALL ? in that case this function
will return multiple lines.
2. you can merge the two calls to sed and drop the second pipe
3. the second regex is frail to partial matches, e.g.
crashkernel=256M and foo-crashkernel=256M will return the same
value which might not be what you want.
The way I see it the sed call should look like this
sed -En -e "/^args=.*$/{s/^.*(\s|\")${_para}=(\S*).*\"$/\2/p;q}"
this will give you the first appearance of of $_para from the grubby
output, which AFAIK is from the last kernel installed.
Applied to v2, thanks!
Thanks
Philipp
> }
>
> reset_crashkernel()
--
Best regards,
Coiby