This patch is used to setup fence kdump environment when building kdump initrd: 1. Check if it's cluster and fence_kdump is configured. 2. Get all the nodes in the cluster and pass them to 2nd kernel via /etc/fence_kdump_nodes 3. Setup network interface which will be used by fence kdump notifier in 2nd kernel. 4. Install fence kdump notifier (/usr/libexec/fence_kdump_send) to initrd.
Signed-off-by: WANG Chao chaowang@redhat.com --- dracut-module-setup.sh | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c013430..e889aa1 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -20,6 +20,10 @@ depends() { _dep="$_dep drm" fi
+ if is_fence_kdump; then + _dep="$_dep network" + fi + echo $_dep return 0 } @@ -234,9 +238,14 @@ kdump_install_net() { fi
kdump_setup_netdev "${_netdev}" + #save netdev used for kdump as cmdline - echo "kdumpnic=${_netdev}" > ${initdir}/etc/cmdline.d/60kdumpnic.conf - echo "bootdev=${_netdev}" > ${initdir}/etc/cmdline.d/70bootdev.conf + #fence kdump would override bootdev and kdumpnic, we should avoid that. + if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] && + [ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then + echo "kdumpnic=${_netdev}" > ${initdir}/etc/cmdline.d/60kdumpnic.conf + echo "bootdev=${_netdev}" > ${initdir}/etc/cmdline.d/70bootdev.conf + fi }
#install kdump.conf and what user specifies in kdump.conf @@ -263,6 +272,7 @@ kdump_install_conf() { esac done < /etc/kdump.conf
+ kdump_check_fence_kdump > ${initdir}/$FENCE_KDUMP_NODES inst "/tmp/$$-kdump.conf" "/etc/kdump.conf" rm -f /tmp/$$-kdump.conf } @@ -393,6 +403,35 @@ kdump_check_iscsi_targets () { }
+# setup fence_kdump in cluster +# setup proper network and install needed files +# also output '[node list]' for 2nd kernel /etc/fence_kdump_nodes +kdump_check_fence_kdump () { + is_fence_kdump || return 1 + + # get cluster nodes from cluster cib, get interface and ip address + nodelist=`pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -` + + # nodelist is formed as 'uname="node1" uname="node2" ... uname="nodeX"' + # we need to convert each to node1, node2 ... nodeX in each iteration + for node in ${nodelist}; do + # convert $node from 'uname="nodeX"' to 'nodeX' + eval $node + nodename=$uname + # Skip its own node name + if [ "$nodename" = `hostname` ]; then + continue + fi + echo -n "$nodename " + + kdump_install_net $nodename + done + echo + + dracut_install $FENCE_KDUMP_SEND + dracut_install -o $FENCE_KDUMP_CONFIG +} + install() { kdump_install_conf >"$initdir/lib/dracut/no-emergency-shell"