diff --git a/.github/labeler.yml b/.github/labeler.yml index 5667c63571..dda81b275b 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -382,10 +382,6 @@ dasd_mod: - changed-files: - any-glob-to-any-file: 'modules.d/95dasd_mod/*' -dasd_rules: - - changed-files: - - any-glob-to-any-file: 'modules.d/95dasd_rules/*' - dcssblk: - changed-files: - any-glob-to-any-file: 'modules.d/95dcssblk/*' @@ -426,10 +422,6 @@ nvmf: - changed-files: - any-glob-to-any-file: 'modules.d/95nvmf/*' -qeth_rules: - - changed-files: - - any-glob-to-any-file: 'modules.d/95qeth_rules/*' - resume: - changed-files: - any-glob-to-any-file: 'modules.d/95resume/*' @@ -462,10 +454,6 @@ zfcp: - changed-files: - any-glob-to-any-file: 'modules.d/95zfcp/*' -zfcp_rules: - - changed-files: - - any-glob-to-any-file: 'modules.d/95zfcp_rules/*' - znet: - changed-files: - any-glob-to-any-file: 'modules.d/95znet/*' diff --git a/man/dracut.cmdline.7.asc b/man/dracut.cmdline.7.asc index ecdb366dcf..bb5a9e89ee 100644 --- a/man/dracut.cmdline.7.asc +++ b/man/dracut.cmdline.7.asc @@ -972,19 +972,38 @@ root=virtiofs:host rw DASD ~~~~ **rd.dasd=**....:: - same syntax as the kernel module parameter (s390 only) + same syntax as the kernel module parameter (s390 only). + For more details on the syntax see the IBM book + "Linux on IBM Z and IBM LinuxONE - Device Drivers, Features, and Commands" + https://www.ibm.com/docs/en/linux-on-systems?topic=overview-device-drivers-features-commands. + This parameter can be specified multiple times. ++ +NOTE: + This parameter is no longer handled by dracut itself but with the exact + same syntax by + https://github.com/ibm-s390-linux/s390-tools/tree/master/zdev/dracut/95zdev. ZFCP ~~~~ **rd.zfcp=**____,____,____:: rd.zfcp can be specified multiple times on the kernel command line. ++ +NOTE: + This parameter is no longer handled by dracut itself but with the exact + same syntax by + https://github.com/ibm-s390-linux/s390-tools/tree/master/zdev/dracut/95zdev. **rd.zfcp=**____:: If NPIV is enabled and the 'allow_lun_scan' parameter to the zfcp - module is set to 'Y' then the zfcp adaptor will be initiating a + module is set to 'Y' then the zfcp driver will be initiating a scan internally and the and parameters can be omitted. + +NOTE: + This parameter is no longer handled by dracut itself but with the exact + same syntax by + https://github.com/ibm-s390-linux/s390-tools/tree/master/zdev/dracut/95zdev. ++ [listing] .Example -- @@ -998,9 +1017,12 @@ rd.zfcp=0.0.4000 ZNET ~~~~ **rd.znet=**____,____,____:: - The whole parameter is appended to /etc/ccw.conf, which is used on - RHEL/Fedora with ccw_init, which is called from udev for certain - devices on z-series. + Activates a channel-attached network interface on s390 architecture. + is one of: qeth, lcs, ctc. + is a comma-separated list of ccw device bus-IDs. + The list consists of 3 entries with nettype qeth, and 2 for other nettype. + is a comma-separated list of = pairs, + where refers to a device sysfs attribute to which gets written. rd.znet can be specified multiple times on the kernel command line. **rd.znet_ifname=**____:____:: diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh index ddb1dc3091..10df22ae15 100755 --- a/modules.d/45ifcfg/write-ifcfg.sh +++ b/modules.d/45ifcfg/write-ifcfg.sh @@ -10,68 +10,21 @@ mkdir -m 0755 -p /tmp/ifcfg/ # shellcheck disable=SC2174 mkdir -m 0755 -p /tmp/ifcfg-leases/ -get_config_line_by_subchannel() { - local CHANNELS - local line - - CHANNELS="$1" - while read -r line || [ -n "$line" ]; do - if strstr "$line" "$CHANNELS"; then - echo "$line" - return 0 - fi - done < /etc/ccw.conf - return 1 -} - print_s390() { local _netif local SUBCHANNELS - local OPTIONS - local NETTYPE - local CONFIG_LINE local i - local channel - local OLD_IFS _netif="$1" # if we find ccw channel, then use those, instead of # of the MAC - SUBCHANNELS=$({ - for i in /sys/class/net/"$_netif"/device/cdev[0-9]*; do - [ -e "$i" ] || continue - channel=$(readlink -f "$i") - printf '%s' "${channel##*/}," - done - }) + # [iface_get_subchannels() from /lib/net-lib.sh sourced at top of this file] + SUBCHANNELS=$(iface_get_subchannels "$_netif") [ -n "$SUBCHANNELS" ] || return 1 SUBCHANNELS=${SUBCHANNELS%,} echo "SUBCHANNELS=\"${SUBCHANNELS}\"" - CONFIG_LINE=$(get_config_line_by_subchannel "$SUBCHANNELS") - # shellcheck disable=SC2181 - [ $? -ne 0 -o -z "$CONFIG_LINE" ] && return 0 - - OLD_IFS=$IFS - IFS="," - # shellcheck disable=SC2086 - set -- $CONFIG_LINE - IFS=$OLD_IFS - NETTYPE=$1 - shift - SUBCHANNELS="$1" - OPTIONS="" - shift - while [ $# -gt 0 ]; do - case $1 in - *=*) OPTIONS="$OPTIONS $1" ;; - esac - shift - done - OPTIONS=${OPTIONS## } - echo "NETTYPE=\"${NETTYPE}\"" - echo "OPTIONS=\"${OPTIONS}\"" return 0 } diff --git a/modules.d/80cms/cms-write-ifcfg.sh b/modules.d/80cms/cms-write-ifcfg.sh index ecfd53efb0..9126309212 100755 --- a/modules.d/80cms/cms-write-ifcfg.sh +++ b/modules.d/80cms/cms-write-ifcfg.sh @@ -81,21 +81,8 @@ EOF fi # colons in SEARCHDNS already replaced with spaces above for /etc/resolv.conf [[ $SEARCHDNS ]] && echo "DOMAIN=\"$SEARCHDNS\"" >> "$IFCFGFILE" - [[ $NETTYPE ]] && echo "NETTYPE=$NETTYPE" >> "$IFCFGFILE" [[ $PEERID ]] && echo "PEERID=$PEERID" >> "$IFCFGFILE" - [[ $PORTNAME ]] && echo "PORTNAME=$PORTNAME" >> "$IFCFGFILE" - [[ $CTCPROT ]] && echo "CTCPROT=$CTCPROT" >> "$IFCFGFILE" [[ $MACADDR ]] && echo "MACADDR=$MACADDR" >> "$IFCFGFILE" - optstr="" - for option in LAYER2 PORTNO; do - [ -z "${!option}" ] && continue - [ -n "$optstr" ] && optstr=${optstr}" " - optstr=${optstr}$(echo ${option} | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')"="${!option} - done - # write single quotes since network.py removes double quotes but we need quotes - echo "OPTIONS='$optstr'" >> "$IFCFGFILE" - unset option - unset optstr unset DNS1 unset DNS2 echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab diff --git a/modules.d/80cms/cmssetup.sh b/modules.d/80cms/cmssetup.sh index 68e45632fe..5e5b926718 100755 --- a/modules.d/80cms/cmssetup.sh +++ b/modules.d/80cms/cmssetup.sh @@ -1,35 +1,18 @@ #!/bin/bash type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh - -function sysecho() { - file="$1" - shift - local i=1 - while [ $i -le 10 ]; do - if [ ! -f "$file" ]; then - sleep 1 - i=$((i + 1)) - else - break - fi - done - local status - read -r status < "$file" - if [[ $status != "$*" ]]; then - [ -f "$file" ] && echo "$*" > "$file" - fi -} +type zdev_parse_dasd_list > /dev/null 2>&1 || . /lib/s390-tools/zdev-from-dasd_mod.dasd function dasd_settle() { - local dasd_status=/sys/bus/ccw/devices/$1/status + local dasd_status + dasd_status=$(lszdev dasd "$1" --columns ATTRPATH:status --no-headings --active) if [ ! -f "$dasd_status" ]; then return 1 fi local i=1 while [ $i -le 60 ]; do local status - read -r status < "$dasd_status" + status=$(lszdev dasd "$1" --columns ATTR:status --no-headings --active) case $status in online | unformatted) return 0 @@ -43,77 +26,23 @@ function dasd_settle() { return 1 } -function dasd_settle_all() { - for dasdccw in $(while read -r line || [ -n "$line" ]; do echo "${line%%(*}"; done < /proc/dasd/devices); do - if ! dasd_settle "$dasdccw"; then - echo $"Could not access DASD $dasdccw in time" - return 1 - fi - done - return 0 -} - -# prints a canonocalized device bus ID for a given devno of any format -function canonicalize_devno() { - case ${#1} in - 3) echo "0.0.0${1}" ;; - 4) echo "0.0.${1}" ;; - *) echo "${1}" ;; - esac - return 0 -} - # read file from CMS and write it to /tmp function readcmsfile() { # $1=dasdport $2=filename local dev - local numcpus local devname local ret=0 if [ $# -ne 2 ]; then return; fi - # precondition: udevd created dasda block device node - if ! dasd_cio_free -d "$1"; then - echo $"DASD $1 could not be cleared from device blacklist" - return 1 - fi - - modprobe dasd_mod dasd="$CMSDASD" - modprobe dasd_eckd_mod - udevadm settle - - # precondition: dasd_eckd_mod driver incl. dependencies loaded, - # dasd_mod must be loaded without setting any DASD online - dev=$(canonicalize_devno "$1") - numcpus=$( - while read -r line || [ -n "$line" ]; do - if strstr "$line" "# processors"; then - echo "${line##*:}" - break - fi - done < /proc/cpuinfo - ) + # precondition: udevd created block device node - if [ "${numcpus}" -eq 1 ]; then - echo 1 > /sys/bus/ccw/devices/"$dev"/online - else - if ! sysecho /sys/bus/ccw/devices/"$dev"/online 1; then - echo $"DASD $dev could not be set online" - return 1 - fi - udevadm settle - if ! dasd_settle "$dev"; then - echo $"Could not access DASD $dev in time" - return 1 - fi + dev="$1" + chzdev --enable --active --yes --quiet --no-root-update --force dasd "$dev" || return 1 + if ! dasd_settle "$dev"; then + echo $"Could not access DASD $dev in time" + return 1 fi - udevadm settle - - devname=$( - cd /sys/bus/ccw/devices/"$dev"/block || exit - set -- * - [ -b /dev/"$1" ] && echo "$1" - ) - devname=${devname:-dasda} + devname=$(lszdev dasd "$dev" --columns NAMES --no-headings --active) + [[ -n $devname ]] || return 1 [[ -d /mnt ]] || mkdir -p /mnt if cmsfs-fuse --to=UTF-8 -a /dev/"$devname" /mnt; then @@ -125,20 +54,22 @@ function readcmsfile() { # $1=dasdport $2=filename ret=1 fi - if ! sysecho /sys/bus/ccw/devices/"$dev"/online 0; then - echo $"DASD $dev could not be set offline again" - #return 1 - fi - udevadm settle + chzdev --disable --active --yes --quiet --no-root-update --force dasd "$dev" # unbind all dasds to unload the dasd modules for a clean start ( cd /sys/bus/ccw/drivers/dasd-eckd || exit - for i in *.*; do echo "$i" > unbind; done + for i in *.*; do echo "$i" > unbind 2> /dev/null; done + ) + ( + cd /sys/bus/ccw/drivers/dasd-fba || exit + for i in *.*; do echo "$i" > unbind 2> /dev/null; done ) udevadm settle modprobe -r dasd_eckd_mod udevadm settle + modprobe -r dasd_fba_mod + udevadm settle modprobe -r dasd_diag_mod udevadm settle modprobe -r dasd_mod @@ -151,13 +82,19 @@ processcmsfile() { SUBCHANNELS="$(echo "$SUBCHANNELS" | sed 'y/ABCDEF/abcdef/')" if [[ $NETTYPE ]]; then - ( - echo -n "$NETTYPE","$SUBCHANNELS" - [[ $PORTNAME ]] && echo -n ",portname=$PORTNAME" - [[ $LAYER2 ]] && echo -n ",layer2=$LAYER2" - [[ $NETTYPE == "ctc" ]] && [[ $CTCPROT ]] && echo -n ",protocol=$CTCPROT" - echo - ) >> /etc/ccw.conf + _cms_attrs="" + if [[ $PORTNAME ]]; then + if [[ $NETTYPE == lcs ]]; then + _cms_attrs="$_cms_attrs portno=$PORTNAME" + else + _cms_attrs="$_cms_attrs portname=$PORTNAME" + fi + fi + [[ $LAYER2 ]] && _cms_attrs="$_cms_attrs layer2=$LAYER2" + [[ $CTCPROT ]] && _cms_attrs="$_cms_attrs protocol=$CTCPROT" + # shellcheck disable=SC2086 + chzdev --enable --persistent --yes --no-root-update --force \ + "$NETTYPE" "$SUBCHANNELS" $_cms_attrs 2>&1 | vinfo OLDIFS=$IFS IFS=, @@ -178,16 +115,13 @@ processcmsfile() { [[ -f /etc/udev/rules.d/90-net.rules ]] \ || printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$name source_hook initqueue/online"\n' >> /etc/udev/rules.d/99-cms.rules udevadm control --reload - znet_cio_free fi if [[ $DASD ]] && [[ $DASD != "none" ]]; then - echo "$DASD" | normalize_dasd_arg > /etc/dasd.conf - echo "options dasd_mod dasd=$DASD" > /etc/modprobe.d/dasd_mod.conf - dasd_cio_free + echo "$DASD" | zdev_parse_dasd_list globals 2>&1 | vinfo + echo "$DASD" | zdev_parse_dasd_list ranges 2>&1 | vinfo fi - unset _do_zfcp for i in ${!FCP_*}; do echo "${!i}" | while read -r port rest || [ -n "$port" ]; do case $port in @@ -200,12 +134,24 @@ processcmsfile() { port="0.0.$port" ;; esac - echo "$port" "$rest" >> /etc/zfcp.conf + # shellcheck disable=SC2086 + set -- $rest + SAVED_IFS="$IFS" + IFS=":" + # Intentionally do not dynamically activate now, but only generate udev + # rules, which activate the device later during udev coldplug. + if [[ -z $rest ]]; then + chzdev --enable --persistent \ + --no-settle --yes --quiet --no-root-update --force \ + zfcp-host "$port" 2>&1 | vinfo + else + chzdev --enable --persistent \ + --no-settle --yes --quiet --no-root-update --force \ + zfcp-lun "$port:$*" 2>&1 | vinfo + fi + IFS="$SAVED_IFS" done - _do_zfcp=1 done - [[ $_do_zfcp ]] && zfcp_cio_free - unset _do_zfcp } [[ $CMSDASD ]] || CMSDASD=$(getarg "CMSDASD=") diff --git a/modules.d/80cms/module-setup.sh b/modules.d/80cms/module-setup.sh index 2b280e0f37..5b33cd1806 100755 --- a/modules.d/80cms/module-setup.sh +++ b/modules.d/80cms/module-setup.sh @@ -4,6 +4,7 @@ check() { arch=${DRACUT_ARCH:-$(uname -m)} [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + require_binaries chzdev lszdev || return 1 return 255 } @@ -11,13 +12,13 @@ check() { depends() { arch=${DRACUT_ARCH:-$(uname -m)} [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 - echo znet zfcp dasd dasd_mod bash + echo znet bash return 0 } # called by dracut installkernel() { - instmods zfcp + instmods zfcp dasd_mod dasd_eckd_mod dasd_fba_mod dasd_diag_mod } # called by dracut @@ -27,8 +28,8 @@ install() { inst_script "$moddir/cmsifup.sh" /sbin/cmsifup # shellcheck disable=SC2046 inst_multiple /etc/cmsfs-fuse/filetypes.conf /etc/udev/rules.d/99-fuse.rules /etc/fuse.conf \ - cmsfs-fuse fusermount bash insmod rmmod cat normalize_dasd_arg sed \ - $(rpm -ql s390utils-base) awk getopt + cmsfs-fuse fusermount bash insmod rmmod cat /lib/s390-tools/zdev-from-dasd_mod.dasd sed \ + awk getopt chzdev lszdev inst_libdir_file "gconv/*" #inst /usr/lib/locale/locale-archive diff --git a/modules.d/95dasd/module-setup.sh b/modules.d/95dasd/module-setup.sh index 180da1406c..825f95d810 100755 --- a/modules.d/95dasd/module-setup.sh +++ b/modules.d/95dasd/module-setup.sh @@ -4,20 +4,18 @@ check() { local _arch=${DRACUT_ARCH:-$(uname -m)} [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 - require_binaries normalize_dasd_arg || return 1 + require_binaries dasdconf.sh || return 1 return 0 } # called by dracut depends() { - echo "dasd_mod" return 0 } # called by dracut install() { - inst_hook cmdline 30 "$moddir/parse-dasd.sh" - inst_multiple dasdinfo dasdconf.sh normalize_dasd_arg + inst_multiple dasdconf.sh conf=/etc/dasd.conf if [[ $hostonly && -f $conf ]]; then inst -H $conf diff --git a/modules.d/95dasd/parse-dasd.sh b/modules.d/95dasd/parse-dasd.sh deleted file mode 100755 index cda3970c5b..0000000000 --- a/modules.d/95dasd/parse-dasd.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -for dasd_arg in $(getargs rd.dasd= -d rd_DASD= DASD=); do - ( - local OLDIFS="$IFS" - IFS="," - # shellcheck disable=SC2086 - set -- $dasd_arg - IFS="$OLDIFS" - echo "$@" | normalize_dasd_arg >> /etc/dasd.conf - ) -done diff --git a/modules.d/95dasd_mod/module-setup.sh b/modules.d/95dasd_mod/module-setup.sh index c59dd3acee..155eaacc71 100755 --- a/modules.d/95dasd_mod/module-setup.sh +++ b/modules.d/95dasd_mod/module-setup.sh @@ -4,7 +4,6 @@ check() { local _arch=${DRACUT_ARCH:-$(uname -m)} [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 - require_binaries grep sed seq return 0 } @@ -22,6 +21,5 @@ installkernel() { # called by dracut install() { inst_hook cmdline 31 "$moddir/parse-dasd-mod.sh" - inst_multiple grep sed seq inst_multiple -o dasd_cio_free } diff --git a/modules.d/95dasd_mod/parse-dasd-mod.sh b/modules.d/95dasd_mod/parse-dasd-mod.sh index 2b86d45434..b635ecf9c2 100755 --- a/modules.d/95dasd_mod/parse-dasd-mod.sh +++ b/modules.d/95dasd_mod/parse-dasd-mod.sh @@ -1,18 +1,4 @@ #!/bin/sh -mod_args="" - -for dasd_arg in $(getargs rd.dasd= -d rd_DASD= DASD=); do - mod_args="$mod_args,$dasd_arg" -done - -mod_args="${mod_args#*,}" - -if [ -x /sbin/dasd_cio_free -a -n "$mod_args" ]; then - [ -d /etc/modprobe.d ] || mkdir -m 0755 -p /etc/modprobe.d - echo "options dasd_mod dasd=$mod_args" >> /etc/modprobe.d/dasd_mod.conf -fi - -unset dasd_arg if [ -x /sbin/dasd_cio_free ]; then dasd_cio_free fi diff --git a/modules.d/95dasd_rules/module-setup.sh b/modules.d/95dasd_rules/module-setup.sh deleted file mode 100755 index 06c57a48eb..0000000000 --- a/modules.d/95dasd_rules/module-setup.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -# called by dracut -cmdline() { - is_dasd() { - local _dev=$1 - local _devpath - _devpath=$( - cd -P /sys/dev/block/"$_dev" || exit - echo "$PWD" - ) - - [ "${_devpath#*/dasd}" == "$_devpath" ] && return 1 - _ccw="${_devpath%%/block/*}" - echo "rd.dasd=${_ccw##*/}" - return 0 - } - [[ $hostonly ]] || [[ $mount_needs ]] && { - for_each_host_dev_and_slaves_all is_dasd || return 255 - } | sort | uniq -} - -# called by dracut -check() { - local _arch=${DRACUT_ARCH:-$(uname -m)} - local found=0 - local bdev - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 - - [[ $hostonly ]] || [[ $mount_needs ]] && { - for bdev in /sys/block/*; do - case "${bdev##*/}" in - dasd*) - found=$((found + 1)) - break - ;; - esac - done - [ $found -eq 0 ] && return 255 - } - return 0 -} - -# called by dracut -depends() { - echo 'dasd_mod' bash - return 0 -} - -# called by dracut -install() { - inst_hook cmdline 30 "$moddir/parse-dasd.sh" - if [[ $hostonly_cmdline == "yes" ]]; then - local _dasd - _dasd=$(cmdline) - [[ $_dasd ]] && printf "%s\n" "$_dasd" >> "${initdir}/etc/cmdline.d/95dasd.conf" - fi - if [[ $hostonly ]]; then - inst_rules_wildcard "51-dasd-*.rules" - inst_rules_wildcard "41-dasd-*.rules" - mark_hostonly /etc/udev/rules.d/51-dasd-*.rules - mark_hostonly /etc/udev/rules.d/41-dasd-*.rules - fi - inst_rules 59-dasd.rules -} diff --git a/modules.d/95dasd_rules/parse-dasd.sh b/modules.d/95dasd_rules/parse-dasd.sh deleted file mode 100755 index 4454aec3e3..0000000000 --- a/modules.d/95dasd_rules/parse-dasd.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -allow_device() { - local ccw=$1 - - if [ -x /sbin/cio_ignore ] && cio_ignore -i "$ccw" > /dev/null; then - cio_ignore -r "$ccw" - fi -} - -if [[ -f /sys/firmware/ipl/ipl_type ]] && [[ $(< /sys/firmware/ipl/ipl_type) == "ccw" ]]; then - allow_device "$(< /sys/firmware/ipl/device)" -fi - -for dasd_arg in $(getargs root=) $(getargs resume=); do - [[ $dasd_arg =~ /dev/disk/by-path/ccw-* ]] || continue - - ccw_dev="${dasd_arg##*/ccw-}" - allow_device "${ccw_dev%%-*}" -done - -for dasd_arg in $(getargs rd.dasd=); do - IFS=',' read -r -a devs <<< "$dasd_arg" - declare -p devs - for dev in "${devs[@]}"; do - case "$dev" in - autodetect | probeonly) ;; - - *-*) - IFS="-" read -r start end _ <<< "${dev%(ro)}" - prefix=${start%.*} - start=${start##*.} - for rdev in $(seq $((16#$start)) $((16#$end))); do - allow_device "$(printf "%s.%04x" "$prefix" "$rdev")" - done - ;; - *) - IFS="." read -r sid ssid chan _ <<< "${dev%(ro)}" - allow_device "$(printf "%01x.%01x.%04x" $((16#$sid)) $((16#$ssid)) $((16#$chan)))" - ;; - esac - done -done diff --git a/modules.d/95qeth_rules/module-setup.sh b/modules.d/95qeth_rules/module-setup.sh deleted file mode 100755 index a84ac1514d..0000000000 --- a/modules.d/95qeth_rules/module-setup.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -# called by dracut -check() { - local _arch=${DRACUT_ARCH:-$(uname -m)} - local _online=0 - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 - dracut_module_included network || return 1 - - [[ $hostonly ]] && { - for i in /sys/devices/qeth/*/online; do - [ ! -f "$i" ] && continue - read -r _online < "$i" - [ "$_online" -eq 1 ] && return 0 - done - } - return 255 -} - -# called by dracut -installkernel() { - instmods qeth -} - -# called by dracut -install() { - ccwid() { - qeth_path=$(readlink -e -q "$1"/device) - basename "$qeth_path" - } - - inst_rules_qeth() { - for rule in /etc/udev/rules.d/{4,5}1-qeth-${1}.rules; do - # prefer chzdev generated 41- rules - if [ -f "$rule" ]; then - inst_rules "$rule" - break - fi - done - } - - has_carrier() { - carrier=0 - # not readable in qeth interfaces - # that have just been assembled, ignore - # read error and assume no carrier - read -r carrier 2> /dev/null < "$1/carrier" - [ "$carrier" -eq 1 ] && return 0 - return 1 - } - - for dev in /sys/class/net/*; do - has_carrier "$dev" || continue - id=$(ccwid "$dev") - [ -n "$id" ] && inst_rules_qeth "$id" - done - -} diff --git a/modules.d/95zfcp/module-setup.sh b/modules.d/95zfcp/module-setup.sh index e1f3aa35a0..b547f9bc14 100755 --- a/modules.d/95zfcp/module-setup.sh +++ b/modules.d/95zfcp/module-setup.sh @@ -5,7 +5,7 @@ check() { arch=${DRACUT_ARCH:-$(uname -m)} [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 - require_binaries zfcp_cio_free grep sed seq || return 1 + require_binaries zfcp_cio_free sed || return 1 return 0 } @@ -23,7 +23,7 @@ installkernel() { # called by dracut install() { inst_hook cmdline 30 "$moddir/parse-zfcp.sh" - inst_multiple zfcp_cio_free grep sed seq + inst_multiple zfcp_cio_free sed inst_script /sbin/zfcpconf.sh inst_rules 56-zfcp.rules diff --git a/modules.d/95zfcp/parse-zfcp.sh b/modules.d/95zfcp/parse-zfcp.sh index 495aa67fd0..41216dd960 100755 --- a/modules.d/95zfcp/parse-zfcp.sh +++ b/modules.d/95zfcp/parse-zfcp.sh @@ -2,15 +2,4 @@ getargbool 1 rd.zfcp.conf -d -n rd_NO_ZFCPCONF || rm /etc/zfcp.conf -for zfcp_arg in $(getargs rd.zfcp -d 'rd_ZFCP='); do - echo "$zfcp_arg" | grep '^0\.[0-9a-fA-F]\.[0-9a-fA-F]\{4\}\(,0x[0-9a-fA-F]\{16\},0x[0-9a-fA-F]\{16\}\)\?$' > /dev/null - test $? -ne 0 && die "For argument 'rd.zfcp=$zfcp_arg'\nSorry, invalid format." - ( - IFS="," - # shellcheck disable=SC2086 - set $zfcp_arg - echo "$@" >> /etc/zfcp.conf - ) -done - zfcp_cio_free diff --git a/modules.d/95zfcp_rules/module-setup.sh b/modules.d/95zfcp_rules/module-setup.sh deleted file mode 100755 index dfa795146d..0000000000 --- a/modules.d/95zfcp_rules/module-setup.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash - -# called by dracut -cmdline() { - is_zfcp() { - local _dev=$1 - local _devpath - _devpath=$( - cd -P /sys/dev/block/"$_dev" || exit - echo "$PWD" - ) - local _sdev _scsiid _hostno _lun _wwpn _ccw _port_type - local _allow_lun_scan _is_npiv - - read -r _allow_lun_scan < /sys/module/zfcp/parameters/allow_lun_scan - [ "${_devpath#*/sd}" == "$_devpath" ] && return 1 - _sdev="${_devpath%%/block/*}" - [ -e "${_sdev}"/fcp_lun ] || return 1 - _scsiid="${_sdev##*/}" - _hostno="${_scsiid%%:*}" - [ -d /sys/class/fc_host/host"${_hostno}" ] || return 1 - read -r _port_type < /sys/class/fc_host/host"${_hostno}"/port_type - case "$_port_type" in - NPIV*) - _is_npiv=1 - ;; - esac - read -r _ccw < "${_sdev}"/hba_id - if [ "$_is_npiv" ] && [ "$_allow_lun_scan" = "Y" ]; then - echo "rd.zfcp=${_ccw}" - else - read -r _lun < "${_sdev}"/fcp_lun - read -r _wwpn < "${_sdev}"/wwpn - echo "rd.zfcp=${_ccw},${_wwpn},${_lun}" - fi - return 0 - } - [[ $hostonly ]] || [[ $mount_needs ]] && { - for_each_host_dev_and_slaves_all is_zfcp - } | sort | uniq -} - -# called by dracut -check() { - local _arch=${DRACUT_ARCH:-$(uname -m)} - local _ccw - [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 - - [[ $hostonly ]] || [[ $mount_needs ]] && { - found=0 - for _ccw in /sys/bus/ccw/devices/*/host*; do - [ -d "$_ccw" ] || continue - found=$((found + 1)) - done - [ $found -eq 0 ] && return 255 - } - return 0 -} - -# called by dracut -depends() { - echo bash - return 0 -} - -# called by dracut -install() { - inst_hook cmdline 30 "$moddir/parse-zfcp.sh" - if [[ $hostonly_cmdline == "yes" ]]; then - local _zfcp - - for _zfcp in $(cmdline); do - printf "%s\n" "$_zfcp" >> "${initdir}/etc/cmdline.d/94zfcp.conf" - done - fi - if [[ $hostonly ]]; then - inst_rules_wildcard "51-zfcp-*.rules" - inst_rules_wildcard "41-zfcp-*.rules" - fi -} diff --git a/modules.d/95zfcp_rules/parse-zfcp.sh b/modules.d/95zfcp_rules/parse-zfcp.sh deleted file mode 100755 index a474b81b07..0000000000 --- a/modules.d/95zfcp_rules/parse-zfcp.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash - -create_udev_rule() { - local ccw=$1 - local wwpn=$2 - local lun=$3 - local _rule=/etc/udev/rules.d/51-zfcp-${ccw}.rules - local _cu_type _dev_type - - if [ -x /sbin/cio_ignore ] && cio_ignore -i "$ccw" > /dev/null; then - cio_ignore -r "$ccw" - fi - - if [ -e /sys/bus/ccw/devices/"${ccw}" ]; then - read -r _cu_type < /sys/bus/ccw/devices/"${ccw}"/cutype - read -r _dev_type < /sys/bus/ccw/devices/"${ccw}"/devtype - fi - if [ "$_cu_type" != "1731/03" ]; then - return 0 - fi - if [ "$_dev_type" != "1732/03" ] && [ "$_dev_type" != "1732/04" ]; then - return 0 - fi - - [ -z "$wwpn" ] || [ -z "$lun" ] && return - m=$(sed -n "/.*${wwpn}.*${lun}.*/p" "$_rule") - if [ -z "$m" ]; then - cat >> "$_rule" << EOF -ACTION=="add", KERNEL=="rport-*", ATTR{port_name}=="$wwpn", SUBSYSTEMS=="ccw", KERNELS=="$ccw", ATTR{[ccw/$ccw]$wwpn/unit_add}="$lun" -EOF - fi -} - -if [[ -f /sys/firmware/ipl/ipl_type ]] \ - && [[ $(< /sys/firmware/ipl/ipl_type) == "fcp" ]]; then - ( - read -r _wwpn < /sys/firmware/ipl/wwpn - read -r _lun < /sys/firmware/ipl/lun - read -r _ccw < /sys/firmware/ipl/device - - create_udev_rule "$_ccw" "$_wwpn" "$_lun" - ) -fi - -for zfcp_arg in $(getargs rd.zfcp); do - ( - OLDIFS="$IFS" - IFS="," - # shellcheck disable=SC2086 - set $zfcp_arg - IFS="$OLDIFS" - create_udev_rule "$1" "$2" "$3" - ) -done - -for zfcp_arg in $(getargs root=) $(getargs resume=); do - ( - case $zfcp_arg in - /dev/disk/by-path/ccw-*) - ccw_arg=${zfcp_arg##*/} - ;; - esac - if [ -n "$ccw_arg" ]; then - OLDIFS="$IFS" - IFS="-" - # shellcheck disable=SC2086 - set -- $ccw_arg - IFS="$OLDIFS" - _wwpn=${4%:*} - _lun=${4#*:} - create_udev_rule "$2" "$wwpn" "$lun" - fi - ) -done diff --git a/modules.d/95znet/module-setup.sh b/modules.d/95znet/module-setup.sh index df37c66089..95164bba64 100755 --- a/modules.d/95znet/module-setup.sh +++ b/modules.d/95znet/module-setup.sh @@ -5,7 +5,7 @@ check() { arch=${DRACUT_ARCH:-$(uname -m)} [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 - require_binaries znet_cio_free grep sed seq readlink || return 1 + require_binaries grep sed seq readlink chzdev || return 1 return 0 } @@ -24,6 +24,37 @@ installkernel() { # called by dracut install() { inst_hook cmdline 30 "$moddir/parse-ccw.sh" - inst_rules 81-ccw.rules - inst_multiple znet_cio_free grep sed seq readlink /lib/udev/ccw_init + inst_multiple grep sed seq readlink chzdev + if [[ $hostonly ]]; then + local _tempfile + _tempfile=$(mktemp --tmpdir="${DRACUT_TMPDIR}" dracut-zdev.XXXXXX) + { + chzdev qeth --export - --configured --persistent --quiet --type + chzdev lcs --export - --configured --persistent --quiet --type + chzdev ctc --export - --configured --persistent --quiet --type + } 2> /dev/null > "$_tempfile" + ddebug < "$_tempfile" + chzdev --import "$_tempfile" --persistent --base "/etc=$initdir/etc" \ + --yes --no-root-update --force 2>&1 | ddebug + lszdev --configured --persistent --info \ + --base "/etc=$initdir/etc" 2>&1 | ddebug + rm -f "$_tempfile" + # these are purely generated udev rules so we have to glob expand + # within $initdir and strip the $initdir prefix for mark_hostonly + local -a _array + # shellcheck disable=SC2155 + local _nullglob=$(shopt -p nullglob) + shopt -u nullglob + # shellcheck disable=SC2086 + readarray -t _array < <( + ls -1 $initdir/etc/udev/rules.d/41-*.rules 2> /dev/null + ) + [[ ${#_array[@]} -gt 0 ]] && mark_hostonly "${_array[@]#$initdir}" + # shellcheck disable=SC2086 + readarray -t _array < <( + ls -1 $initdir/etc/modprobe.d/s390x-*.conf 2> /dev/null + ) + [[ ${#_array[@]} -gt 0 ]] && mark_hostonly "${_array[@]#$initdir}" + $_nullglob + fi } diff --git a/modules.d/95znet/parse-ccw.sh b/modules.d/95znet/parse-ccw.sh index d89536059f..ccf05bc66e 100755 --- a/modules.d/95znet/parse-ccw.sh +++ b/modules.d/95znet/parse-ccw.sh @@ -1,7 +1,50 @@ #!/bin/bash +znet_base_args="--no-settle --yes --no-root-update --force" + +# at this point in time dracut's vinfo() only logs to journal which is hard for +# s390 users to find and access on a line mode console such as 3215 mode +# so use a vinfo alternative that still prints to the console via kmsg +znet_vinfo() { + while read -r _znet_vinfo_line || [ -n "$_znet_vinfo_line" ]; do + # Prefix "<30>" represents facility LOG_DAEMON 3 and loglevel INFO 6: + # (facility << 3) | level. + echo "<30>dracut: $_znet_vinfo_line" > /dev/kmsg + done +} + for ccw_arg in $(getargs rd.ccw -d 'rd_CCW=') $(getargs rd.znet -d 'rd_ZNET='); do - echo "$ccw_arg" >> /etc/ccw.conf + ( + SAVED_IFS="$IFS" + IFS="," + # shellcheck disable=SC2086 + set -- $ccw_arg + IFS="$SAVED_IFS" + type="$1" + subchannel1="$2" + subchannel2="$3" + subchannel3="$4" + echo "rd.znet ${ccw_arg} :" | znet_vinfo + if [ "$#" -lt 3 ]; then + echo "rd.znet needs at least 3 list items: type,subchannel1,subchannel2" | znet_vinfo + fi + if [ "$1" = "qeth" ]; then + if [ "$#" -lt 4 ]; then + echo "rd.znet for type qeth needs at least 4 list items: qeth,subchannel1,subchannel2,subchannel3" | znet_vinfo + fi + subchannels="$subchannel1:$subchannel2:$subchannel3" + shift 4 + # shellcheck disable=SC2086 + chzdev --enable --persistent $znet_base_args \ + "$type" "$subchannels" "$@" 2>&1 | znet_vinfo + else + subchannels="$subchannel1:$subchannel2" + shift 3 + # shellcheck disable=SC2086 + chzdev --enable --persistent $znet_base_args \ + "$type" "$subchannels" "$@" 2>&1 | znet_vinfo + fi + ) done for ifname in $(getargs rd.znet_ifname); do @@ -10,16 +53,16 @@ for ifname in $(getargs rd.znet_ifname); do warn "Invalid arguments for rd.znet_ifname=" else { - ifname_subchannels=${ifname_subchannels//,/|} + ifname_subchannels="${ifname_subchannels//,/|}" + # sanitize for use in udev label: replace non-word characters by _ + ifname_if_label="${ifname_if//[^[:word:]]/_}" - echo 'ACTION!="add|change", GOTO="ccw_ifname_end"' - echo 'ATTR{type}!="1", GOTO="ccw_ifname_end"' - echo 'SUBSYSTEM!="net", GOTO="ccw_ifname_end"' + echo "ACTION!=\"add|change\", GOTO=\"ccw_ifname_${ifname_if_label}_end\"" + echo "ATTR{type}!=\"1\", GOTO=\"ccw_ifname_${ifname_if_label}_end\"" + echo "SUBSYSTEM!=\"net\", GOTO=\"ccw_ifname_${ifname_if_label}_end\"" echo "SUBSYSTEMS==\"ccwgroup\", KERNELS==\"$ifname_subchannels\", DRIVERS==\"?*\" NAME=\"$ifname_if\"" - echo 'LABEL="ccw_ifname_end"' + echo "LABEL=\"ccw_ifname_${ifname_if_label}_end\"" - } > /etc/udev/rules.d/81-ccw-ifname.rules + } >> /etc/udev/rules.d/81-ccw-ifname.rules fi done - -znet_cio_free diff --git a/suse/README.susemaint b/suse/README.susemaint index 9b80a17454..5bcfd43464 100644 --- a/suse/README.susemaint +++ b/suse/README.susemaint @@ -355,4 +355,20 @@ were already merged a45048b8 fix(dracut): move hooks directory from /usr/lib to /var/lib 424717af fix: /etc/modprobe.d --> /run/modprobe.d (partially reverted) 4cc962aa fix(systemd-ask-password): no graphical output in aarch64 +6c55657e refactor(cms): use zdev to simplify handling CMSDASD=... boot option +53a5d10b refactor(cms): use consolidated zfcp config with zdev from s390-tools +168c0c66 refactor(cms): use consolidated dasd config with zdev from s390-tools +0b6d6952 refactor(cms): use consolidated network config with zdev from s390-tools +166e8a22 refactor(cms): remove now unnecessary inclusion of full s390utils-base +b5a35f9d feat(zfcp_rules): remove zfcp handling consolidated in s390-tools +7745a81a feat(zfcp): minimize zfcp handling consolidated in s390-tools +72c945ca feat(dasd_rules): remove dasd handling consolidated in s390-tools +2397c479 feat(dasd_mod): minimize dasd handling consolidated in s390-tools +36e1f884 feat(dasd): minimize dasd handling consolidated in s390-tools +658a21ac feat(znet): use zdev for consolidated device configuration +8707a69b docs(dracut.cmdline): generalize description of rd.znet +198a86c2 feat(qeth_rules): remove qeth handling consolidated in 95znet +22f51730 fix(znet): append to udev rules so each rd.znet_ifname is effective +2d8fa8be refactor(ifcfg): delete code duplication using iface_get_subchannels() +457e66e6 feat(ifcfg): minimize s390-specific network configuration aspects diff --git a/suse/dracut.spec b/suse/dracut.spec index 81e474d125..8fb8a9b87e 100644 --- a/suse/dracut.spec +++ b/suse/dracut.spec @@ -146,11 +146,8 @@ rm -rf %{buildroot}%{dracutlibdir}/modules.d/81cio_ignore rm -rf %{buildroot}%{dracutlibdir}/modules.d/91zipl rm -rf %{buildroot}%{dracutlibdir}/modules.d/95dasd rm -rf %{buildroot}%{dracutlibdir}/modules.d/95dasd_mod -rm -rf %{buildroot}%{dracutlibdir}/modules.d/95dasd_rules rm -rf %{buildroot}%{dracutlibdir}/modules.d/95dcssblk -rm -rf %{buildroot}%{dracutlibdir}/modules.d/95qeth_rules rm -rf %{buildroot}%{dracutlibdir}/modules.d/95zfcp -rm -rf %{buildroot}%{dracutlibdir}/modules.d/95zfcp_rules rm -rf %{buildroot}%{dracutlibdir}/modules.d/95znet %else rm -rf %{buildroot}%{dracutlibdir}/modules.d/00warpclock @@ -433,7 +430,6 @@ rm -f /var/adm/fillup-templates/sysconfig.kernel-mkinitrd %{dracutlibdir}/modules.d/95cifs %ifarch s390 s390x %{dracutlibdir}/modules.d/95dasd_mod -%{dracutlibdir}/modules.d/95dasd_rules %{dracutlibdir}/modules.d/95dcssblk %endif %{dracutlibdir}/modules.d/95debug @@ -445,9 +441,6 @@ rm -f /var/adm/fillup-templates/sysconfig.kernel-mkinitrd %{dracutlibdir}/modules.d/95nbd %{dracutlibdir}/modules.d/95nfs %{dracutlibdir}/modules.d/95nvmf -%ifarch s390 s390x -%{dracutlibdir}/modules.d/95qeth_rules -%endif %{dracutlibdir}/modules.d/95resume %{dracutlibdir}/modules.d/95rootfs-block %{dracutlibdir}/modules.d/95ssh-client @@ -455,9 +448,6 @@ rm -f /var/adm/fillup-templates/sysconfig.kernel-mkinitrd %{dracutlibdir}/modules.d/95udev-rules %{dracutlibdir}/modules.d/95virtfs %{dracutlibdir}/modules.d/95virtiofs -%ifarch s390 s390x -%{dracutlibdir}/modules.d/95zfcp_rules -%endif %{dracutlibdir}/modules.d/97biosdevname %ifarch %ix86 %exclude %{dracutlibdir}/modules.d/96securityfs