From 3ee00cd384e03dc37267096dd0d452fb51b09479 Mon Sep 17 00:00:00 2001 From: Xunlei Pang Date: Fri, 7 Jul 2017 15:48:53 +0800 Subject: [PATCH] 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 Acked-by: Dave Young --- kdump-lib.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ kdumpctl | 5 ----- mkdumprd | 12 ------------ 3 files changed, 51 insertions(+), 17 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 3cf7af5..a33f172 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -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. diff --git a/kdumpctl b/kdumpctl index bc57948..1b8f4bd 100755 --- a/kdumpctl +++ b/kdumpctl @@ -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() diff --git a/mkdumprd b/mkdumprd index 45b185a..337ae87 100644 --- a/mkdumprd +++ b/mkdumprd @@ -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