kdump-lib.sh: introduce get_kdump_targets()

Resolves: bz1451717
https://bugzilla.redhat.com/1451717

We need to know all the kdump targets including the dump
target and root in case of "dump_to_rootfs".

This is useful for us to do some extra work related to the
type of different targets.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
Xunlei Pang 2017-07-07 15:48:53 +08:00 committed by Dave Young
parent 1bc78e025f
commit 3ee00cd384
3 changed files with 51 additions and 17 deletions

View File

@ -135,6 +135,57 @@ get_block_dump_target()
[ -b "$_target" ] && echo $(to_dev_name $_target)
}
is_dump_to_rootfs()
{
grep "^default[[:space:]]dump_to_rootfs" /etc/kdump.conf >/dev/null
}
get_default_action_target()
{
local _target
if is_dump_to_rootfs; then
# Get rootfs device name
_target=$(get_root_fs_device)
[ -b "$_target" ] && echo $(to_dev_name $_target) && return
# Then, must be nfs root
echo "nfs"
fi
}
# Get kdump targets(including root in case of dump_to_rootfs).
get_kdump_targets()
{
local _target _root
local kdump_targets
_target=$(get_block_dump_target)
if [ -n "$_target" ]; then
kdump_targets=$_target
elif is_ssh_dump_target; then
kdump_targets="ssh"
else
kdump_targets="nfs"
fi
# Add the root device if dump_to_rootfs is specified.
_root=$(get_default_action_target)
if [ -n "$_root" -a "$kdump_targets" != "$_root" ]; then
kdump_targets="$kdump_targets $_root"
fi
# NOTE:
# dracut parses devices from "/etc/fstab" with the "x-initrd.mount" option,
# which will be added as host_devs, it also includes usually simple devices
# (say mounted to /boot, /boot/efi/, etc) plus the root device. Then kdump
# must wait for these devices if initramfs is built with "--hostonly-cmdline".
#
# We don't pass "--hostonly-cmdline" to dracut, so there's no problem.
echo "$kdump_targets"
}
# findmnt uses the option "-v, --nofsroot" to exclusive the [/dir]
# in the SOURCE column for bind-mounts, then if $_mntpoint equals to
# $_mntpoint_nofsroot, the mountpoint is not bind mounted directory.

View File

@ -175,11 +175,6 @@ check_kdump_cpus()
echo " try nr_cpus=$nr_min or larger instead"
}
is_dump_to_rootfs()
{
grep "^default[[:space:]]dump_to_rootfs" /etc/kdump.conf >/dev/null
}
# This function performs a series of edits on the command line.
# Store the final result in global $KDUMP_COMMANDLINE.
prepare_cmdline()

View File

@ -278,18 +278,6 @@ handle_default_dump_target()
check_size fs $_target
}
get_default_action_target()
{
local _target
local _action=$(grep "^default" /etc/kdump.conf 2>/dev/null | awk '{print $2}')
if [ -n "$_action" ] && [ "$_action" = "dump_to_rootfs" ]; then
#get rootfs device name
_target=$(findmnt -k -f -n -o SOURCE /)
[ -b "$_target" ] && echo $(to_dev_name $_target)
fi
return
}
get_override_resettable()
{
local override_resettable