Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Alexander_Naumov:SLE-12:Update
kdump
kdump-move-network-setup-to-module-setup.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File kdump-move-network-setup-to-module-setup.patch of Package kdump
From: Petr Tesarik <ptesarik@suse.cz> Date: Tue Sep 23 11:02:22 2014 +0200 Subject: Move dracut network command line to module-setup.sh References: bnc#885897 Patch-mainline: v0.8.16 Git-commit: 16e3640c2bcbb08fb31c7c3da03a8fb726d7686a This is mostly a cleanup to allow adding more code to module-setup.sh without too much duplication. Signed-off-by: Petr Tesarik <ptesarik@suse.cz> --- init/mkdumprd | 54 ------------------------------- init/module-setup.sh | 76 ++++++++++++++++++++++++++++++++++++++++++--- init/setup-kdump.functions | 19 ++++++++++- 3 files changed, 90 insertions(+), 59 deletions(-) --- a/init/mkdumprd +++ b/init/mkdumprd @@ -120,8 +120,6 @@ function run_mkinitrd() # Create a new initrd using dracut {{{ function run_dracut() { - local modules="kdump" - DRACUT_ARGS="--force --hostonly --omit 'plymouth resume usrmount'" DRACUT_ARGS="$DRACUT_ARGS --compress='xz -0 --check=crc32'" @@ -136,60 +134,10 @@ function run_dracut() i=$((i+1)) done - # Check for additional modules - neednet= - for protocol in "${kdump_Protocol[@]}" ; do - if [ "$protocol" = "nfs" ]; then - modules="$modules nfs" - fi - if [ "$protocol" = "cifs" -o "$protocol" = "smb" ]; then - modules="$modules cifs" - fi - if [ "$protocol" != "file" ]; then - neednet=y - fi - done - - # network configuration - if [ -n "$KDUMP_SMTP_SERVER" -a -n "$KDUMP_NOTIFICATION_TO" ]; then - neednet=y - fi - if [ "$KDUMP_NETCONFIG" = "auto" ] ; then - status_message "Network: auto" - if [ -n "$neednet" ]; then - DRACUT_ARGS+=" --kernel-cmdline 'rd.neednet=1 ip=any'" - modules="$modules network" - fi - elif [ -z "$KDUMP_NETCONFIG" ] ; then - status_message "Network: none" - else - interface=$(echo "$KDUMP_NETCONFIG" | cut -d ':' -f 1) - mode=$(echo "$KDUMP_NETCONFIG" | cut -d ':' -f 2) - - if [ "$interface" = "default" ] ; then - interface=$( kdump_default_netdev ) - status_message "Network interface: $interface (default)" - else - status_message "Network interface: $interface" - fi - - if [ "$mode" = "static" ] ; then - ipcfg="$(kdump_ip_config "$interface")" - hwaddr=$(cat "/sys/class/net/$interface/address") - status_message "Network mode: Static IP" - DRACUT_ARGS+=" --kernel-cmdline 'rd.neednet=1 ip=$ipcfg::$hwaddr'" - else - status_message "Network mode: Automatic IP (DHCP)" - DRACUT_ARGS+=" --kernel-cmdline 'rd.neednet=1 ip=${interface}:dhcp'" - fi - modules="$modules network" - fi - # Make resolved variables visible to the dracut module kdump_export_targets - DRACUT_ARGS="$DRACUT_ARGS --add '$modules' $INITRD $KERNELVERSION" - status_message "Calling dracut $DRACUT_ARGS" + DRACUT_ARGS="$DRACUT_ARGS --add 'kdump' $INITRD $KERNELVERSION" echo "Regenerating kdump initrd ..." >&2 eval "bash -$- dracut $DRACUT_ARGS" } # }}} --- a/init/module-setup.sh +++ b/init/module-setup.sh @@ -3,12 +3,51 @@ . /lib/kdump/setup-kdump.functions +kdump_check_net() { + kdump_neednet= + for protocol in "${kdump_Protocol[@]}" ; do + if [ "$protocol" != "file" ]; then + kdump_neednet=y + fi + done + + # network configuration + if [ -n "$KDUMP_SMTP_SERVER" -a -n "$KDUMP_NOTIFICATION_TO" ]; then + kdump_neednet=y + fi + + # network explicitly disabled in configuration? + [ -z "$KDUMP_NETCONFIG" ] && kdump_neednet= +} + check() { + # Get configuration + kdump_import_targets || return 1 + kdump_get_config || return 1 + kdump_check_net + return 255 } depends() { - echo drm + local -A _modules + + # drm is needed to get console output, but it is not included + # automatically, because kdump does not use plymouth + _modules[drm]= + + [ "$kdump_neednet" = y ] && _modules[network]= + + for protocol in "${kdump_Protocol[@]}" ; do + if [ "$protocol" = "nfs" ]; then + _modules[nfs]= + fi + if [ "$protocol" = "cifs" -o "$protocol" = "smb" ]; then + _modules[cifs]= + fi + done + + echo ${!_modules[@]} } kdump_add_mpath_dev() { @@ -22,10 +61,39 @@ kdump_add_mpath_dev() { fi } +kdump_cmdline_ip() { + [ "$kdump_neednet" = y ] || return 0 + + echo -n "rd.neednet=1" + if [ "$KDUMP_NETCONFIG" = "auto" ] ; then + echo -n " ip=any" + else + set -- ${KDUMP_NETCONFIG//:/ } + local _if=$1 + local _mode=$2 + + if [ "$_if" = "default" ] ; then + _if=$(kdump_default_netdev) + fi + printf " %s" $(kdump_ifname_config "$_if") + + if [ "$_mode" = "static" ] ; then + printf " %s" $(kdump_ip_config "$_if") + else + echo -n " ip=${_if}:dhcp" + fi + fi +} + +cmdline() { + kdump_cmdline_ip +} + install() { - # Get configuration - kdump_get_config || return 1 - kdump_import_targets + if [[ $hostonly_cmdline == "yes" ]] ; then + local _cmdline=$(cmdline) + [ -n "$_cmdline" ] && printf "%s\n" "$_cmdline" >> "${initdir}/etc/cmdline.d/99kdump.conf" + fi # Get a list of required multipath devices local kdump_mpath_wwids --- a/init/setup-kdump.functions +++ b/init/setup-kdump.functions @@ -193,6 +193,20 @@ function kdump_netdev_mode() # { } # }}} # +# Get the ifname parameter for a given device +# +# Parameters: +# 1) device device name +# Output: +# ifname corresponding ifname= initrd parameter (or empty) +function kdump_ifname_config() # {{{ +{ + local iface="$1" + local hwaddr=$(<"/sys/class/net/$iface/address") + [ -n "$hwaddr" ] && echo "ifname=$iface:$hwaddr" +} # }}} + +# # Convert a CIDR prefix to IPv4 netmask # # Parameters: @@ -219,7 +233,7 @@ kdump_prefix2netmask() { # {{{ # Get the ip= parameter for a given device # # Parameters: -# 1) device device name (use default if empty) +# 1) device device name # Output: # ip configuration string that can be used for the ip= initrd parameter function kdump_ip_config() # {{{ @@ -249,7 +263,7 @@ function kdump_ip_config() # {{{ gwaddr=$(ip route show 0/0 | sed -n 's/.* via \([^ ]*\).*/\1/p') hostname=$(hostname) - echo "$ipaddr:$peeraddr:$gwaddr:$netmask:$hostname:$iface:none" + echo "ip=$ipaddr:$peeraddr:$gwaddr:$netmask:$hostname:$iface:none" } # }}} # @@ -311,6 +325,7 @@ function kdump_import_targets() eval "kdump_Host=( $KDUMP_x_Host )" eval "kdump_Realpath=( $KDUMP_x_Realpath )" eval "kdump_mnt=( $KDUMP_x_mnt )" + test ${#kdump_URL[@]} -gt 0 } # }}} #
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor