On Fri, Apr 16, 2021 at 07:24:38PM +0800, Kairui Song wrote:
On Thu, Apr 1, 2021 at 3:38 PM Coiby Xu <coxu(a)redhat.com>
wrote:
>
> Now kdumpctl will abort when failing to set up znet.
>
> Signed-off-by: Coiby Xu <coxu(a)redhat.com>
> ---
> dracut-module-setup.sh | 39 ++++++++++++++++++++++++++++++---------
> 1 file changed, 30 insertions(+), 9 deletions(-)
>
> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> index 21143b4..0ea343a 100755
> --- a/dracut-module-setup.sh
> +++ b/dracut-module-setup.sh
> @@ -318,17 +318,33 @@ kdump_setup_vlan() {
> }
>
> # setup s390 znet cmdline
> -# $1: netdev name
> +# $1: netdev (ifname)
> +# $2: nmcli connection show output
> kdump_setup_znet() {
> + local _netdev="$1"
> + local _nmcli_cmd="$2"
> + local s390_prefix="802-3-ethernet.s390-"
> local _options=""
> - local _netdev=$1
> + local NETTYPE
> + local SUBCHANNELS
> +
> + NETTYPE=$(get_nmcli_value_by_field "$_nmcli_cmd"
"${s390_prefix}nettype")
> + SUBCHANNELS=$(get_nmcli_value_by_field "$_nmcli_cmd"
"${s390_prefix}subchannels")
> + _options=$(get_nmcli_value_by_field "$_nmcli_cmd"
"${s390_prefix}options")
> +
> + if [[ -z "$NETTYPE" || -z "$SUBCHANNELS" || -z
"$_options" ]]; then
> + dwarning "Failed to get znet configuration via nmlci output. Now try
sourcing ifcfg script."
> + source_ifcfg_file $_netdev
> + for i in $OPTIONS; do
> + _options=${_options},$i
> + done
> + fi
>
> - source_ifcfg_file $_netdev
> + if [[ -z "$NETTYPE" || -z "$SUBCHANNELS" || -z
"$_options" ]]; then
> + exit 1
> + fi
>
> - for i in $OPTIONS; do
> - _options=${_options},$i
> - done
> - echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options}
rd.znet_ifname=$_netdev:${SUBCHANNELS} > ${initdir}/etc/cmdline.d/30znet.conf
> + echo rd.znet=${NETTYPE},${SUBCHANNELS},${_options}
rd.znet_ifname=$_netdev:${SUBCHANNELS} > ${initdir}/etc/cmdline.d/30znet.conf
> }
>
> kdump_get_ip_route()
> @@ -362,17 +378,22 @@ kdump_get_remote_ip()
> # initramfs accessing giving destination
> # $1: destination host
> kdump_install_net() {
> - local _destaddr _srcaddr _route _netdev
> + local _destaddr _srcaddr _route _netdev _nm_show_cmd
> local _static _proto _ip_conf _ip_opts _ifname_opts
>
> _destaddr=$(kdump_get_remote_ip $1)
> _route=$(kdump_get_ip_route $_destaddr)
> _srcaddr=$(kdump_get_ip_route_field "$_route" "src")
> _netdev=$(kdump_get_ip_route_field "$_route" "dev")
> + _nm_show_cmd=$(get_nmcli_connection_show_cmd_by_ifname "$_netdev")
> _netmac=$(kdump_get_mac_addr $_netdev)
>
> if [ "$(uname -m)" = "s390x" ]; then
> - kdump_setup_znet $_netdev
> + $(kdump_setup_znet "$_netdev" "$_nm_show_cmd")
Any reason why we invoke the function via a subshell here?
Calling the function via a subshell makes the function more like a pure
function thus no unexpected side effect. So I think it's better.
> + if [[ $? != 0 ]]; then
> + derror "Failed to set up znet"
> + exit 1
> + fi
> fi
>
> _static=$(kdump_static_ip $_netdev $_srcaddr)
> --
> 2.31.0
> _______________________________________________
> kexec mailing list -- kexec(a)lists.fedoraproject.org
> To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
> Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
> List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives:
https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
> Do not reply to spam on the list, report it:
https://pagure.io/fedora-infrastructure
--
Best Regards,
Kairui Song
--
Best regards,
Coiby