kdump-lib.sh: Use a more generic helper to detect omitted dracut module

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
This commit is contained in:
Kairui Song 2020-10-15 18:22:15 +08:00
parent 647aa56b53
commit 4464bcf8f3
2 changed files with 13 additions and 20 deletions

View File

@ -455,28 +455,21 @@ get_ifcfg_filename() {
echo -n "${ifcfg_file}"
}
# returns 0 when omission of watchdog module is desired in dracut_args
# returns 0 when omission of a module is desired in dracut_args
# returns 1 otherwise
is_wdt_mod_omitted() {
local dracut_args
local ret=1
is_dracut_mod_omitted() {
local dracut_args dracut_mod=$1
dracut_args=$(grep "^dracut_args" /etc/kdump.conf)
[[ -z $dracut_args ]] && return $ret
set -- $(grep "^dracut_args" /etc/kdump.conf)
while [ $# -gt 0 ]; do
case $1 in
-o|--omit)
[[ " ${2//[^[:alnum:]]/ } " == *" $dracut_mod "* ]] && return 0
esac
shift
done
eval set -- $dracut_args
while :; do
[[ -z $1 ]] && break
case $1 in
-o|--omit)
echo $2 | grep -qw "watchdog"
[[ $? == 0 ]] && ret=0
break
esac
shift
done
return $ret
return 1
}
is_wdt_active() {

View File

@ -452,7 +452,7 @@ check_drivers_modified()
fi
# Include watchdog drivers if watchdog module is not omitted
is_wdt_mod_omitted || _new_drivers+=" $(get_watchdog_drvs)"
is_dracut_mod_omitted watchdog || _new_drivers+=" $(get_watchdog_drvs)"
[ -z "$_new_drivers" ] && return 0
_old_drivers="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')"