Previously, the range of log level is from 1 to 6, and the TRACE level and FATAL level are not used, therefore, let's remove these unused log levels and update the kdump sysconfig accordingly.
Nowadays it has only four log levels: error(1), warn(2), info(3) and debug(4). We have to remap the numeric log level to the logger priority or syslog log level, which is finished in kdump-logger.sh module, it is invisible for user.
In addition, kdump uses the different options to control the log levels for the first kernel and the second kernel.
Signed-off-by: Lianbo Jiang lijiang@redhat.com --- dracut-module-setup.sh | 5 +- kdump-lib-initramfs.sh | 1 - kdump-logger.sh | 206 +++++++++++++++++----------------------- kdump.sysconfig | 21 ++-- kdump.sysconfig.aarch64 | 21 ++-- kdump.sysconfig.i386 | 21 ++-- kdump.sysconfig.ppc64 | 21 ++-- kdump.sysconfig.ppc64le | 21 ++-- kdump.sysconfig.s390x | 21 ++-- kdump.sysconfig.x86_64 | 21 ++-- 10 files changed, 157 insertions(+), 202 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 911a8b84de9d..e8d7c46cc407 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -33,7 +33,7 @@ depends() { if is_squash_available && ! is_fadump_capable; then _dep="$_dep squash" else - dwarning "Required modules to build a squashed kdump image is missing!" + dwarn "Required modules to build a squashed kdump image is missing!" fi
if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then @@ -72,7 +72,7 @@ source_ifcfg_file() { if [ -f "${ifcfg_file}" ]; then . ${ifcfg_file} else - dwarning "The ifcfg file of $1 is not found!" + dwarn "The ifcfg file of $1 is not found!" fi }
@@ -819,7 +819,6 @@ install() { kdump_install_random_seed fi dracut_install -o /etc/adjtime /etc/localtime - inst_simple "/etc/sysconfig/kdump" inst "$moddir/monitor_dd_progress" "/kdumpscripts/monitor_dd_progress" chmod +x ${initdir}/kdumpscripts/monitor_dd_progress inst "/bin/dd" "/bin/dd" diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 14aac7b98d44..d8d48935b32e 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -1,6 +1,5 @@ # These variables and functions are useful in 2nd kernel
-. /etc/sysconfig/kdump . /lib/kdump-lib.sh
KDUMP_PATH="/var/crash" diff --git a/kdump-logger.sh b/kdump-logger.sh index a3d674cd07c2..fedcc4b6d3c6 100755 --- a/kdump-logger.sh +++ b/kdump-logger.sh @@ -2,39 +2,58 @@ # # This comes from the dracut-logger.sh # -# The logger defined 6 logging levels: -# - dtrace() (6) -# The TRACE Level designates finer-grained informational events than the -# DEBUG. -# - ddebug (5) +# The logger defined 4 logging levels: +# - ddebug (4) # The DEBUG Level designates fine-grained informational events that are most # useful to debug an application. -# - dinfo (4) +# - dinfo (3) # The INFO level designates informational messages that highlight the # progress of the application at coarse-grained level. -# - dwarn (3) +# - dwarn (2) # The WARN level designates potentially harmful situations. -# - derror (2) +# - derror (1) # The ERROR level designates error events that might still allow the # application to continue running. -# - dfatal (1) -# The FATAL level designates very severe error events that will presumably -# lead the application to abort. # # Logging is controlled by following global variables: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) # -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl = 4 (info) -# - @var kdump_sysloglvl = 4 (info) -# - @var kdump_kmsgloglvl = 0 (no logging) +# If any of the variables is not set, the function dlog_init() sets it to default: +# - In the first kernel: +# - @var kdump_stdloglvl = 3 (info) +# - @var kdump_sysloglvl = 3 (info) +# - @var kdump_kmsgloglvl = 0 (no logging) +# +# -In the second kernel: +# - @var kdump_stdloglvl = 0 (no logging) +# - @var kdump_sysloglvl = 3 (info) +# - @var kdump_kmsgloglvl = 0 (no logging) # # First of all you have to start with dlog_init() function which initializes # required variables. Don't call any other logging function before that one! #
+if [ -f /lib/dracut-lib.sh ]; then + . /lib/dracut-lib.sh +fi + +# @brief Get the log level from kernel command line. +# @retval 1 if something has gone wrong +# @retval 0 on success. +# +get_kdump_loglvl() +{ + (type -p getarg) && kdump_sysloglvl=$(getarg rd.kdumploglvl) + [ -z "$kdump_sysloglvl" ] && return 1; + + (type -p isdigit) && isdigit $kdump_sysloglvl + [ $? -ne 0 ] && return 1; + + return 0 +} + # @brief Check the log level. # @retval 1 if something has gone wrong # @retval 0 on success. @@ -42,7 +61,7 @@ check_loglvl() { case "$1" in - 0|1|2|3|4|5|6) + 0|1|2|3|4) return 0 ;; *) @@ -58,8 +77,19 @@ check_loglvl() dlog_init() { local ret=0; local errmsg
- [ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=4 - [ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=4 + if [ -s /proc/vmcore ];then + get_kdump_loglvl + if [ $? -ne 0 ];then + logger -t "kdump[$$]" -p error -- "Fail to set rd.kdumploglvl option in kernel command line." + logger -t "kdump[$$]" -p warn -- "Kdump is using the default log level(3)." + kdump_sysloglvl=3 + fi + kdump_stdloglvl=0 + kdump_kmsgloglvl=0 + fi + + [ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=3 + [ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=3 [ -z "$kdump_kmsgloglvl" ] && kdump_kmsgloglvl=0
for loglvl in $kdump_stdloglvl $kdump_kmsgloglvl $kdump_sysloglvl; do @@ -103,83 +133,50 @@ dlog_init() { readonly kdump_maxloglvl=$maxloglvl_l export kdump_maxloglvl
- - if [[ $kdump_stdloglvl -lt 6 ]] && [[ $kdump_kmsgloglvl -lt 6 ]] && [[ $kdump_sysloglvl -lt 6 ]]; then - unset dtrace - dtrace() { :; }; - fi - - if [[ $kdump_stdloglvl -lt 5 ]] && [[ $kdump_kmsgloglvl -lt 5 ]] && [[ $kdump_sysloglvl -lt 5 ]]; then + if [[ $kdump_stdloglvl -lt 4 ]] && [[ $kdump_kmsgloglvl -lt 4 ]] && [[ $kdump_sysloglvl -lt 4 ]]; then unset ddebug ddebug() { :; }; fi
- if [[ $kdump_stdloglvl -lt 4 ]] && [[ $kdump_kmsgloglvl -lt 4 ]] && [[ $kdump_sysloglvl -lt 4 ]]; then + if [[ $kdump_stdloglvl -lt 3 ]] && [[ $kdump_kmsgloglvl -lt 3 ]] && [[ $kdump_sysloglvl -lt 3 ]]; then unset dinfo dinfo() { :; }; fi
- if [[ $kdump_stdloglvl -lt 3 ]] && [[ $kdump_kmsgloglvl -lt 3 ]] && [[ $kdump_sysloglvl -lt 3 ]]; then + if [[ $kdump_stdloglvl -lt 2 ]] && [[ $kdump_kmsgloglvl -lt 2 ]] && [[ $kdump_sysloglvl -lt 2 ]]; then unset dwarn dwarn() { :; }; - unset dwarning - dwarning() { :; }; fi
- if [[ $kdump_stdloglvl -lt 2 ]] && [[ $kdump_kmsgloglvl -lt 2 ]] && [[ $kdump_sysloglvl -lt 2 ]]; then + if [[ $kdump_stdloglvl -lt 1 ]] && [[ $kdump_kmsgloglvl -lt 1 ]] && [[ $kdump_sysloglvl -lt 1 ]]; then unset derror derror() { :; }; fi
- if [[ $kdump_stdloglvl -lt 1 ]] && [[ $kdump_kmsgloglvl -lt 1 ]] && [[ $kdump_sysloglvl -lt 1 ]]; then - unset dfatal - dfatal() { :; }; - fi - [ -n "$errmsg" ] && derror "$errmsg"
return $ret }
-## @brief Converts numeric logging level to the first letter of level name. -# -# @param lvl Numeric logging level in range from 1 to 6. -# @retval 1 if @a lvl is out of range. -# @retval 0 if @a lvl is correct. -# @result Echoes first letter of level name. -_lvl2char() { - case "$1" in - 1) echo F;; - 2) echo E;; - 3) echo W;; - 4) echo I;; - 5) echo D;; - 6) echo T;; - *) return 1;; - esac -} - ## @brief Converts numeric level to logger priority defined by POSIX.2. # -# @param lvl Numeric logging level in range from 1 to 6. +# @param lvl Numeric logging level in range from 1 to 4. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes logger priority. _lvl2syspri() { case "$1" in - 1) echo crit;; - 2) echo error;; - 3) echo warning;; - 4) echo info;; - 5) echo debug;; - 6) echo debug;; + 1) echo error;; + 2) echo warning;; + 3) echo info;; + 4) echo debug;; *) return 1;; esac }
## @brief Converts logger numeric level to syslog log level # -# @param lvl Numeric logging level in range from 1 to 6. +# @param lvl Numeric logging level in range from 1 to 4. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes kernel console numeric log level @@ -189,13 +186,12 @@ _lvl2syspri() { # <tt> # none -> LOG_EMERG (0) # none -> LOG_ALERT (1) -# FATAL(1) -> LOG_CRIT (2) -# ERROR(2) -> LOG_ERR (3) -# WARN(3) -> LOG_WARNING (4) +# none -> LOG_CRIT (2) +# ERROR(1) -> LOG_ERR (3) +# WARN(2) -> LOG_WARNING (4) # none -> LOG_NOTICE (5) -# INFO(4) -> LOG_INFO (6) -# DEBUG(5) -> LOG_DEBUG (7) -# TRACE(6) / +# INFO(3) -> LOG_INFO (6) +# DEBUG(4) -> LOG_DEBUG (7) # </tt> # # @see /usr/include/sys/syslog.h @@ -203,30 +199,31 @@ _dlvl2syslvl() { local lvl
case "$1" in - 1) lvl=2;; - 2) lvl=3;; - 3) lvl=4;; - 4) lvl=6;; - 5) lvl=7;; - 6) lvl=7;; + 1) lvl=3;; + 2) lvl=4;; + 3) lvl=6;; + 4) lvl=7;; *) return 1;; esac
- [ -s /proc/vmcore ] && echo $((24+$lvl)) || echo $((8+$lvl)) + # The number is constructed by multiplying the facility by 8 and then + # adding the level. + # About The Syslog Protocol, please refer to the RFC5424 for more details. + echo $((24+$lvl)) }
-## @brief Prints to stderr and/or writes to file, to syslog and/or /dev/kmsg -# given message with given level (priority). +## @brief Prints to stderr, to syslog and/or /dev/kmsg given message with +# given level (priority). # # @param lvl Numeric logging level. # @param msg Message. # @retval 0 It's always returned, even if logging failed. # # @note This function is not supposed to be called manually. Please use -# dtrace(), ddebug(), or others instead which wrap this one. +# dinfo(), ddebug(), or others instead which wrap this one. # -# This is core logging function which logs given message to standard error, file -# and/or syslog (with POSIX shell command <tt>logger</tt>) and/or to /dev/kmsg. +# This is core logging function which logs given message to standard error +# and syslog (with POSIX shell command <tt>logger</tt>) and/or to /dev/kmsg. # The format is following: # # <tt>X: some message</tt> @@ -236,16 +233,13 @@ _dlvl2syslvl() { # # Message to syslog is sent with tag @c kdump. Priorities are mapped as # following: -# - @c FATAL to @c crit # - @c ERROR to @c error # - @c WARN to @c warning # - @c INFO to @c info -# - @c DEBUG and @c TRACE both to @c debug +# - @c DEBUG to @c debug _do_dlog() { local lvl="$1"; shift - local lvlc=$(_lvl2char "$lvl") || return 0 local msg="$*" - local lmsg="$lvlc: $*"
[[ $lvl -le $kdump_stdloglvl ]] && printf -- 'kdump: %s\n' "$msg" >&2
@@ -268,7 +262,7 @@ _do_dlog() { # @retval 0 It's always returned, even if logging failed. # # @note This function is not supposed to be called manually. Please use -# dtrace(), ddebug(), or others instead which wrap this one. +# dinfo(), ddebug(), or others instead which wrap this one. # # This function calls _do_dlog() either with parameter msg, or if # none is given, it will read standard input and will use every line as @@ -290,71 +284,41 @@ dlog() { fi }
-## @brief Logs message at TRACE level (6) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -dtrace() { - set +x - dlog 6 "$@" - [ -n "$debug" ] && set -x || : -} - -## @brief Logs message at DEBUG level (5) +## @brief Logs message at DEBUG level (4) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. ddebug() { - set +x - dlog 5 "$@" - [ -n "$debug" ] && set -x || : -} - -## @brief Logs message at INFO level (4) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -dinfo() { set +x dlog 4 "$@" [ -n "$debug" ] && set -x || : }
-## @brief Logs message at WARN level (3) +## @brief Logs message at INFO level (3) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. -dwarn() { +dinfo() { set +x dlog 3 "$@" [ -n "$debug" ] && set -x || : }
-## @brief It's an alias to dwarn() function. +## @brief Logs message at WARN level (2) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. -dwarning() { - set +x - dwarn "$@" - [ -n "$debug" ] && set -x || : -} - -## @brief Logs message at ERROR level (2) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -derror() { +dwarn() { set +x dlog 2 "$@" [ -n "$debug" ] && set -x || : }
-## @brief Logs message at FATAL level (1) +## @brief Logs message at ERROR level (1) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. -dfatal() { +derror() { set +x dlog 1 "$@" [ -n "$debug" ] && set -x || : diff --git a/kdump.sysconfig b/kdump.sysconfig index 52a0b9249fe7..d6b54ef489c0 100644 --- a/kdump.sysconfig +++ b/kdump.sysconfig @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -36,18 +36,17 @@ KEXEC_ARGS="" #What is the image type used for kdump KDUMP_IMG="vmlinuz"
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 index 1d75979df03e..f869e0e7e93d 100644 --- a/kdump.sysconfig.aarch64 +++ b/kdump.sysconfig.aarch64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -36,18 +36,17 @@ KEXEC_ARGS="" #What is the image type used for kdump KDUMP_IMG="vmlinuz"
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386 index 2eb9705e32e9..da37cd90d8a0 100644 --- a/kdump.sysconfig.i386 +++ b/kdump.sysconfig.i386 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -39,18 +39,17 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT=""
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 index 24279ff34211..2c91dcd56461 100644 --- a/kdump.sysconfig.ppc64 +++ b/kdump.sysconfig.ppc64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -41,18 +41,17 @@ KDUMP_IMG_EXT=""
#Specify the action after failure
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index 24279ff34211..2c91dcd56461 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -41,18 +41,17 @@ KDUMP_IMG_EXT=""
#Specify the action after failure
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 5e1cb5a7ad89..add43dbc8c34 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd rd.kdumploglvl=3"
# Any additional /sbin/mkdumprd arguments required. MKDUMPRD_ARGS="" @@ -42,18 +42,17 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT=""
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index eb1c53824241..fb0da9f33cb7 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -39,18 +39,17 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT=""
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0
On Mon, Nov 9, 2020 at 7:10 PM Lianbo Jiang lijiang@redhat.com wrote:
Previously, the range of log level is from 1 to 6, and the TRACE level and FATAL level are not used, therefore, let's remove these unused log levels and update the kdump sysconfig accordingly.
Nowadays it has only four log levels: error(1), warn(2), info(3) and debug(4). We have to remap the numeric log level to the logger priority or syslog log level, which is finished in kdump-logger.sh module, it is invisible for user.
In addition, kdump uses the different options to control the log levels for the first kernel and the second kernel.
Signed-off-by: Lianbo Jiang lijiang@redhat.com
dracut-module-setup.sh | 5 +- kdump-lib-initramfs.sh | 1 - kdump-logger.sh | 206 +++++++++++++++++----------------------- kdump.sysconfig | 21 ++-- kdump.sysconfig.aarch64 | 21 ++-- kdump.sysconfig.i386 | 21 ++-- kdump.sysconfig.ppc64 | 21 ++-- kdump.sysconfig.ppc64le | 21 ++-- kdump.sysconfig.s390x | 21 ++-- kdump.sysconfig.x86_64 | 21 ++-- 10 files changed, 157 insertions(+), 202 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 911a8b84de9d..e8d7c46cc407 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -33,7 +33,7 @@ depends() { if is_squash_available && ! is_fadump_capable; then _dep="$_dep squash" else
dwarning "Required modules to build a squashed kdump image is missing!"
dwarn "Required modules to build a squashed kdump image is missing!"
fi
if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then
@@ -72,7 +72,7 @@ source_ifcfg_file() { if [ -f "${ifcfg_file}" ]; then . ${ifcfg_file} else
dwarning "The ifcfg file of $1 is not found!"
fidwarn "The ifcfg file of $1 is not found!"
}
@@ -819,7 +819,6 @@ install() { kdump_install_random_seed fi dracut_install -o /etc/adjtime /etc/localtime
- inst_simple "/etc/sysconfig/kdump" inst "$moddir/monitor_dd_progress" "/kdumpscripts/monitor_dd_progress" chmod +x ${initdir}/kdumpscripts/monitor_dd_progress inst "/bin/dd" "/bin/dd"
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 14aac7b98d44..d8d48935b32e 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -1,6 +1,5 @@ # These variables and functions are useful in 2nd kernel
-. /etc/sysconfig/kdump . /lib/kdump-lib.sh
KDUMP_PATH="/var/crash" diff --git a/kdump-logger.sh b/kdump-logger.sh index a3d674cd07c2..fedcc4b6d3c6 100755 --- a/kdump-logger.sh +++ b/kdump-logger.sh @@ -2,39 +2,58 @@ # # This comes from the dracut-logger.sh # -# The logger defined 6 logging levels: -# - dtrace() (6) -# The TRACE Level designates finer-grained informational events than the -# DEBUG. -# - ddebug (5) +# The logger defined 4 logging levels: +# - ddebug (4) # The DEBUG Level designates fine-grained informational events that are most # useful to debug an application. -# - dinfo (4) +# - dinfo (3) # The INFO level designates informational messages that highlight the # progress of the application at coarse-grained level. -# - dwarn (3) +# - dwarn (2) # The WARN level designates potentially harmful situations. -# - derror (2) +# - derror (1) # The ERROR level designates error events that might still allow the # application to continue running. -# - dfatal (1) -# The FATAL level designates very severe error events that will presumably -# lead the application to abort. # # Logging is controlled by following global variables: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) # -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl = 4 (info) -# - @var kdump_sysloglvl = 4 (info) -# - @var kdump_kmsgloglvl = 0 (no logging) +# If any of the variables is not set, the function dlog_init() sets it to default: +# - In the first kernel: +# - @var kdump_stdloglvl = 3 (info) +# - @var kdump_sysloglvl = 3 (info) +# - @var kdump_kmsgloglvl = 0 (no logging) +# +# -In the second kernel: +# - @var kdump_stdloglvl = 0 (no logging) +# - @var kdump_sysloglvl = 3 (info) +# - @var kdump_kmsgloglvl = 0 (no logging) # # First of all you have to start with dlog_init() function which initializes # required variables. Don't call any other logging function before that one! #
+if [ -f /lib/dracut-lib.sh ]; then
- . /lib/dracut-lib.sh
+fi
Hi, Lianbo
I think it's better to add a comment here that this dracut-lib.sh is only available when in kdump kernel, so the behaviour of this script will differ between first / kdump kernel.
+# @brief Get the log level from kernel command line. +# @retval 1 if something has gone wrong +# @retval 0 on success. +# +get_kdump_loglvl() +{
- (type -p getarg) && kdump_sysloglvl=$(getarg rd.kdumploglvl)
- [ -z "$kdump_sysloglvl" ] && return 1;
- (type -p isdigit) && isdigit $kdump_sysloglvl
- [ $? -ne 0 ] && return 1;
- return 0
+}
# @brief Check the log level. # @retval 1 if something has gone wrong # @retval 0 on success. @@ -42,7 +61,7 @@ check_loglvl() { case "$1" in
0|1|2|3|4|5|6)
0|1|2|3|4) return 0 ;; *)
@@ -58,8 +77,19 @@ check_loglvl() dlog_init() { local ret=0; local errmsg
- [ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=4
- [ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=4
if [ -s /proc/vmcore ];then
get_kdump_loglvl
if [ $? -ne 0 ];then
logger -t "kdump[$$]" -p error -- "Fail to set rd.kdumploglvl option in kernel command line."
logger -t "kdump[$$]" -p warn -- "Kdump is using the default log level(3)."
kdump_sysloglvl=3
fi
kdump_stdloglvl=0
kdump_kmsgloglvl=0
fi
[ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=3
[ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=3 [ -z "$kdump_kmsgloglvl" ] && kdump_kmsgloglvl=0
for loglvl in $kdump_stdloglvl $kdump_kmsgloglvl $kdump_sysloglvl; do
@@ -103,83 +133,50 @@ dlog_init() { readonly kdump_maxloglvl=$maxloglvl_l export kdump_maxloglvl
- if [[ $kdump_stdloglvl -lt 6 ]] && [[ $kdump_kmsgloglvl -lt 6 ]] && [[ $kdump_sysloglvl -lt 6 ]]; then
unset dtrace
dtrace() { :; };
- fi
- if [[ $kdump_stdloglvl -lt 5 ]] && [[ $kdump_kmsgloglvl -lt 5 ]] && [[ $kdump_sysloglvl -lt 5 ]]; then
- if [[ $kdump_stdloglvl -lt 4 ]] && [[ $kdump_kmsgloglvl -lt 4 ]] && [[ $kdump_sysloglvl -lt 4 ]]; then unset ddebug ddebug() { :; }; fi
- if [[ $kdump_stdloglvl -lt 4 ]] && [[ $kdump_kmsgloglvl -lt 4 ]] && [[ $kdump_sysloglvl -lt 4 ]]; then
- if [[ $kdump_stdloglvl -lt 3 ]] && [[ $kdump_kmsgloglvl -lt 3 ]] && [[ $kdump_sysloglvl -lt 3 ]]; then unset dinfo dinfo() { :; }; fi
- if [[ $kdump_stdloglvl -lt 3 ]] && [[ $kdump_kmsgloglvl -lt 3 ]] && [[ $kdump_sysloglvl -lt 3 ]]; then
- if [[ $kdump_stdloglvl -lt 2 ]] && [[ $kdump_kmsgloglvl -lt 2 ]] && [[ $kdump_sysloglvl -lt 2 ]]; then unset dwarn dwarn() { :; };
unset dwarning
dwarning() { :; };
fi
if [[ $kdump_stdloglvl -lt 2 ]] && [[ $kdump_kmsgloglvl -lt 2 ]] && [[ $kdump_sysloglvl -lt 2 ]]; then
- if [[ $kdump_stdloglvl -lt 1 ]] && [[ $kdump_kmsgloglvl -lt 1 ]] && [[ $kdump_sysloglvl -lt 1 ]]; then unset derror derror() { :; }; fi
if [[ $kdump_stdloglvl -lt 1 ]] && [[ $kdump_kmsgloglvl -lt 1 ]] && [[ $kdump_sysloglvl -lt 1 ]]; then
unset dfatal
dfatal() { :; };
fi
[ -n "$errmsg" ] && derror "$errmsg"
return $ret
}
-## @brief Converts numeric logging level to the first letter of level name. -# -# @param lvl Numeric logging level in range from 1 to 6. -# @retval 1 if @a lvl is out of range. -# @retval 0 if @a lvl is correct. -# @result Echoes first letter of level name. -_lvl2char() {
- case "$1" in
1) echo F;;
2) echo E;;
3) echo W;;
4) echo I;;
5) echo D;;
6) echo T;;
*) return 1;;
- esac
-}
## @brief Converts numeric level to logger priority defined by POSIX.2. # -# @param lvl Numeric logging level in range from 1 to 6. +# @param lvl Numeric logging level in range from 1 to 4. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes logger priority. _lvl2syspri() { case "$1" in
1) echo crit;;
2) echo error;;
3) echo warning;;
4) echo info;;
5) echo debug;;
6) echo debug;;
1) echo error;;
2) echo warning;;
3) echo info;;
esac4) echo debug;; *) return 1;;
}
## @brief Converts logger numeric level to syslog log level # -# @param lvl Numeric logging level in range from 1 to 6. +# @param lvl Numeric logging level in range from 1 to 4. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes kernel console numeric log level @@ -189,13 +186,12 @@ _lvl2syspri() { # <tt> # none -> LOG_EMERG (0) # none -> LOG_ALERT (1) -# FATAL(1) -> LOG_CRIT (2) -# ERROR(2) -> LOG_ERR (3) -# WARN(3) -> LOG_WARNING (4) +# none -> LOG_CRIT (2) +# ERROR(1) -> LOG_ERR (3) +# WARN(2) -> LOG_WARNING (4) # none -> LOG_NOTICE (5) -# INFO(4) -> LOG_INFO (6) -# DEBUG(5) -> LOG_DEBUG (7) -# TRACE(6) / +# INFO(3) -> LOG_INFO (6) +# DEBUG(4) -> LOG_DEBUG (7) # </tt> # # @see /usr/include/sys/syslog.h @@ -203,30 +199,31 @@ _dlvl2syslvl() { local lvl
case "$1" in
1) lvl=2;;
2) lvl=3;;
3) lvl=4;;
4) lvl=6;;
5) lvl=7;;
6) lvl=7;;
1) lvl=3;;
2) lvl=4;;
3) lvl=6;;
esac4) lvl=7;; *) return 1;;
- [ -s /proc/vmcore ] && echo $((24+$lvl)) || echo $((8+$lvl))
- # The number is constructed by multiplying the facility by 8 and then
- # adding the level.
- # About The Syslog Protocol, please refer to the RFC5424 for more details.
- echo $((24+$lvl))
}
-## @brief Prints to stderr and/or writes to file, to syslog and/or /dev/kmsg -# given message with given level (priority). +## @brief Prints to stderr, to syslog and/or /dev/kmsg given message with +# given level (priority). # # @param lvl Numeric logging level. # @param msg Message. # @retval 0 It's always returned, even if logging failed. # # @note This function is not supposed to be called manually. Please use -# dtrace(), ddebug(), or others instead which wrap this one. +# dinfo(), ddebug(), or others instead which wrap this one. # -# This is core logging function which logs given message to standard error, file -# and/or syslog (with POSIX shell command <tt>logger</tt>) and/or to /dev/kmsg. +# This is core logging function which logs given message to standard error +# and syslog (with POSIX shell command <tt>logger</tt>) and/or to /dev/kmsg. # The format is following: # # <tt>X: some message</tt> @@ -236,16 +233,13 @@ _dlvl2syslvl() { # # Message to syslog is sent with tag @c kdump. Priorities are mapped as # following: -# - @c FATAL to @c crit # - @c ERROR to @c error # - @c WARN to @c warning # - @c INFO to @c info -# - @c DEBUG and @c TRACE both to @c debug +# - @c DEBUG to @c debug _do_dlog() { local lvl="$1"; shift
local lvlc=$(_lvl2char "$lvl") || return 0 local msg="$*"
local lmsg="$lvlc: $*"
[[ $lvl -le $kdump_stdloglvl ]] && printf -- 'kdump: %s\n' "$msg" >&2
@@ -268,7 +262,7 @@ _do_dlog() { # @retval 0 It's always returned, even if logging failed. # # @note This function is not supposed to be called manually. Please use -# dtrace(), ddebug(), or others instead which wrap this one. +# dinfo(), ddebug(), or others instead which wrap this one. # # This function calls _do_dlog() either with parameter msg, or if # none is given, it will read standard input and will use every line as @@ -290,71 +284,41 @@ dlog() { fi }
-## @brief Logs message at TRACE level (6) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -dtrace() {
- set +x
- dlog 6 "$@"
- [ -n "$debug" ] && set -x || :
-}
-## @brief Logs message at DEBUG level (5) +## @brief Logs message at DEBUG level (4) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. ddebug() {
- set +x
- dlog 5 "$@"
- [ -n "$debug" ] && set -x || :
-}
-## @brief Logs message at INFO level (4) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -dinfo() { set +x dlog 4 "$@" [ -n "$debug" ] && set -x || : }
-## @brief Logs message at WARN level (3) +## @brief Logs message at INFO level (3) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. -dwarn() { +dinfo() { set +x dlog 3 "$@" [ -n "$debug" ] && set -x || : }
-## @brief It's an alias to dwarn() function. +## @brief Logs message at WARN level (2) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. -dwarning() {
- set +x
- dwarn "$@"
- [ -n "$debug" ] && set -x || :
-}
-## @brief Logs message at ERROR level (2) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -derror() { +dwarn() { set +x dlog 2 "$@" [ -n "$debug" ] && set -x || : }
-## @brief Logs message at FATAL level (1) +## @brief Logs message at ERROR level (1) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. -dfatal() { +derror() { set +x dlog 1 "$@" [ -n "$debug" ] && set -x || : diff --git a/kdump.sysconfig b/kdump.sysconfig index 52a0b9249fe7..d6b54ef489c0 100644 --- a/kdump.sysconfig +++ b/kdump.sysconfig @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -36,18 +36,17 @@ KEXEC_ARGS="" #What is the image type used for kdump KDUMP_IMG="vmlinuz"
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 index 1d75979df03e..f869e0e7e93d 100644 --- a/kdump.sysconfig.aarch64 +++ b/kdump.sysconfig.aarch64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -36,18 +36,17 @@ KEXEC_ARGS="" #What is the image type used for kdump KDUMP_IMG="vmlinuz"
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386 index 2eb9705e32e9..da37cd90d8a0 100644 --- a/kdump.sysconfig.i386 +++ b/kdump.sysconfig.i386 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -39,18 +39,17 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT=""
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 index 24279ff34211..2c91dcd56461 100644 --- a/kdump.sysconfig.ppc64 +++ b/kdump.sysconfig.ppc64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -41,18 +41,17 @@ KDUMP_IMG_EXT=""
#Specify the action after failure
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index 24279ff34211..2c91dcd56461 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -41,18 +41,17 @@ KDUMP_IMG_EXT=""
#Specify the action after failure
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 5e1cb5a7ad89..add43dbc8c34 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd rd.kdumploglvl=3"
# Any additional /sbin/mkdumprd arguments required. MKDUMPRD_ARGS="" @@ -42,18 +42,17 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT=""
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index eb1c53824241..fb0da9f33cb7 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -39,18 +39,17 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT=""
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3
+kdump_kmsgloglvl=0
2.17.1
Thanks for the patch,
This patch's idea looks good to me, but maybe it's better to split iinto two, one to remove the extra log level, one for updating the set of the kdumploglvl, so other people can revietw this easier.
And is this patch based on the latest master branch? git am reports a log of conflicts, maybe need a rebase?
-- Best Regards, Kairui Song
Hi, Kairui
Thank you for the comment.
在 2020年11月10日 08:00, Kairui Song 写道:
On Mon, Nov 9, 2020 at 7:10 PM Lianbo Jiang lijiang@redhat.com wrote:
Previously, the range of log level is from 1 to 6, and the TRACE level and FATAL level are not used, therefore, let's remove these unused log levels and update the kdump sysconfig accordingly.
Nowadays it has only four log levels: error(1), warn(2), info(3) and debug(4). We have to remap the numeric log level to the logger priority or syslog log level, which is finished in kdump-logger.sh module, it is invisible for user.
In addition, kdump uses the different options to control the log levels for the first kernel and the second kernel.
Signed-off-by: Lianbo Jiang lijiang@redhat.com
dracut-module-setup.sh | 5 +- kdump-lib-initramfs.sh | 1 - kdump-logger.sh | 206 +++++++++++++++++----------------------- kdump.sysconfig | 21 ++-- kdump.sysconfig.aarch64 | 21 ++-- kdump.sysconfig.i386 | 21 ++-- kdump.sysconfig.ppc64 | 21 ++-- kdump.sysconfig.ppc64le | 21 ++-- kdump.sysconfig.s390x | 21 ++-- kdump.sysconfig.x86_64 | 21 ++-- 10 files changed, 157 insertions(+), 202 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 911a8b84de9d..e8d7c46cc407 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -33,7 +33,7 @@ depends() { if is_squash_available && ! is_fadump_capable; then _dep="$_dep squash" else
dwarning "Required modules to build a squashed kdump image is missing!"
dwarn "Required modules to build a squashed kdump image is missing!"
fi
if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then
@@ -72,7 +72,7 @@ source_ifcfg_file() { if [ -f "${ifcfg_file}" ]; then . ${ifcfg_file} else
dwarning "The ifcfg file of $1 is not found!"
fidwarn "The ifcfg file of $1 is not found!"
}
@@ -819,7 +819,6 @@ install() { kdump_install_random_seed fi dracut_install -o /etc/adjtime /etc/localtime
- inst_simple "/etc/sysconfig/kdump" inst "$moddir/monitor_dd_progress" "/kdumpscripts/monitor_dd_progress" chmod +x ${initdir}/kdumpscripts/monitor_dd_progress inst "/bin/dd" "/bin/dd"
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 14aac7b98d44..d8d48935b32e 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -1,6 +1,5 @@ # These variables and functions are useful in 2nd kernel
-. /etc/sysconfig/kdump . /lib/kdump-lib.sh
KDUMP_PATH="/var/crash" diff --git a/kdump-logger.sh b/kdump-logger.sh index a3d674cd07c2..fedcc4b6d3c6 100755 --- a/kdump-logger.sh +++ b/kdump-logger.sh @@ -2,39 +2,58 @@ # # This comes from the dracut-logger.sh # -# The logger defined 6 logging levels: -# - dtrace() (6) -# The TRACE Level designates finer-grained informational events than the -# DEBUG. -# - ddebug (5) +# The logger defined 4 logging levels: +# - ddebug (4) # The DEBUG Level designates fine-grained informational events that are most # useful to debug an application. -# - dinfo (4) +# - dinfo (3) # The INFO level designates informational messages that highlight the # progress of the application at coarse-grained level. -# - dwarn (3) +# - dwarn (2) # The WARN level designates potentially harmful situations. -# - derror (2) +# - derror (1) # The ERROR level designates error events that might still allow the # application to continue running. -# - dfatal (1) -# The FATAL level designates very severe error events that will presumably -# lead the application to abort. # # Logging is controlled by following global variables: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) # -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl = 4 (info) -# - @var kdump_sysloglvl = 4 (info) -# - @var kdump_kmsgloglvl = 0 (no logging) +# If any of the variables is not set, the function dlog_init() sets it to default: +# - In the first kernel: +# - @var kdump_stdloglvl = 3 (info) +# - @var kdump_sysloglvl = 3 (info) +# - @var kdump_kmsgloglvl = 0 (no logging) +# +# -In the second kernel: +# - @var kdump_stdloglvl = 0 (no logging) +# - @var kdump_sysloglvl = 3 (info) +# - @var kdump_kmsgloglvl = 0 (no logging) # # First of all you have to start with dlog_init() function which initializes # required variables. Don't call any other logging function before that one! #
+if [ -f /lib/dracut-lib.sh ]; then
- . /lib/dracut-lib.sh
+fi
Hi, Lianbo
I think it's better to add a comment here that this dracut-lib.sh is only available when in kdump kernel, so the behaviour of this script will differ between first / kdump kernel.
The dracut-lib.sh is only available in the second kernel, and it won't be used in the first kernel because the dracut-lib.sh is invisible in the first kernel.
Do you mean that I need to add the above explanation in the code comment?
+# @brief Get the log level from kernel command line. +# @retval 1 if something has gone wrong +# @retval 0 on success. +# +get_kdump_loglvl() +{
- (type -p getarg) && kdump_sysloglvl=$(getarg rd.kdumploglvl)
- [ -z "$kdump_sysloglvl" ] && return 1;
- (type -p isdigit) && isdigit $kdump_sysloglvl
- [ $? -ne 0 ] && return 1;
- return 0
+}
# @brief Check the log level. # @retval 1 if something has gone wrong # @retval 0 on success. @@ -42,7 +61,7 @@ check_loglvl() { case "$1" in
0|1|2|3|4|5|6)
0|1|2|3|4) return 0 ;; *)
@@ -58,8 +77,19 @@ check_loglvl() dlog_init() { local ret=0; local errmsg
- [ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=4
- [ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=4
if [ -s /proc/vmcore ];then
get_kdump_loglvl
if [ $? -ne 0 ];then
logger -t "kdump[$$]" -p error -- "Fail to set rd.kdumploglvl option in kernel command line."
logger -t "kdump[$$]" -p warn -- "Kdump is using the default log level(3)."
kdump_sysloglvl=3
fi
kdump_stdloglvl=0
kdump_kmsgloglvl=0
fi
[ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=3
[ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=3 [ -z "$kdump_kmsgloglvl" ] && kdump_kmsgloglvl=0
for loglvl in $kdump_stdloglvl $kdump_kmsgloglvl $kdump_sysloglvl; do
@@ -103,83 +133,50 @@ dlog_init() { readonly kdump_maxloglvl=$maxloglvl_l export kdump_maxloglvl
- if [[ $kdump_stdloglvl -lt 6 ]] && [[ $kdump_kmsgloglvl -lt 6 ]] && [[ $kdump_sysloglvl -lt 6 ]]; then
unset dtrace
dtrace() { :; };
- fi
- if [[ $kdump_stdloglvl -lt 5 ]] && [[ $kdump_kmsgloglvl -lt 5 ]] && [[ $kdump_sysloglvl -lt 5 ]]; then
- if [[ $kdump_stdloglvl -lt 4 ]] && [[ $kdump_kmsgloglvl -lt 4 ]] && [[ $kdump_sysloglvl -lt 4 ]]; then unset ddebug ddebug() { :; }; fi
- if [[ $kdump_stdloglvl -lt 4 ]] && [[ $kdump_kmsgloglvl -lt 4 ]] && [[ $kdump_sysloglvl -lt 4 ]]; then
- if [[ $kdump_stdloglvl -lt 3 ]] && [[ $kdump_kmsgloglvl -lt 3 ]] && [[ $kdump_sysloglvl -lt 3 ]]; then unset dinfo dinfo() { :; }; fi
- if [[ $kdump_stdloglvl -lt 3 ]] && [[ $kdump_kmsgloglvl -lt 3 ]] && [[ $kdump_sysloglvl -lt 3 ]]; then
- if [[ $kdump_stdloglvl -lt 2 ]] && [[ $kdump_kmsgloglvl -lt 2 ]] && [[ $kdump_sysloglvl -lt 2 ]]; then unset dwarn dwarn() { :; };
unset dwarning
dwarning() { :; };
fi
if [[ $kdump_stdloglvl -lt 2 ]] && [[ $kdump_kmsgloglvl -lt 2 ]] && [[ $kdump_sysloglvl -lt 2 ]]; then
- if [[ $kdump_stdloglvl -lt 1 ]] && [[ $kdump_kmsgloglvl -lt 1 ]] && [[ $kdump_sysloglvl -lt 1 ]]; then unset derror derror() { :; }; fi
if [[ $kdump_stdloglvl -lt 1 ]] && [[ $kdump_kmsgloglvl -lt 1 ]] && [[ $kdump_sysloglvl -lt 1 ]]; then
unset dfatal
dfatal() { :; };
fi
[ -n "$errmsg" ] && derror "$errmsg"
return $ret
}
-## @brief Converts numeric logging level to the first letter of level name. -# -# @param lvl Numeric logging level in range from 1 to 6. -# @retval 1 if @a lvl is out of range. -# @retval 0 if @a lvl is correct. -# @result Echoes first letter of level name. -_lvl2char() {
- case "$1" in
1) echo F;;
2) echo E;;
3) echo W;;
4) echo I;;
5) echo D;;
6) echo T;;
*) return 1;;
- esac
-}
## @brief Converts numeric level to logger priority defined by POSIX.2. # -# @param lvl Numeric logging level in range from 1 to 6. +# @param lvl Numeric logging level in range from 1 to 4. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes logger priority. _lvl2syspri() { case "$1" in
1) echo crit;;
2) echo error;;
3) echo warning;;
4) echo info;;
5) echo debug;;
6) echo debug;;
1) echo error;;
2) echo warning;;
3) echo info;;
esac4) echo debug;; *) return 1;;
}
## @brief Converts logger numeric level to syslog log level # -# @param lvl Numeric logging level in range from 1 to 6. +# @param lvl Numeric logging level in range from 1 to 4. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes kernel console numeric log level @@ -189,13 +186,12 @@ _lvl2syspri() { # <tt> # none -> LOG_EMERG (0) # none -> LOG_ALERT (1) -# FATAL(1) -> LOG_CRIT (2) -# ERROR(2) -> LOG_ERR (3) -# WARN(3) -> LOG_WARNING (4) +# none -> LOG_CRIT (2) +# ERROR(1) -> LOG_ERR (3) +# WARN(2) -> LOG_WARNING (4) # none -> LOG_NOTICE (5) -# INFO(4) -> LOG_INFO (6) -# DEBUG(5) -> LOG_DEBUG (7) -# TRACE(6) / +# INFO(3) -> LOG_INFO (6) +# DEBUG(4) -> LOG_DEBUG (7) # </tt> # # @see /usr/include/sys/syslog.h @@ -203,30 +199,31 @@ _dlvl2syslvl() { local lvl
case "$1" in
1) lvl=2;;
2) lvl=3;;
3) lvl=4;;
4) lvl=6;;
5) lvl=7;;
6) lvl=7;;
1) lvl=3;;
2) lvl=4;;
3) lvl=6;;
esac4) lvl=7;; *) return 1;;
- [ -s /proc/vmcore ] && echo $((24+$lvl)) || echo $((8+$lvl))
- # The number is constructed by multiplying the facility by 8 and then
- # adding the level.
- # About The Syslog Protocol, please refer to the RFC5424 for more details.
- echo $((24+$lvl))
}
-## @brief Prints to stderr and/or writes to file, to syslog and/or /dev/kmsg -# given message with given level (priority). +## @brief Prints to stderr, to syslog and/or /dev/kmsg given message with +# given level (priority). # # @param lvl Numeric logging level. # @param msg Message. # @retval 0 It's always returned, even if logging failed. # # @note This function is not supposed to be called manually. Please use -# dtrace(), ddebug(), or others instead which wrap this one. +# dinfo(), ddebug(), or others instead which wrap this one. # -# This is core logging function which logs given message to standard error, file -# and/or syslog (with POSIX shell command <tt>logger</tt>) and/or to /dev/kmsg. +# This is core logging function which logs given message to standard error +# and syslog (with POSIX shell command <tt>logger</tt>) and/or to /dev/kmsg. # The format is following: # # <tt>X: some message</tt> @@ -236,16 +233,13 @@ _dlvl2syslvl() { # # Message to syslog is sent with tag @c kdump. Priorities are mapped as # following: -# - @c FATAL to @c crit # - @c ERROR to @c error # - @c WARN to @c warning # - @c INFO to @c info -# - @c DEBUG and @c TRACE both to @c debug +# - @c DEBUG to @c debug _do_dlog() { local lvl="$1"; shift
local lvlc=$(_lvl2char "$lvl") || return 0 local msg="$*"
local lmsg="$lvlc: $*"
[[ $lvl -le $kdump_stdloglvl ]] && printf -- 'kdump: %s\n' "$msg" >&2
@@ -268,7 +262,7 @@ _do_dlog() { # @retval 0 It's always returned, even if logging failed. # # @note This function is not supposed to be called manually. Please use -# dtrace(), ddebug(), or others instead which wrap this one. +# dinfo(), ddebug(), or others instead which wrap this one. # # This function calls _do_dlog() either with parameter msg, or if # none is given, it will read standard input and will use every line as @@ -290,71 +284,41 @@ dlog() { fi }
-## @brief Logs message at TRACE level (6) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -dtrace() {
- set +x
- dlog 6 "$@"
- [ -n "$debug" ] && set -x || :
-}
-## @brief Logs message at DEBUG level (5) +## @brief Logs message at DEBUG level (4) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. ddebug() {
- set +x
- dlog 5 "$@"
- [ -n "$debug" ] && set -x || :
-}
-## @brief Logs message at INFO level (4) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -dinfo() { set +x dlog 4 "$@" [ -n "$debug" ] && set -x || : }
-## @brief Logs message at WARN level (3) +## @brief Logs message at INFO level (3) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. -dwarn() { +dinfo() { set +x dlog 3 "$@" [ -n "$debug" ] && set -x || : }
-## @brief It's an alias to dwarn() function. +## @brief Logs message at WARN level (2) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. -dwarning() {
- set +x
- dwarn "$@"
- [ -n "$debug" ] && set -x || :
-}
-## @brief Logs message at ERROR level (2) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -derror() { +dwarn() { set +x dlog 2 "$@" [ -n "$debug" ] && set -x || : }
-## @brief Logs message at FATAL level (1) +## @brief Logs message at ERROR level (1) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. -dfatal() { +derror() { set +x dlog 1 "$@" [ -n "$debug" ] && set -x || : diff --git a/kdump.sysconfig b/kdump.sysconfig index 52a0b9249fe7..d6b54ef489c0 100644 --- a/kdump.sysconfig +++ b/kdump.sysconfig @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -36,18 +36,17 @@ KEXEC_ARGS="" #What is the image type used for kdump KDUMP_IMG="vmlinuz"
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 index 1d75979df03e..f869e0e7e93d 100644 --- a/kdump.sysconfig.aarch64 +++ b/kdump.sysconfig.aarch64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -36,18 +36,17 @@ KEXEC_ARGS="" #What is the image type used for kdump KDUMP_IMG="vmlinuz"
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386 index 2eb9705e32e9..da37cd90d8a0 100644 --- a/kdump.sysconfig.i386 +++ b/kdump.sysconfig.i386 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -39,18 +39,17 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT=""
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 index 24279ff34211..2c91dcd56461 100644 --- a/kdump.sysconfig.ppc64 +++ b/kdump.sysconfig.ppc64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -41,18 +41,17 @@ KDUMP_IMG_EXT=""
#Specify the action after failure
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index 24279ff34211..2c91dcd56461 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -41,18 +41,17 @@ KDUMP_IMG_EXT=""
#Specify the action after failure
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 5e1cb5a7ad89..add43dbc8c34 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd rd.kdumploglvl=3"
# Any additional /sbin/mkdumprd arguments required. MKDUMPRD_ARGS="" @@ -42,18 +42,17 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT=""
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3 +kdump_kmsgloglvl=0 diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index eb1c53824241..fb0da9f33cb7 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swio
# This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd rd.kdumploglvl=3"
# Any additional kexec arguments required. In most situations, this should # be left empty @@ -39,18 +39,17 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT=""
-# Logging is controlled by following global variables: +# Logging is controlled by following global variables in the first kernel: # - @var kdump_stdloglvl - logging level to standard error (console output) # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +kdump_stdloglvl=3 +kdump_sysloglvl=3
+kdump_kmsgloglvl=0
2.17.1
Thanks for the patch,
This patch's idea looks good to me, but maybe it's better to split iinto two, one to remove the extra log level, one for updating the set of the kdumploglvl, so other people can revietw this easier.
OK, good idea. I will split into two patches.
And is this patch based on the latest master branch? git am reports a
Yes, this patch is done based on the latest master branch.
You could need to apply another patch firstly: [PATCH] Add sanity checks for the log level
Thanks. Lianbo
log of conflicts, maybe need a rebase?
-- Best Regards, Kairui Song