On Mon, May 6, 2019 at 4:23 PM Dave Young <dyoung(a)redhat.com> wrote:
On 05/06/19 at 03:17pm, Kairui Song wrote:
> We don't necessarily have to always rebuild the initramfs when
> extra_modules is set, instead just detect if any module is updated
> and only rebuild initramfs if found any updated kernel module.
>
> Signed-off-by: Kairui Song <kasong(a)redhat.com>
> ---
> kdumpctl | 20 +++++++++++++++-----
> 1 file changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/kdumpctl b/kdumpctl
> index 3f36903..d3d1325 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -334,6 +334,21 @@ check_files_modified()
> files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS
$CORE_COLLECTOR"
> [[ -e /etc/fstab ]] && files="$files /etc/fstab"
>
> + # Check for any updated extra module
> + EXTRA_MODULES="$(grep ^extra_modules $KDUMP_CONFIG_FILE | sed
's/^extra_modules\s*//')"
> + for _module in $EXTRA_MODULES; do
> + _module_file="$(modinfo -k "$kdump_kver" -n
"$_module" 2>/dev/null)"
> + if [ $? -eq 0 ]; then
> + files="$files $_module_file"
> + else
> + # If it's not a module nor builtin, give an error
> + modprobe --set-version "$kdump_kver" --dry-run
"$_module" &>/dev/null
> + if [ $? -ne 0 ]; then
> + echo "Invalid kernel module name: $_module"
Maybe "Module $_module not found" is better
Good idea, will update.
> + fi
> + fi
> + done
> +
> check_exist "$files" && check_executable
"$EXTRA_BINS"
> [ $? -ne 0 ] && return 2
>
> @@ -526,7 +541,6 @@ check_system_modified()
>
> check_rebuild()
> {
> - local extra_modules
> local capture_capable_initrd="1"
> local _force_rebuild force_rebuild="0"
> local _force_no_rebuild force_no_rebuild="0"
> @@ -566,10 +580,6 @@ check_rebuild()
> return 0
> fi
>
> - #will rebuild every time if extra_modules are specified
> - extra_modules=`grep ^extra_modules $KDUMP_CONFIG_FILE`
> - [ -n "$extra_modules" ] && force_rebuild="1"
> -
> #check to see if dependent files has been modified
> #since last build of the image file
> if [ -f $TARGET_INITRD ]; then
> --
> 2.20.1
>
Thanks
Dave
--
Best Regards,
Kairui Song