File kdump-set-serial-console-from-Xen-cmdline.patch of Package kdump.21349
From: Olaf Hering <olaf@aepfle.de>
Date: Tue, 10 Nov 2020 21:39:39 +0100
Subject: set serial console from Xen cmdline
References: bsc#1173914
Upstream: merged
Git-commit: e3b10c632c6f05028454bbf98cf4fc0e180c2b0d
In case Xen has its console to a serial port, construct the matching
Linux console= kernel cmdline option for the kdump kernel.
Allow to skip this logic in case KDUMP_COMMANDLINE_APPEND is set.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
init/load.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
--- a/init/load.sh
+++ b/init/load.sh
@@ -31,6 +31,57 @@ function remove_from_commandline()
}'
}
+# Construct console= parameter for kdump kernel from current Xen cmdline
+function set_serial_console()
+{
+ local com1 com2 unhandled opt
+ local maybe_console
+ local kdump_console
+
+ test -f /proc/xen/capabilities || return
+ grep -wq 'control_d' /proc/xen/capabilities || return
+ test -x "$(type -P xl)" || return
+
+ read xen_commandline < <(xl info | awk -F ':' '/^xen_commandline/{print $2}')
+ test -n "${xen_commandline}" || return
+
+ for opt in ${xen_commandline}
+ do
+ unhandled=
+ case "${opt}" in
+ console=com1) maybe_console='ttyS0' ;;
+ console=com2) maybe_console='ttyS1' ;;
+ com1=*,*) unhandled=1 ; com1= ;;
+ com1=*) com1="${opt#*=}" ;;
+ com2=*,*) unhandled=1 ; com2=;;
+ com2=*) com2="${opt#*=}" ;;
+ console=*com*) unhandled=1 ; maybe_console= ;;
+ *) ;;
+ esac
+ test -n "${unhandled}" && echo >&2 "${opt} in Xen commandline not handled"
+ done
+
+ test -n "${maybe_console}" || return
+
+ case "${maybe_console}" in
+ ttyS0)
+ test -n "${com1}" && kdump_console="console=${maybe_console},${com1}"
+ ;;
+ ttyS1)
+ test -n "${com2}" && kdump_console="console=${maybe_console},${com2}"
+ ;;
+ esac
+
+ test -n "${kdump_console}" || return
+
+ if test -n "${KDUMP_COMMANDLINE_APPEND}"
+ then
+ echo >&2 "KDUMP_COMMANDLINE_APPEND is set, assuming it already contains '${kdump_console}'"
+ return
+ fi
+
+ echo "${kdump_console}"
+}
#
# Get the name of kernel parameter to limit CPUs
# Linux 2.6.34+ has nr_cpus, older versions must use maxcpus
@@ -98,6 +149,7 @@ function build_kdump_commandline()
fi
fi
+ commandline="$commandline $(set_serial_console)"
commandline="$commandline $KDUMP_COMMANDLINE_APPEND"
# Add panic=1 unless there is a panic option already