[PATCH] Hardware iSCSI support
by WANG Chao
Currently we retrieve all the necessary information of an iSCSI session
and pass them to 2nd kernel. This is wrong way to go for hardware iscsi,
because dracut has already had its own infrastructure to do bring up any
iscsi device configured in firmware of an HBA (Host Bus Bridge).
This patch will determine if an iscsi session is established by firmware
configured iscsi. If it does, then we don't pass anything down to 2nd
kernel. dracut will handle it.
I read some iscsi code and I also talked with storage QE. It's confirmed
that software iscsi will use "tcp" transport class while hardware iscsi
will use like "be2iscsi" "bnx2i" transport class. It's ok to use
the transport name of an iface of a scsi session to determine hardware
iscsi or not. Additionally using "iscsi_firmware" "rd.iscsi.firmware" to
determine if the system is iscsi boot, because dracut can only handle
this case.
Along this patch, I add the infrastructure of determine iBFT, but it's
not complete yet. Mark the part as "FIXME". Once customer is asking or
maybe I get hold of iBFT box, I can start working on it.
Signed-off-by: WANG Chao <chaowang(a)redhat.com>
---
dracut-module-setup.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 76 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index dcebc47..9616866 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -411,7 +411,78 @@ kdump_get_iscsi_initiator() {
return 1
}
-# No ibft handling yet.
+# Determine hardware iscsi by an iface's transport class.
+# If transport class is tcp, it's software iscsi.
+# If it's be2iscsi, bnx2i, cxgb3i, cxgb4i, it's hardware iscsi.
+kdump_is_iscsi_hw_session() {
+ if [ "$(kdump_iscsi_get_rec_val $1 "iface.transport_name")" = tcp ]; then
+ return 1
+ fi
+
+ return 0
+}
+
+# FIXME: determine iBFT
+kdump_is_iscsi_ibft_session() {
+ return 1
+}
+
+# kernel cmdline must contain these either of the following arguments
+# for booting off hardware iSCSI:
+# rd.iscsi.firmware[=1], iscsi_firmware
+kdump_is_iscsi_hw_cmdline() {
+ local cmdline
+
+ cmdline="$(cat /proc/cmdline)"
+
+ for arg in $cmdline; do
+ case "$arg" in
+ "rd.iscsi.firmware" |\
+ "rd.iscsi.firmware=1" |\
+ "iscsi_firmware")
+ return 0
+ ;;
+ esac
+ done
+
+ return 1
+}
+
+# kernel cmdline must contain these either of the following arguments
+# for booting off iBFT:
+# rd.iscsi.ibft[=1], ip=ibft
+kdump_is_iscsi_ibft_cmdline() {
+ local cmdline
+
+ cmdline="$(cat /proc/cmdline)"
+
+ for arg in $cmdline; do
+ case "$arg" in
+ "rd.iscsi.ibft" |\
+ "rd.iscsi.ibft=1" |\
+ "ip=ibft")
+ return 0
+ ;;
+ esac
+ done
+
+ return 1
+}
+
+# Sanity check if an iscsi session is established by iBFT or firmware
+kdump_is_iscsi_fw() {
+
+ if kdump_is_iscsi_hw_cmdline && kdump_is_iscsi_hw_session $1; then
+ return 0
+ fi
+
+ if kdump_is_iscsi_ibft_cmdline && kdump_is_iscsi_ibft_session $1; then
+ return 0
+ fi
+
+ return 1
+}
+
kdump_setup_iscsi_device() {
local path=$1
local tgt_name; local tgt_ipaddr;
@@ -434,6 +505,10 @@ kdump_setup_iscsi_device() {
return 1
fi
+ if kdump_is_iscsi_fw ${path}; then
+ return 0;
+ fi
+
tgt_name=$(kdump_iscsi_get_rec_val ${path} "node.name")
tgt_ipaddr=$(kdump_iscsi_get_rec_val ${path} "node.conn\[0\].address")
--
1.9.3
9 years, 5 months
[PATCH] kdump, add latest soft link for local dumps
by Prarit Bhargava
Add a latest soft link for local dumps, and a user configurable option
for other cases. This makes things easier when going through $path to
find the latest kdump.
Signed-off-by: Prarit Bhargava <prarit(a)redhat.com>
---
kdump-lib-initramfs.sh | 10 ++++++++++
kdump.conf | 3 +++
kdump.conf.5 | 9 +++++++++
kdumpctl | 2 +-
kexec-kdump-howto.txt | 5 +++++
5 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index f882b09..925eda6 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -18,6 +18,7 @@ KDUMP_CONF="/etc/kdump.conf"
KDUMP_PRE=""
KDUMP_POST=""
NEWROOT="/sysroot"
+LATEST_LINK=0
get_kdump_confs()
{
@@ -53,6 +54,9 @@ get_kdump_confs()
fence_kdump_nodes)
FENCE_KDUMP_NODES="$config_val"
;;
+ latest_link)
+ LATEST_LINK="$config_val"
+ ;;
default)
case $config_val in
shell)
@@ -112,6 +116,12 @@ dump_fs()
mv $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore
sync
+ if [ "$HOST_IP" == "127.0.0.1" ] || [ $LATEST_LINK -eq 1 ]; then
+ echo "kdump: creating link to latest"
+ rm -f $_mp/$KDUMP_PATH/latest
+ ln -sf $KDUMP_PATH/$HOST_IP-$DATEDIR $_mp/$KDUMP_PATH/latest
+ fi
+
echo "kdump: saving vmcore complete"
}
diff --git a/kdump.conf b/kdump.conf
index 54b581d..a70adde 100644
--- a/kdump.conf
+++ b/kdump.conf
@@ -141,6 +141,9 @@
# - List of cluster node(s) separated by space to send fence_kdump
# notification to (this option is mandatory to enable fence_kdump).
#
+# latest_link <0 | 1 >
+# - Adds a /$path/latest soft link to the latest crashdump
+#
#raw /dev/vg/lv_kdump
#ext4 /dev/vg/lv_kdump
diff --git a/kdump.conf.5 b/kdump.conf.5
index f1c2a2c..c1760ea 100644
--- a/kdump.conf.5
+++ b/kdump.conf.5
@@ -259,6 +259,15 @@ KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer
to dracut.cmdline man page for more details on module blacklist option.
.RE
+.B latest_link <0 | 1>
+.RS
+Adds a /$path/latest soft link to the latest crashdump
+.PP
+0 - disabled
+.PP
+1 - enabled
+.RE
+
.RE
.SH EXAMPLES
diff --git a/kdumpctl b/kdumpctl
index ee3214a..4ccc0b8 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -242,7 +242,7 @@ check_config()
case "$config_opt" in
\#* | "")
;;
- raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes)
+ raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes|latest_link)
[ -z "$config_val" ] && {
echo "Invalid kdump config value for option $config_opt."
return 1;
diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt
index 5582e40..9866fc7 100644
--- a/kexec-kdump-howto.txt
+++ b/kexec-kdump-howto.txt
@@ -476,6 +476,11 @@ Core collector command format depends on dump target type. Typically for
filesystem (local/remote), core_collector should accept two arguments.
First one is source file and second one is target file. For ex.
+Latest Link
+
+The 'latest_link' parameter can be set to one to create a 'latest' soft link
+in the specifie dump path directory.
+
ex1.
---
core_collector "cp --sparse=always"
--
1.7.9.3
9 years, 5 months
[PATCH v2] Enhance kdump to support ipv6
by Minfei Huang
From: Arthur Zou <zzou(a)redhat.com>
Description:
Currently kdump doesn't support ipv6 nfs/ssh dump. Ipv6 is the latest version
of the Internet Protocal. so it is a significant feture for kdump to enhance
to support ipv6.
Solutions:
Since dracut has supported ipv6 now, it is easy to change the kdump code to
support ipv6. Just need pass the right _ip_opts to the second kernle. What is
the main difference in userspace bettwen ipv4 and ipv6 is the ip address format.
For ipv6 nfs dump:
if ipv6 address type is link scope, /etc/kdump.conf should be edited like
"nfs [fe80::5054:ff:fe48:ca80%eth0]:/mnt"
else /etc/kdump.conf should be edited like "nfs [2001:db8:0:f101::2]:/mnt"
For ipv6 ssh dump
if ipv6 address type is link scope, /etc/kdump.conf should be edited like
"ssh root at fe80::5054:ff:fe48:ca80%eth0"
else /etc/kdump.conf should be edited like "ssh root at 2001:db8:0:f101::2"
What this patch do is:
a): Add a function is_ipv6_target to tell what version of Internet Protocal
(ipv4/ipv6) kdump will use to dump to remote target.
b): Modify kdump_install_net to handle ipv6 configuration in /etc/kdump.conf
correctly. Get the ipv6 address from /etc/kdump.conf is more complicated
than ipv4 because the difference configuration format mentioned above.
c): Based on the ip address type, using corresponding ip address as HOST_IP
in second kernel.
It was tested for IPV6 and IPV4 address in beaker machine and passed.
Note:
1): Currntly only f19 support remount a nfs target in ipv6. detail in https:
//bugzilla.redhat.com/show_bug.cgi?id=1099761. If using in f20, you can
comment out "mount -o remount,rw $_mp || return 1" in kdump.sh line 105.
2): If Using static ipv6 address and configuring nfs/ssh with hostname of
remote target, MUST add a ipv6 DNS in ifcfg-devname.
How to create a ipv6 enviromnet.
1): Reserving two beaker machine with family fedora19.
2): Choosing a beaker machine as a nfs/ssh server and delete it's ipv4 address
by "ip address del ipv4-address dev nicname"
3): Configuring the /etc/kdump.conf like mentioned above.
Signed-off-by: Arthur Zou <zzou(a)redhat.com>
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
---
dracut-kdump.sh | 8 ++++--
dracut-module-setup.sh | 67 ++++++++++++++++++++++++++++++++++++--------------
kdump-lib.sh | 33 +++++++++++++++++++++++++
3 files changed, 88 insertions(+), 20 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 600e84e..9f12084 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -121,9 +121,13 @@ get_host_ip()
then
kdumpnic=$(getarg kdumpnic=)
[ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1
- _host=`ip addr show dev $kdumpnic|grep 'inet '`
+ if is_ipv6_target; then
+ _host=`ip addr show dev $kdumpnic|grep 'inet6'`
+ else
+ _host=`ip addr show dev $kdumpnic|grep 'inet '`
+ fi
[ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1
- _host="${_host##*inet }"
+ _host=`echo $_host | cut -d' ' -f2`
_host="${_host%%/*}"
[ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1
HOST_IP=$_host
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 38801de..d39b127 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -70,14 +70,24 @@ kdump_setup_dns() {
#$2: srcaddr
#if it use static ip echo it, or echo null
kdump_static_ip() {
- local _netmask _gateway
+ local _netmask _gateway _ipaddr
local _netdev="$1" _srcaddr="$2"
- local _ipaddr=$(ip addr show dev $_netdev permanent | \
+
+ if is_ipv6_target; then
+ _ipaddr=$(ip addr show dev $_netdev permanent | \
+ awk "/ $_srcaddr\/.* /{print \$2}")
+ if [ -n "$_ipaddr" ]; then
+ _gateway=$(ip -6 route list dev $_netdev | awk '/^default /{print $3}')
+ echo -n "[${_srcaddr}]::[${_gateway}]:64::"
+ fi
+ else
+ _ipaddr=$(ip addr show dev $_netdev permanent | \
awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
- if [ -n "$_ipaddr" ]; then
- _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
- _gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
- echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
+ if [ -n "$_ipaddr" ]; then
+ _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
+ _gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
+ echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
+ fi
fi
/sbin/ip route show | grep -v default | grep "^[[:digit:]].*via.* $_netdev " |\
@@ -264,24 +274,43 @@ kdump_install_net() {
local _server _netdev _srcaddr
local config_val="$1"
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
+ _server=`get_remote_host $config_val`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
+ if is_ipv6_target; then
+ _need_dns=`echo $_server|grep "[:]"`
+ [ -z "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
+ else
+ _need_dns=`echo $_server|grep "[a-zA-Z]"`
+ [ -n "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
+ 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
- _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
- _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
+ if is_ipv6_target; then
+ #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
+ _srcaddr=`echo $_netdev|awk '{print $9}'|head -n 1`
+ _netdev=`echo $_netdev|awk '{print $7;}'|head -n 1`
+ else
+ # we are on the same subnet
+ _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
+ _netdev=`echo $_netdev|awk '{print $5}'|head -n 1`
+ fi
else
- # we are on the same subnet
- _srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
- _netdev=`echo $_netdev|awk '{print $3}'|head -n 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
+ _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
+ _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
+ else
+ # we are on the same subnet
+ _srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
+ _netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
+ fi
fi
kdump_setup_netdev "${_netdev}" "${_srcaddr}"
@@ -583,6 +612,8 @@ install() {
inst "/bin/date" "/bin/date"
inst "/bin/sync" "/bin/sync"
inst "/bin/cut" "/bin/cut"
+ inst "/bin/getent" "/bin/getent"
+ inst "/bin/head" "/bin/head"
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
diff --git a/kdump-lib.sh b/kdump-lib.sh
index a20c6e8..5053fdd 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -138,3 +138,36 @@ check_save_path_fs()
fi
}
+# get ip address or hostname from nfs/ssh config value
+get_remote_host()
+{
+ local _config_val=$1
+
+ # in ipv6, the _config_val format is [xxxx:xxxx::xxxx%eth0]:/mnt/nfs or
+ # username at xxxx:xxxx::xxxx%eth0. what we need is just xxxx:xxxx::xxxx
+ _config_val=${_config_val#*@}
+ _config_val=${_config_val%:/*}
+ _config_val=${_config_val#[}
+ _config_val=${_config_val%]}
+ _config_val=${_config_val%\%*}
+ echo $_config_val
+}
+
+# check the remote server ip address tpye
+is_ipv6_target()
+{
+ local _server _server_tmp
+
+ if is_ssh_dump_target; then
+ _server=`get_option_value ssh`
+ elif is_nfs_dump_target; then
+ _server=`get_option_value nfs`
+ fi
+
+ [ -z "$_server" ] && return 1
+ _server=`get_remote_host $_server`
+ _server_tmp=$_server
+ _server=`getent hosts $_server | head -n 1 | cut -d' ' -f1`
+ _server=${_server:-$_server_tmp}
+ echo $_server | grep -q ":"
+}
--
1.8.3.1
9 years, 5 months