Ok, thanks.
On Tue, Jun 8, 2021 at 8:37 AM Coiby Xu <coxu(a)redhat.com> wrote:
On Tue, Jun 08, 2021 at 02:29:24AM +0800, Kairui Song wrote:
>On Mon, Jun 7, 2021 at 7:26 AM Coiby Xu <coxu(a)redhat.com> wrote:
>>
>> This patch fixes bz1941106 and bz1941905 which passed empty rd.znet to the
>> kernel command line in the following cases,
>> - The IBM (Z15) KVM guest uses virtio for all devices including network
>> device, so there is no znet device for IBM KVM guest. So we can't
>> assume a s390x machine always has a znet device.
>> - When a bridged network is used, kexec-tools tries to obtain the znet
>> configuration from the ifcfg script of the bridged network rather than
>> from the ifcfg script of znet device.
>>
>> We can iterate /sys/bus/ccwgroup/devices to tell if there if there is
>> a znet network device. By getting an ifname from znet, we can also avoid
>> mistaking the slave netdev as a znet network device in a bridged network
>> or bonded network.
>>
>> Note: This patch also assumes there is only one znet device as commit
>> 7148c0a30dfc48221eadf255e8a89619f98a8752 ("add s390x netdev setup")
>> which greatly simplifies the code. According to IBM [1], there could be
>> more than znet devices for a z/VM system and a z/VM system may have a
>> non-znet network device like ConnectX. Since kdump_setup_znet was
>> introduced in 2012 and so far there is no known customer complaint that
>> invalidates this assumption I think it's safe to assume an IBM z/VM
>> system only has one znet device. Besides, there is no z/VM system found
>> on beaker to test the alternative scenarios.
>>
>> [1]
https://bugzilla.redhat.com/show_bug.cgi?id=1941905#c13
>>
>> Signed-off-by: Coiby Xu <coxu(a)redhat.com>
>> ---
>> v1 -> v2:
>> - fix the error of passing $_netdev instead of $_znet_netdev to
>> kdump_setup_znet [Kairui]
>> ---
>> dracut-module-setup.sh | 35 +++++++++++++++++++++++++++++++++--
>> 1 file changed, 33 insertions(+), 2 deletions(-)
>>
>> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
>> index a99a0ea..a8ea63b 100755
>> --- a/dracut-module-setup.sh
>> +++ b/dracut-module-setup.sh
>> @@ -460,6 +460,34 @@ kdump_setup_vlan() {
>> fi
>> }
>>
>> +# find online znet device
>> +# return ifname (_netdev)
>> +# code reaped from the list_configured function of
>> +#
https://github.com/hreinecke/s390-tools/blob/master/zconf/znetconf
>> +find_online_znet_device() {
>> + local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices"
>> + local NETWORK_DEVICES d ifname ONLINE
>> + NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR -type l)
>> + for d in $NETWORK_DEVICES
>> + do
>> + read ONLINE < $d/online
>> + if [ $ONLINE -ne 1 ]; then
>> + continue
>> + fi
>> + # determine interface name, if there (only for qeth and if
>> + # device is online)
>> + if [ -f $d/if_name ]
>> + then
>> + read ifname < $d/if_name
>> + elif [ -d $d/net ]
>> + then
>> + ifname=$(ls $d/net/)
>> + fi
>> + [ -n "$ifname" ] && break
>> + done
>> + echo -n "$ifname"
>> +}
>> +
>> # setup s390 znet cmdline
>> # $1: netdev (ifname)
>> # $2: nmcli connection show output
>> @@ -526,6 +554,7 @@ kdump_get_remote_ip()
>> kdump_install_net() {
>> local _destaddr _srcaddr _route _netdev _nm_show_cmd kdumpnic
>> local _static _proto _ip_conf _ip_opts _ifname_opts
>> + local _znet_netdev _nm_show_cmd_znet
>>
>> _destaddr=$(kdump_get_remote_ip $1)
>> _route=$(kdump_get_ip_route $_destaddr)
>> @@ -535,8 +564,10 @@ kdump_install_net() {
>> _netmac=$(kdump_get_mac_addr $_netdev)
>> kdumpnic=$(kdump_setup_ifname $_netdev)
>>
>> - if [ "$(uname -m)" = "s390x" ]; then
>> - $(kdump_setup_znet "$_netdev" "$_nm_show_cmd")
>> + _znet_netdev=$(find_online_znet_device)
>> + if [[ -n "$_znet_netdev" ]]; then
>
>Hi Coiby, all looks good, just one question here, in what case
>$_znet_netdev will be empty? And we just skip the setup here in that
>case?
Hi. Thanks for reviewing the patch! s390x KVM machine is known to have
virtio network device so $_znet_netdev would be empty for this machine.
>
>> + _nm_show_cmd_znet=$(get_nmcli_connection_show_cmd_by_ifname
"$_znet_netdev")
>> + $(kdump_setup_znet "$_znet_netdev"
"$_nm_show_cmd_znet")
>> if [[ $? != 0 ]]; then
>> derror "Failed to set up znet"
>> exit 1
>> --
>> 2.31.1
>> _______________________________________________
>> 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
Acked-by: Kairui Song <kasong(a)redhat.com>
--
Best Regards,
Kairui Song