diff --git a/kdump_dracut_modules/99kdumpbase/kdump.sh b/kdump_dracut_modules/99kdumpbase/kdump.sh index 366b303..78127ed 100755 --- a/kdump_dracut_modules/99kdumpbase/kdump.sh +++ b/kdump_dracut_modules/99kdumpbase/kdump.sh @@ -121,8 +121,7 @@ read_kdump_conf() CORE_COLLECTOR="$config_val" ;; net) - if [ -n "$(echo $config_val | grep @)" ] - then + if [[ "$config_val" =~ "@" ]]; then add_dump_code "dump_ssh $config_val || do_default_action" else add_dump_code "dump_nfs $config_val || do_default_action" diff --git a/kdump_dracut_modules/99kdumpbase/module-setup.sh b/kdump_dracut_modules/99kdumpbase/module-setup.sh index e4efc90..713f968 100755 --- a/kdump_dracut_modules/99kdumpbase/module-setup.sh +++ b/kdump_dracut_modules/99kdumpbase/module-setup.sh @@ -1,5 +1,7 @@ #!/bin/bash +. $dracutfunctions + check() { [[ $debug ]] && set -x #kdumpctl sets this explicitly @@ -10,6 +12,11 @@ check() { return 0 } +depends() { + echo "base shutdown" + return 0 +} + to_udev_name() { local dev="$1" @@ -24,18 +31,53 @@ to_udev_name() { echo ${dev#/dev/} } -depends() { - echo "base shutdown" - return 0 +is_bridge() { + [ -d /sys/class/net/"$1"/bridge ] +} + +is_bond() { + [ -d /sys/class/net/"$1"/bonding ] } install() { + local _server + local _netdev + sed -ne '/^#/!p' /etc/kdump.conf > /tmp/$$-kdump.conf while read config_opt config_val; do case "$config_opt" in ext[234]|xfs|btrfs|minix|raw) - sed -i -e "s#$1#/dev/$(to_udev_name $1)#" /tmp/$$-kdump.conf + sed -i -e "s#$config_val#/dev/$(to_udev_name $config_val)#" /tmp/$$-kdump.conf + ;; + net) + if strstr "$config_val" "@"; then + _server=$(echo $config_val | sed -e 's#.*@\(.*\):.*#\1#') + else + _server=$(echo $config_val | sed -e 's#\(.*\):.*#\1#') + fi + + _netdev=`/sbin/ip route get to $_server 2>&1` + [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1 + #the field in the ip output changes if we go to another subnet + if [ -n "`echo $_netdev | grep via`" ] + then + # we are going to a different subnet + _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1` + else + # we are on the same subnet + _netdev=`echo $_netdev|awk '{print $3}'|head -n 1` + fi + echo " ip=$_netdev:dhcp" > ${initdir}/etc/cmdline.d/40ip.conf + if is_bridge "$_netdev"; then + echo " bridge=$_netdev:$(cd /sys/class/net/$_netdev/brif/; echo *)" > ${initdir}/etc/cmdline.d/41bridge.conf + elif is_bond "$_netdev"; then + echo " bond=$_netdev:\"$(cat /sys/class/net/$_netdev/bonding/slaves)\"" > ${initdir}/etc/cmdline.d/42bond.conf + #TODO + #echo "bondoptions=\"$bondoptions\"" >> /tmp/$$-bond + else + : + fi ;; esac done < /etc/kdump.conf @@ -44,6 +86,6 @@ install() { inst "/bin/sync" "/bin/sync" inst "/sbin/makedumpfile" "/sbin/makedumpfile" inst "/tmp/$$-kdump.conf" "/etc/kdump.conf" - inst_hook pre-pivot 01 "$moddir/kdump.sh" + inst_hook pre-pivot 93 "$moddir/kdump.sh" } diff --git a/kexec-tools.spec b/kexec-tools.spec index 0b0c4df..a0b50fb 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.3 -Release: 36%{?dist} +Release: 37%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component. @@ -289,6 +289,9 @@ done %changelog +* Fri Jan 27 2012 Cong Wang - 2.0.2-37 +- Add initial NFS dump support, experimental. + * Wed Jan 25 2012 Cong Wang - 2.0.2-36 - Really upload the dracut module. diff --git a/sources b/sources index 4934f96..85cddf6 100644 --- a/sources +++ b/sources @@ -4,4 +4,4 @@ e3a813bd6d7dace903a05c1296e20d57 makedumpfile-1.3.5.tar.gz 8e359dd03731b93a2082bd37cc2a4a4c kexec-tools-2.0.2.tar.bz2 b3ced2097ce3981abba38ceedc84f939 kexec-tools-2.0.3.tar.bz2 967f89bb947ca4db78f51beeaaee0bd8 makedumpfile-1.4.1.tar.gz -cca779064913dc899ce027872d0ba498 dracut-files.tbz2 +2132832b58a209c05192d5783031c79d dracut-files.tbz2