Petr Šabata f5bf49
#!/bin/bash --norc
Petr Šabata f5bf49
# New mkdumprd
Petr Šabata f5bf49
#
Petr Šabata f5bf49
# Copyright 2011 Red Hat, Inc.
Petr Šabata f5bf49
#
Petr Šabata f5bf49
# Written by Cong Wang <amwang@redhat.com>
Petr Šabata f5bf49
#
Petr Šabata f5bf49
dcb59c
if [[ -f /etc/sysconfig/kdump ]]; then
DistroBaker 5cac7c
	. /etc/sysconfig/kdump
DistroBaker 5cac7c
fi
DistroBaker 5cac7c
Petr Šabata f5bf49
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
Petr Šabata f5bf49
. $dracutbasedir/dracut-functions.sh
Petr Šabata f5bf49
. /lib/kdump/kdump-lib.sh
DistroBaker 624a64
. /lib/kdump/kdump-logger.sh
Petr Šabata f5bf49
export IN_KDUMP=1
Petr Šabata f5bf49
DistroBaker 5cac7c
#initiate the kdump logger
f6d6b6
if ! dlog_init; then
DistroBaker 5cac7c
	echo "failed to initiate the kdump logger."
DistroBaker 5cac7c
	exit 1
DistroBaker 5cac7c
fi
DistroBaker 5cac7c
Petr Šabata f5bf49
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
Petr Šabata f5bf49
SAVE_PATH=$(get_save_path)
Petr Šabata f5bf49
OVERRIDE_RESETTABLE=0
Petr Šabata f5bf49
Petr Šabata f5bf49
extra_modules=""
dd08f1
dracut_args=( --add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o "plymouth dash resume ifcfg earlykdump" )
Petr Šabata f5bf49
Petr Šabata f5bf49
readonly MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)"
Petr Šabata f5bf49
[ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed."
Petr Šabata f5bf49
readonly MKDUMPRD_TMPMNT="$MKDUMPRD_TMPDIR/target"
Petr Šabata f5bf49
Petr Šabata f5bf49
trap '
Petr Šabata f5bf49
    ret=$?;
Petr Šabata f5bf49
    is_mounted $MKDUMPRD_TMPMNT && umount -f $MKDUMPRD_TMPMNT;
Petr Šabata f5bf49
    [[ -d $MKDUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKDUMPRD_TMPDIR";
Petr Šabata f5bf49
    exit $ret;
Petr Šabata f5bf49
    ' EXIT
Petr Šabata f5bf49
Petr Šabata f5bf49
# clean up after ourselves no matter how we die.
Petr Šabata f5bf49
trap 'exit 1;' SIGINT
Petr Šabata f5bf49
Petr Šabata f5bf49
add_dracut_arg() {
dd08f1
    dracut_args+=( "$@" )
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
add_dracut_mount() {
dd08f1
    add_dracut_arg "--mount" "$1"
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
add_dracut_sshkey() {
dd08f1
    add_dracut_arg "--sshkey" "$1"
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
# caller should ensure $1 is valid and mounted in 1st kernel
Petr Šabata f5bf49
to_mount() {
d07b20
    local _target=$1 _fstype=$2 _options=$3 _sed_cmd _new_mntpoint _pdev
Petr Šabata f5bf49
bf4667
    _new_mntpoint=$(get_kdump_mntpoint_from_target "$_target")
bf4667
    _fstype="${_fstype:-$(get_fs_type_from_target "$_target")}"
bf4667
    _options="${_options:-$(get_mntopt_from_target "$_target")}"
Petr Šabata f5bf49
    _options="${_options:-defaults}"
Petr Šabata f5bf49
Petr Šabata f5bf49
    if [[ "$_fstype" == "nfs"* ]]; then
Petr Šabata f5bf49
        _pdev=$_target
d07b20
        _sed_cmd+='s/,addr=[^,]*//;'
d07b20
        _sed_cmd+='s/,proto=[^,]*//;'
d07b20
        _sed_cmd+='s/,clientaddr=[^,]*//;'
Petr Šabata f5bf49
    else
Petr Šabata f5bf49
        # for non-nfs _target converting to use udev persistent name
bf4667
        _pdev="$(kdump_get_persistent_dev "$_target")"
bf4667
        if [[ -z $_pdev ]]; then
Petr Šabata f5bf49
            return 1
Petr Šabata f5bf49
        fi
Petr Šabata f5bf49
    fi
Petr Šabata f5bf49
Petr Šabata f5bf49
    # mount fs target as rw in 2nd kernel
d07b20
    _sed_cmd+='s/\(^\|,\)ro\($\|,\)/\1rw\2/g;'
Petr Šabata f5bf49
    # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd
Petr Šabata f5bf49
    # kernel, filter it out here.
d07b20
    _sed_cmd+='s/\(^\|,\)noauto\($\|,\)/\1/g;'
Petr Šabata f5bf49
    # drop nofail or nobootwait
d07b20
    _sed_cmd+='s/\(^\|,\)nofail\($\|,\)/\1/g;'
d07b20
    _sed_cmd+='s/\(^\|,\)nobootwait\($\|,\)/\1/g;'
d07b20
d07b20
    _options=$(echo "$_options" | sed "$_sed_cmd")
Petr Šabata f5bf49
Petr Šabata f5bf49
    echo "$_pdev $_new_mntpoint $_fstype $_options"
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
#Function: get_ssh_size
Petr Šabata f5bf49
#$1=dump target
Petr Šabata f5bf49
#called from while loop and shouldn't read from stdin, so we're using "ssh -n"
Petr Šabata f5bf49
get_ssh_size() {
033d4c
    local _out
033d4c
    local _opt=("-i" "$SSH_KEY_LOCATION" "-o" "BatchMode=yes" "-o" "StrictHostKeyChecking=yes")
033d4c
033d4c
    if ! _out=$(ssh -q -n "${_opt[@]}" "$1" "df" "--output=avail" "$SAVE_PATH"); then
Petr Šabata f5bf49
        perror_exit "checking remote ssh server available size failed."
033d4c
    fi
Petr Šabata f5bf49
033d4c
    echo -n "$_out" | tail -1
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
#mkdir if save path does not exist on ssh dump target
Petr Šabata f5bf49
#$1=ssh dump target
Petr Šabata f5bf49
#caller should ensure write permission on $1:$SAVE_PATH
Petr Šabata f5bf49
#called from while loop and shouldn't read from stdin, so we're using "ssh -n"
Petr Šabata f5bf49
mkdir_save_path_ssh()
Petr Šabata f5bf49
{
Petr Šabata f5bf49
    local _opt _dir
153906
    _opt=(-i "$SSH_KEY_LOCATION" -o BatchMode=yes -o StrictHostKeyChecking=yes)
f6d6b6
    ssh -qn "${_opt[@]}" "$1" mkdir -p "$SAVE_PATH" &>/dev/null || \
Petr Šabata f5bf49
        perror_exit "mkdir failed on $1:$SAVE_PATH"
Petr Šabata f5bf49
f6d6b6
    # check whether user has write permission on $1:$SAVE_PATH
f6d6b6
    _dir=$(ssh -qn "${_opt[@]}" "$1" mktemp -dqp "$SAVE_PATH" 2>/dev/null) || \
Petr Šabata f5bf49
        perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination"
bf4667
    ssh -qn "${_opt[@]}" "$1" rmdir "$_dir"
Petr Šabata f5bf49
Petr Šabata f5bf49
    return 0
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
#Function: get_fs_size
Petr Šabata f5bf49
#$1=dump target
Petr Šabata f5bf49
get_fs_size() {
965870
    df --output=avail "$(get_mntpoint_from_target "$1")/$SAVE_PATH" | tail -1
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
#Function: get_raw_size
Petr Šabata f5bf49
#$1=dump target
Petr Šabata f5bf49
get_raw_size() {
0d4248
    fdisk -s "$1"
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
#Function: check_size
Petr Šabata f5bf49
#$1: dump type string ('raw', 'fs', 'ssh')
Petr Šabata f5bf49
#$2: dump target
Petr Šabata f5bf49
check_size() {
Petr Šabata f5bf49
    local avail memtotal
Petr Šabata f5bf49
Petr Šabata f5bf49
    memtotal=$(awk '/MemTotal/{print $2}' /proc/meminfo)
Petr Šabata f5bf49
    case "$1" in
Petr Šabata f5bf49
        raw)
Petr Šabata f5bf49
            avail=$(get_raw_size "$2")
Petr Šabata f5bf49
            ;;
Petr Šabata f5bf49
        ssh)
Petr Šabata f5bf49
            avail=$(get_ssh_size "$2")
Petr Šabata f5bf49
            ;;
Petr Šabata f5bf49
        fs)
Petr Šabata f5bf49
            avail=$(get_fs_size "$2")
Petr Šabata f5bf49
            ;;
Petr Šabata f5bf49
        *)
Petr Šabata f5bf49
            return
f6d6b6
    esac || perror_exit "Check dump target size failed"
Petr Šabata f5bf49
bf4667
    if [[ "$avail" -lt "$memtotal" ]]; then
DistroBaker 5cac7c
        dwarn "Warning: There might not be enough space to save a vmcore."
DistroBaker 5cac7c
        dwarn "         The size of $2 should be greater than $memtotal kilo bytes."
Petr Šabata f5bf49
    fi
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
check_save_path_fs()
Petr Šabata f5bf49
{
Petr Šabata f5bf49
    local _path=$1
Petr Šabata f5bf49
dcb59c
    if [[ ! -d $_path ]]; then
Petr Šabata f5bf49
        perror_exit "Dump path $_path does not exist."
Petr Šabata f5bf49
    fi
Petr Šabata f5bf49
}
Petr Šabata f5bf49
b9cefb
mount_failure()
b9cefb
{
b9cefb
    local _target=$1
b9cefb
    local _mnt=$2
b9cefb
    local _fstype=$3
b9cefb
    local msg="Failed to mount $_target"
b9cefb
dcb59c
    if [[ -n "$_mnt" ]]; then
b9cefb
        msg="$msg on $_mnt"
b9cefb
    fi
b9cefb
b9cefb
    msg="$msg for kdump preflight check."
b9cefb
b9cefb
    if [[ $_fstype = "nfs" ]]; then
b9cefb
        msg="$msg Please make sure nfs-utils has been installed."
b9cefb
    fi
b9cefb
b9cefb
    perror_exit "$msg"
b9cefb
}
b9cefb
Petr Šabata f5bf49
check_user_configured_target()
Petr Šabata f5bf49
{
Petr Šabata f5bf49
    local _target=$1 _cfg_fs_type=$2 _mounted
bf4667
    local _mnt=$(get_mntpoint_from_target "$_target")
bf4667
    local _opt=$(get_mntopt_from_target "$_target")
bf4667
    local _fstype=$(get_fs_type_from_target "$_target")
Petr Šabata f5bf49
dcb59c
    if [[ -n "$_fstype" ]]; then
Petr Šabata f5bf49
        # In case of nfs4, nfs should be used instead, nfs* options is deprecated in kdump.conf
Petr Šabata f5bf49
        [[ $_fstype = "nfs"* ]] && _fstype=nfs
Petr Šabata f5bf49
dcb59c
        if [[ -n "$_cfg_fs_type" ]] && [[ "$_fstype" != "$_cfg_fs_type" ]]; then
Petr Šabata f5bf49
            perror_exit "\"$_target\" have a wrong type config \"$_cfg_fs_type\", expected \"$_fstype\""
Petr Šabata f5bf49
        fi
Petr Šabata f5bf49
    else
Petr Šabata f5bf49
        _fstype="$_cfg_fs_type"
Petr Šabata f5bf49
        _fstype="$_cfg_fs_type"
Petr Šabata f5bf49
    fi
Petr Šabata f5bf49
Petr Šabata f5bf49
    # For noauto mount, mount it inplace with default value.
Petr Šabata f5bf49
    # Else use the temporary target directory
dcb59c
    if [[ -n "$_mnt" ]]; then
Petr Šabata f5bf49
        if ! is_mounted "$_mnt"; then
Petr Šabata f5bf49
            if [[ $_opt  = *",noauto"* ]]; then
f6d6b6
                mount "$_mnt" || mount_failure "$_target" "$_mnt" "$_fstype"
Petr Šabata f5bf49
                _mounted=$_mnt
Petr Šabata f5bf49
            else
Petr Šabata f5bf49
                perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\""
Petr Šabata f5bf49
            fi
Petr Šabata f5bf49
        fi
Petr Šabata f5bf49
    else
Petr Šabata f5bf49
        _mnt=$MKDUMPRD_TMPMNT
bf4667
        mkdir -p "$_mnt"
f6d6b6
        mount "$_target" "$_mnt" -t "$_fstype" -o defaults || mount_failure "$_target" "" "$_fstype"
Petr Šabata f5bf49
        _mounted=$_mnt
Petr Šabata f5bf49
    fi
Petr Šabata f5bf49
Petr Šabata f5bf49
    # For user configured target, use $SAVE_PATH as the dump path within the target
dcb59c
    if [[ ! -d "$_mnt/$SAVE_PATH" ]]; then
20c694
        perror_exit "Dump path \"$_mnt/$SAVE_PATH\" does not exist in dump target \"$_target\""
Petr Šabata f5bf49
    fi
Petr Šabata f5bf49
Petr Šabata f5bf49
    check_size fs "$_target"
Petr Šabata f5bf49
Petr Šabata f5bf49
    # Unmount it early, if function is interrupted and didn't reach here, the shell trap will clear it up anyway
dcb59c
    if [[ -n "$_mounted" ]]; then
bf4667
        umount -f -- "$_mounted"
Petr Šabata f5bf49
    fi
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
# $1: core_collector config value
Petr Šabata f5bf49
verify_core_collector() {
Petr Šabata f5bf49
    local _cmd="${1%% *}"
Petr Šabata f5bf49
    local _params="${1#* }"
Petr Šabata f5bf49
dcb59c
    if [[ "$_cmd" != "makedumpfile" ]]; then
Petr Šabata f5bf49
        if is_raw_dump_target; then
DistroBaker 5cac7c
            dwarn "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
Petr Šabata f5bf49
        fi
Petr Šabata f5bf49
        return
Petr Šabata f5bf49
    fi
Petr Šabata f5bf49
Petr Šabata f5bf49
    if is_ssh_dump_target || is_raw_dump_target; then
Petr Šabata f5bf49
        if ! strstr "$_params" "-F"; then
Petr Šabata f5bf49
            perror_exit "The specified dump target needs makedumpfile \"-F\" option."
Petr Šabata f5bf49
        fi
Petr Šabata f5bf49
        _params="$_params vmcore"
Petr Šabata f5bf49
    else
Petr Šabata f5bf49
        _params="$_params vmcore dumpfile"
Petr Šabata f5bf49
    fi
Petr Šabata f5bf49
bf4667
    # shellcheck disable=SC2086
Petr Šabata f5bf49
    if ! $_cmd --check-params $_params; then
Petr Šabata f5bf49
        perror_exit "makedumpfile parameter check failed."
Petr Šabata f5bf49
    fi
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
add_mount() {
f6d6b6
    local _mnt
Petr Šabata f5bf49
f6d6b6
    _mnt=$(to_mount "$@") || exit 1
Petr Šabata f5bf49
Petr Šabata f5bf49
    add_dracut_mount "$_mnt"
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
#handle the case user does not specify the dump target explicitly
Petr Šabata f5bf49
handle_default_dump_target()
Petr Šabata f5bf49
{
Petr Šabata f5bf49
    local _target
Petr Šabata f5bf49
    local _mntpoint
Petr Šabata f5bf49
Petr Šabata f5bf49
    is_user_configured_dump_target && return
Petr Šabata f5bf49
bf4667
    check_save_path_fs "$SAVE_PATH"
Petr Šabata f5bf49
bf4667
    _save_path=$(get_bind_mount_source "$SAVE_PATH")
bf4667
    _target=$(get_target_from_path "$_save_path")
bf4667
    _mntpoint=$(get_mntpoint_from_target "$_target")
Petr Šabata f5bf49
Petr Šabata f5bf49
    SAVE_PATH=${_save_path##"$_mntpoint"}
Petr Šabata f5bf49
    add_mount "$_target"
bf4667
    check_size fs "$_target"
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
# $1: function name
Petr Šabata f5bf49
for_each_block_target()
Petr Šabata f5bf49
{
Petr Šabata f5bf49
    local dev majmin
Petr Šabata f5bf49
Petr Šabata f5bf49
    for dev in $(get_kdump_targets); do
dcb59c
        [[ -b "$dev" ]] || continue
bf4667
        majmin=$(get_maj_min "$dev")
bf4667
        check_block_and_slaves "$1" "$majmin" && return 1
Petr Šabata f5bf49
    done
Petr Šabata f5bf49
Petr Šabata f5bf49
    return 0
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
#judge if a specific device with $1 is unresettable
Petr Šabata f5bf49
#return false if unresettable.
Petr Šabata f5bf49
is_unresettable()
Petr Šabata f5bf49
{
bf4667
    local path="/sys/$(udevadm info --query=all --path="/sys/dev/block/$1" | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable"
Petr Šabata f5bf49
    local resettable=1
Petr Šabata f5bf49
dcb59c
    if [[ -f "$path" ]]
Petr Šabata f5bf49
    then
e07098
        resettable="$(<"$path")"
dcb59c
        [[ $resettable -eq 0 ]] && [[ "$OVERRIDE_RESETTABLE" -eq 0 ]] && {
bf4667
            local device=$(udevadm info --query=all --path="/sys/dev/block/$1" | awk -F= '/DEVNAME/{print $2}')
DistroBaker 5cac7c
            derror "Error: Can not save vmcore because device $device is unresettable"
Petr Šabata f5bf49
            return 0
Petr Šabata f5bf49
        }
Petr Šabata f5bf49
    fi
Petr Šabata f5bf49
Petr Šabata f5bf49
    return 1
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
#check if machine is resettable.
Petr Šabata f5bf49
#return true if resettable
Petr Šabata f5bf49
check_resettable()
Petr Šabata f5bf49
{
f6d6b6
    local _target _override_resettable
Petr Šabata f5bf49
514b4f
    _override_resettable=$(kdump_get_conf_val override_resettable)
514b4f
    OVERRIDE_RESETTABLE=${_override_resettable:-$OVERRIDE_RESETTABLE}
514b4f
    if [ "$OVERRIDE_RESETTABLE" != "0" ] && [ "$OVERRIDE_RESETTABLE" != "1" ];then
514b4f
        perror_exit "override_resettable value '$OVERRIDE_RESETTABLE' is invalid"
514b4f
    fi
Petr Šabata f5bf49
f6d6b6
    for_each_block_target is_unresettable && return
Petr Šabata f5bf49
Petr Šabata f5bf49
    return 1
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
check_crypt()
Petr Šabata f5bf49
{
Kairui Song de1c56
    local _dev
Petr Šabata f5bf49
Kairui Song de1c56
    for _dev in $(get_kdump_targets); do
Kairui Song de1c56
        if [[ -n $(get_luks_crypt_dev "$(get_maj_min "$_dev")") ]]; then
Kairui Song de1c56
            derror "Device $_dev is encrypted." && return 1
Kairui Song de1c56
        fi
Kairui Song de1c56
    done
Petr Šabata f5bf49
}
Petr Šabata f5bf49
Petr Šabata f5bf49
if ! check_resettable; then
Petr Šabata f5bf49
    exit 1
Petr Šabata f5bf49
fi
Petr Šabata f5bf49
Petr Šabata f5bf49
if ! check_crypt; then
DistroBaker 5cac7c
    dwarn "Warning: Encrypted device is in dump path, which is not recommended, see kexec-kdump-howto.txt for more details."
Petr Šabata f5bf49
fi
Petr Šabata f5bf49
Petr Šabata f5bf49
# firstly get right SSH_KEY_LOCATION
514b4f
keyfile=$(kdump_get_conf_val sshkey)
dcb59c
if [[ -f "$keyfile" ]]; then
Petr Šabata f5bf49
    # canonicalize the path
bf4667
    SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$keyfile")
Petr Šabata f5bf49
fi
Petr Šabata f5bf49
67611b
while read -r config_opt config_val;
Petr Šabata f5bf49
do
Petr Šabata f5bf49
    # remove inline comments after the end of a directive.
Petr Šabata f5bf49
    case "$config_opt" in
Petr Šabata f5bf49
    extra_modules)
Petr Šabata f5bf49
        extra_modules="$extra_modules $config_val"
Petr Šabata f5bf49
        ;;
Petr Šabata f5bf49
    ext[234]|xfs|btrfs|minix|nfs)
Petr Šabata f5bf49
        check_user_configured_target "$config_val" "$config_opt"
Petr Šabata f5bf49
        add_mount "$config_val" "$config_opt"
Petr Šabata f5bf49
        ;;
Petr Šabata f5bf49
    raw)
Petr Šabata f5bf49
        # checking raw disk writable
bf4667
        dd if="$config_val" count=1 of=/dev/null > /dev/null 2>&1 || {
Petr Šabata f5bf49
            perror_exit "Bad raw disk $config_val"
Petr Šabata f5bf49
        }
bf4667
        _praw=$(persistent_policy="by-id" kdump_get_persistent_dev "$config_val")
bf4667
        if [[ -z $_praw ]]; then
Petr Šabata f5bf49
            exit 1
Petr Šabata f5bf49
        fi
Petr Šabata f5bf49
        add_dracut_arg "--device" "$_praw"
bf4667
        check_size raw "$config_val"
Petr Šabata f5bf49
        ;;
Petr Šabata f5bf49
    ssh)
Petr Šabata f5bf49
        if strstr "$config_val" "@";
Petr Šabata f5bf49
        then
bf4667
            mkdir_save_path_ssh "$config_val"
bf4667
            check_size ssh "$config_val"
Petr Šabata f5bf49
            add_dracut_sshkey "$SSH_KEY_LOCATION"
Petr Šabata f5bf49
        else
Petr Šabata f5bf49
            perror_exit "Bad ssh dump target $config_val"
Petr Šabata f5bf49
        fi
Petr Šabata f5bf49
        ;;
Petr Šabata f5bf49
    core_collector)
Petr Šabata f5bf49
        verify_core_collector "$config_val"
Petr Šabata f5bf49
        ;;
Petr Šabata f5bf49
    dracut_args)
dd08f1
        while read -r dracut_arg; do
dd08f1
            add_dracut_arg "$dracut_arg"
dd08f1
        done <<< "$(echo "$config_val" | xargs -n 1 echo)"
Petr Šabata f5bf49
        ;;
Petr Šabata f5bf49
    *)
Petr Šabata f5bf49
        ;;
Petr Šabata f5bf49
    esac
67b8dd
done <<< "$(kdump_read_conf)"
Petr Šabata f5bf49
Petr Šabata f5bf49
handle_default_dump_target
Petr Šabata f5bf49
dcb59c
if [[ -n "$extra_modules" ]]
Petr Šabata f5bf49
then
dd08f1
    add_dracut_arg "--add-drivers" "$extra_modules"
Petr Šabata f5bf49
fi
Petr Šabata f5bf49
Kairui Song 96a3fc
# TODO: The below check is not needed anymore with the introduction of
Kairui Song 96a3fc
#       'zz-fadumpinit' module, that isolates fadump's capture kernel initrd,
Kairui Song 96a3fc
#       but still sysroot.mount unit gets generated based on 'root=' kernel
Kairui Song 96a3fc
#       parameter available in fadump case. So, find a way to fix that first
Kairui Song 96a3fc
#       before removing this check.
Petr Šabata f5bf49
if ! is_fadump_capable; then
Petr Šabata f5bf49
    # The 2nd rootfs mount stays behind the normal dump target mount,
Petr Šabata f5bf49
    # so it doesn't affect the logic of check_dump_fs_modified().
bf4667
    is_dump_to_rootfs && add_mount "$(to_dev_name "$(get_root_fs_device)")"
Petr Šabata f5bf49
Petr Šabata f5bf49
    add_dracut_arg "--no-hostonly-default-device"
Petr Šabata f5bf49
fi
Petr Šabata f5bf49
dd08f1
dracut "${dracut_args[@]}" "$@"
Petr Šabata f5bf49
Petr Šabata f5bf49
_rc=$?
Petr Šabata f5bf49
sync
Petr Šabata f5bf49
exit $_rc