On 01/09/2020 12:53 AM, Kairui Song wrote:
The dracut initqueue may quit immediately and won't trigger any
hook if
there is no "finished" hook still pending (finished hook will be deleted
once it return 0).
This issue start to appear with latest dracut, latest dracut use
network-manager to configure the network,
network-manager module only install "settled" hook, and we didn't
install any other hook. So NFS/SSH dump will fail. iSCSI dump works
because dracut iscsi module will install a "finished" hook to detect if
the iscsi target is up.
So for NFS/SSH we keep initqueue running until the host successfully get
a valid IP address, which means the network is ready.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
dracut-kdump-wait-for-target.sh | 23 ++++++++++++++++
dracut-kdump.sh | 48 ---------------------------------
dracut-module-setup.sh | 2 ++
kdump-lib-initramfs.sh | 48 +++++++++++++++++++++++++++++++++
kexec-tools.spec | 2 ++
5 files changed, 75 insertions(+), 48 deletions(-)
create mode 100755 dracut-kdump-wait-for-target.sh
diff --git a/dracut-kdump-wait-for-target.sh b/dracut-kdump-wait-for-target.sh
new file mode 100755
index 0000000..ce984d0
--- /dev/null
+++ b/dracut-kdump-wait-for-target.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# only wait if it's kdump kernel
+if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump
]; then
+ exit 0
+fi
+
+. /lib/dracut-lib.sh
+. /lib/kdump-lib-initramfs.sh
+
+# For SSH/NFS target, need to wait for the network to setup
+if is_nfs_dump_target; then
+ get_host_ip
+ exit $?
+fi
+
+if is_ssh_dump_target; then
+ get_host_ip
+ exit $?
+fi
+
+# No need to wait for dump target
+exit 0
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 2ae1c7c..8add48d 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -114,54 +114,6 @@ save_vmcore_dmesg_ssh() {
fi
}
-get_host_ip()
-{
- local _host
- if is_nfs_dump_target || is_ssh_dump_target
- then
- kdumpnic=$(getarg kdumpnic=)
- [ -z "$kdumpnic" ] && echo "kdump: failed to get
kdumpnic!" && return 1
- _host=`ip addr show dev $kdumpnic|grep '[ ]*inet'`
- [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic"
&& return 1
- _host=`echo $_host | head -n 1 | cut -d' ' -f2`
- _host="${_host%%/*}"
- [ -z "$_host" ] && echo "kdump: wrong kdumpnic:
$kdumpnic" && return 1
- HOST_IP=$_host
- fi
- return 0
-}
-
-read_kdump_conf()
-{
- if [ ! -f "$KDUMP_CONF" ]; then
- echo "kdump: $KDUMP_CONF not found"
- return
- fi
-
- get_kdump_confs
-
- # rescan for add code for dump target
- while read config_opt config_val;
- do
- # remove inline comments after the end of a directive.
- case "$config_opt" in
- dracut_args)
- config_val=$(get_dracut_args_target "$config_val")
- [ -n "$config_val" ] && add_dump_code "dump_fs
$config_val"
- ;;
- ext[234]|xfs|btrfs|minix|nfs)
- add_dump_code "dump_fs $config_val"
- ;;
- raw)
- add_dump_code "dump_raw $config_val"
- ;;
- ssh)
- add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val"
- ;;
- esac
- done <<< "$(read_strip_comments $KDUMP_CONF)"
-}
-
fence_kdump_notify()
{
if [ -n "$FENCE_KDUMP_NODES" ]; then
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 3558a0f..570bd62 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -842,7 +842,9 @@ install() {
kdump_check_iscsi_targets
# nfs/ssh dump will need to get host ip in second kernel and need to call
'ip' tool, see get_host_ip for more detail
+ # also need to let initqueue wait for target to become ready
if is_nfs_dump_target || is_ssh_dump_target; then
+ inst_hook initqueue/finished 01 $moddir/kdump-wait-for-target.sh
inst "ip"
fi
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 8530556..d5d2ee2 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -201,3 +201,51 @@ do_final_action()
{
eval $FINAL_ACTION
}
+
+get_host_ip()
+{
+ local _host
+ if is_nfs_dump_target || is_ssh_dump_target
+ then
+ kdumpnic=$(getarg kdumpnic=)
+ [ -z "$kdumpnic" ] && echo "kdump: failed to get
kdumpnic!" && return 1
+ _host=`ip addr show dev $kdumpnic|grep '[ ]*inet'`
+ [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic"
&& return 1
+ _host=`echo $_host | head -n 1 | cut -d' ' -f2`
+ _host="${_host%%/*}"
+ [ -z "$_host" ] && echo "kdump: wrong kdumpnic:
$kdumpnic" && return 1
+ HOST_IP=$_host
+ fi
+ return 0
+}
+
+read_kdump_conf()
+{
+ if [ ! -f "$KDUMP_CONF" ]; then
+ echo "kdump: $KDUMP_CONF not found"
+ return
+ fi
+
+ get_kdump_confs
+
+ # rescan for add code for dump target
+ while read config_opt config_val;
+ do
+ # remove inline comments after the end of a directive.
+ case "$config_opt" in
+ dracut_args)
+ config_val=$(get_dracut_args_target "$config_val")
+ [ -n "$config_val" ] && add_dump_code "dump_fs
$config_val"
+ ;;
+ ext[234]|xfs|btrfs|minix|nfs)
+ add_dump_code "dump_fs $config_val"
+ ;;
+ raw)
+ add_dump_code "dump_raw $config_val"
+ ;;
+ ssh)
+ add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val"
+ ;;
+ esac
+ done <<< "$(read_strip_comments $KDUMP_CONF)"
+}
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 06b8aae..91eae0c 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -50,6 +50,7 @@ Source106: dracut-kdump-capture.service
Source107: dracut-kdump-emergency.target
Source108: dracut-early-kdump.sh
Source109: dracut-early-kdump-module-setup.sh
+Source110: dracut-kdump-wait-for-target.sh
Requires(post): systemd-units
Requires(preun): systemd-units
@@ -222,6 +223,7 @@ cp %{SOURCE104}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpb
cp %{SOURCE105}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE105}}
cp %{SOURCE106}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE106}}
cp %{SOURCE107}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE107}}
+cp %{SOURCE110}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE110}}
chmod 755
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE100}}
chmod 755
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE101}}
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump
LGTM,
Acked-by: Pingfan Liu <piliu(a)redhat.com>