On Mon, Feb 22, 2021 at 2:42 PM Coiby Xu <coxu(a)redhat.com> wrote:
From: Coiby Xu <coiby.xu(a)gmail.com>
Since Fedora 34, ifcfg has been deprecated. Read znet config from nmcli
directly,
$ nmcli c show enc8000
connection.id: enc8000
connection.uuid: 02fbf6c2-b5bf-4ced-8a41-99a46ade828c
connection.stable-id: --
connection.type: 802-3-ethernet
connection.interface-name: enc8000
...
802-3-ethernet.s390-subchannels: 0.0.8000,0.0.8001,0.0.8002
802-3-ethernet.s390-nettype: qeth
802-3-ethernet.s390-options: layer2=1,portname=z-104,portno=0
Reported-by: Jie Li <jieli(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
dracut-module-setup.sh | 41 +++++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 21143b4..390cb6d 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -317,17 +317,50 @@ kdump_setup_vlan() {
fi
}
+# parse s390 znet config from nmcli output
+# $1: netdev name
+# $2: option name
+parse_znet_from_nmcli() {
+ # nmlci connection show $netdev has the following output if
+ # 1. there is active znet netdev
+ # 802-3-ethernet.s390-subchannels: 0.0.8000,0.0.8001,0.0.8002
+ # 802-3-ethernet.s390-nettype: qeth
+ # 802-3-ethernet.s390-options: layer2=1,portname=z-104,portno=0
+ # 2. or "--" to indicate no related znet options on Fedora or RHEL
+ # 802-3-ethernet.s390-subchannels: --
+ # 802-3-ethernet.s390-nettype: --
+ # 802-3-ethernet.s390-options: --
+ # 3. no "s390-*" related lines
+ local _netdev=$1
+ local _field=$2
+ local val=$(nmcli conn show $_netdev | grep s390-$_field | sed
"s/.*:\s*//g")
+
+ if [ "$val" = "--" ]; then
+ val=""
+ fi
+ echo $val
+}
+
# setup s390 znet cmdline
# $1: netdev name
kdump_setup_znet() {
local _options=""
local _netdev=$1
- source_ifcfg_file $_netdev
+ # 1. first read from nmcli output directly
+ NETTYPE=$(parse_znet_from_nmcli $_netdev nettype)
+ SUBCHANNELS=$(parse_znet_from_nmcli $_netdev subchannels )
+ options=$(parse_znet_from_nmcli $_netdev options)
+
+ # 2. if failed to get SUBCHANNELS, read from ifcfg_file
+ if [[ -z "$SUBCHANNELS" ]]; then
+ source_ifcfg_file $_netdev
+
+ for i in $OPTIONS; do
+ _options=${_options},$i
+ done
+ 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
}
--
2.30.1
Looks good.
Acked-by: Kairui Song <kasong(a)redhat.com>
--
Best Regards,
Kairui Song