Compare commits
No commits in common. "c10s" and "c8" have entirely different histories.
@ -1,32 +0,0 @@
|
||||
# EditorConfig configuration for kexec-tools
|
||||
# http://EditorConfig.org
|
||||
|
||||
# Top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Default code style for kexec-tools scripts
|
||||
[*]
|
||||
end_of_line = lf
|
||||
shell_variant = posix
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = tab
|
||||
indent_size = 1
|
||||
switch_case_indent = false
|
||||
function_next_line = true
|
||||
binary_next_line = false
|
||||
space_redirects = true
|
||||
|
||||
# Some scripts will only run with bash
|
||||
[{mkfadumprd,mkdumprd,kdumpctl,kdump-lib.sh}]
|
||||
shell_variant = bash
|
||||
|
||||
# Use dracut code style for *-module-setup.sh
|
||||
[*-module-setup.sh,dracut-early-kdump.sh]
|
||||
shell_variant = bash
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
switch_case_indent = true
|
||||
function_next_line = false
|
||||
binary_next_line = true
|
||||
space_redirects = true
|
27
.gitignore
vendored
27
.gitignore
vendored
@ -1,24 +1,3 @@
|
||||
*.gz
|
||||
*.xz
|
||||
*.swp
|
||||
*.rpm
|
||||
/eppic_030413.tar.gz
|
||||
/makedumpfile-1.5.7.tar.gz
|
||||
/kexec-tools-2.0.8.tar.xz
|
||||
/kdump-anaconda-addon-005-2-g86366ae.tar.gz
|
||||
/kdump-anaconda-addon-005-5-gbf53665.tar.gz
|
||||
/kdump-anaconda-addon-005-8-ge6ea581.tar.gz
|
||||
/kdump-anaconda-addon-005-9-g6115ca7.tar.gz
|
||||
/kexec-tools-2.0.9.tar.xz
|
||||
/makedumpfile-1.5.8.tar.gz
|
||||
/eppic_050615.tar.gz
|
||||
/kexec-tools-2.0.10.tar.xz
|
||||
/kdump-anaconda-addon-005-10-gd16915f.tar.gz
|
||||
/kdump-anaconda-addon-005-11-g59f9b73.tar.gz
|
||||
/kdump-anaconda-addon-005-12-g60fa4c1.tar.gz
|
||||
/kdump-anaconda-addon-005-14-g563e904.tar.gz
|
||||
/kdump-anaconda-addon-005-16-g586cc82.tar.gz
|
||||
/kexec-tools-2.0.11.tar.xz
|
||||
/makedumpfile-1.5.9.tar.gz
|
||||
/kexec-tools-2.0.12.tar.xz
|
||||
coverage/
|
||||
SOURCES/1.7.2.tar.gz
|
||||
SOURCES/eppic_050615.tar.gz
|
||||
SOURCES/kexec-tools-2.0.26.tar.xz
|
||||
|
3
.kexec-tools.metadata
Normal file
3
.kexec-tools.metadata
Normal file
@ -0,0 +1,3 @@
|
||||
24bce02cd42cdbb960ada4d9e733355582e35784 SOURCES/1.7.2.tar.gz
|
||||
a096c8e0892b559f40b01916aae240652f75b68a SOURCES/eppic_050615.tar.gz
|
||||
27cea5d032ec1e93506b8110222420abf754df2d SOURCES/kexec-tools-2.0.26.tar.xz
|
16
.packit.yaml
16
.packit.yaml
@ -1,16 +0,0 @@
|
||||
# See the documentation for more information:
|
||||
# https://packit.dev/docs/configuration/
|
||||
|
||||
specfile_path: kexec-tools.spec
|
||||
|
||||
# add or remove files that should be synced
|
||||
files_to_sync:
|
||||
- kexec-tools.spec
|
||||
- .packit.yaml
|
||||
|
||||
# name in upstream package repository or registry (e.g. in PyPI)
|
||||
upstream_package_name: kexec-tools
|
||||
# downstream (Fedora) RPM package name
|
||||
downstream_package_name: kexec-tools
|
||||
|
||||
upstream_tag_template: v{version}
|
12
README
12
README
@ -1,12 +0,0 @@
|
||||
Adding a patch to kexec-tools
|
||||
=============================
|
||||
There is a mailing list kexec@lists.fedoraproject.org where all the dicussion
|
||||
related to fedora kexec-tools happen. All the patches are posted there for
|
||||
inclusion and committed to kexec-tools after review.
|
||||
|
||||
So if you want your patches to be included in fedora kexec-tools package,
|
||||
post these to kexec@lists.fedoraproject.org.
|
||||
|
||||
One can subscribe to list and browse through archives here.
|
||||
|
||||
https://admin.fedoraproject.org/mailman/listinfo/kexec
|
@ -1,3 +0,0 @@
|
||||
This repository is maintained by packit.
|
||||
https://packit.dev/
|
||||
The file was generated using packit 0.89.0.
|
36
SOURCES/60-kdump.install
Executable file
36
SOURCES/60-kdump.install
Executable file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
COMMAND="$1"
|
||||
KERNEL_VERSION="$2"
|
||||
KDUMP_INITRD_DIR_ABS="$3"
|
||||
KERNEL_IMAGE="$4"
|
||||
|
||||
if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -d "$KDUMP_INITRD_DIR_ABS" ]]; then
|
||||
KDUMP_INITRD="initrdkdump"
|
||||
else
|
||||
# If `KDUMP_BOOTDIR` is not writable, then the kdump
|
||||
# initrd must have been placed at `/var/lib/kdump`
|
||||
if [[ ! -w "/boot" ]]; then
|
||||
KDUMP_INITRD_DIR_ABS="/var/lib/kdump"
|
||||
else
|
||||
KDUMP_INITRD_DIR_ABS="/boot"
|
||||
fi
|
||||
KDUMP_INITRD="initramfs-${KERNEL_VERSION}kdump.img"
|
||||
fi
|
||||
|
||||
ret=0
|
||||
case "$COMMAND" in
|
||||
add)
|
||||
# Do nothing, kdump initramfs is strictly host only
|
||||
# and managed by kdump service
|
||||
;;
|
||||
remove)
|
||||
rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD"
|
||||
ret=$?
|
||||
;;
|
||||
esac
|
||||
exit $ret
|
16
SOURCES/98-kexec.rules
Normal file
16
SOURCES/98-kexec.rules
Normal file
@ -0,0 +1,16 @@
|
||||
SUBSYSTEM=="cpu", ACTION=="add", GOTO="kdump_reload"
|
||||
SUBSYSTEM=="cpu", ACTION=="remove", GOTO="kdump_reload"
|
||||
SUBSYSTEM=="memory", ACTION=="online", GOTO="kdump_reload"
|
||||
SUBSYSTEM=="memory", ACTION=="offline", GOTO="kdump_reload"
|
||||
|
||||
GOTO="kdump_reload_end"
|
||||
|
||||
LABEL="kdump_reload"
|
||||
|
||||
# If kdump is not loaded, calling kdump-udev-throttle will end up
|
||||
# doing nothing, but systemd-run will always generate extra logs for
|
||||
# each call, so trigger the kdump-udev-throttler only if kdump
|
||||
# service is active to avoid unnecessary logs
|
||||
RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'"
|
||||
|
||||
LABEL="kdump_reload_end"
|
22
SOURCES/98-kexec.rules.ppc64
Normal file
22
SOURCES/98-kexec.rules.ppc64
Normal file
@ -0,0 +1,22 @@
|
||||
SUBSYSTEM=="cpu", ACTION=="online", GOTO="kdump_reload_cpu"
|
||||
SUBSYSTEM=="memory", ACTION=="online", GOTO="kdump_reload_mem"
|
||||
SUBSYSTEM=="memory", ACTION=="offline", GOTO="kdump_reload_mem"
|
||||
|
||||
GOTO="kdump_reload_end"
|
||||
|
||||
# If kdump is not loaded, calling kdump-udev-throttle will end up
|
||||
# doing nothing, but systemd-run will always generate extra logs for
|
||||
# each call, so trigger the kdump-udev-throttler only if kdump
|
||||
# service is active to avoid unnecessary logs
|
||||
|
||||
LABEL="kdump_reload_mem"
|
||||
|
||||
RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'"
|
||||
|
||||
GOTO="kdump_reload_end"
|
||||
|
||||
LABEL="kdump_reload_cpu"
|
||||
|
||||
RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; ! test -f /sys/kernel/fadump_enabled || cat /sys/kernel/fadump_enabled | grep 0 || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'"
|
||||
|
||||
LABEL="kdump_reload_end"
|
64
SOURCES/dracut-early-kdump-module-setup.sh
Executable file
64
SOURCES/dracut-early-kdump-module-setup.sh
Executable file
@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /etc/sysconfig/kdump
|
||||
|
||||
KDUMP_KERNEL=""
|
||||
KDUMP_INITRD=""
|
||||
|
||||
check() {
|
||||
if [ ! -f /etc/sysconfig/kdump ] || [ ! -f /lib/kdump/kdump-lib.sh ]\
|
||||
|| [ -n "${IN_KDUMP}" ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
return 255
|
||||
}
|
||||
|
||||
depends() {
|
||||
echo "base shutdown"
|
||||
return 0
|
||||
}
|
||||
|
||||
prepare_kernel_initrd() {
|
||||
. /lib/kdump/kdump-lib.sh
|
||||
|
||||
prepare_kdump_bootinfo
|
||||
|
||||
# $kernel is a variable from dracut
|
||||
if [ "$KDUMP_KERNELVER" != $kernel ]; then
|
||||
dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \
|
||||
"but the initramfs is generated for kernel version '$kernel'"
|
||||
fi
|
||||
}
|
||||
|
||||
install() {
|
||||
prepare_kernel_initrd
|
||||
if [ ! -f "$KDUMP_KERNEL" ]; then
|
||||
derror "Could not find required kernel for earlykdump," \
|
||||
"earlykdump will not work!"
|
||||
return 1
|
||||
fi
|
||||
if [ ! -f "$KDUMP_INITRD" ]; then
|
||||
derror "Could not find required kdump initramfs for earlykdump," \
|
||||
"please ensure kdump initramfs is generated first," \
|
||||
"earlykdump will not work!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
inst_multiple tail find cut dirname hexdump
|
||||
inst_simple "/etc/sysconfig/kdump"
|
||||
inst_binary "/usr/sbin/kexec"
|
||||
inst_binary "/usr/bin/gawk" "/usr/bin/awk"
|
||||
inst_binary "/usr/bin/logger" "/usr/bin/logger"
|
||||
inst_binary "/usr/bin/printf" "/usr/bin/printf"
|
||||
inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
|
||||
inst_script "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh"
|
||||
inst_hook cmdline 00 "$moddir/early-kdump.sh"
|
||||
inst_binary "$KDUMP_KERNEL"
|
||||
inst_binary "$KDUMP_INITRD"
|
||||
|
||||
ln_r "$KDUMP_KERNEL" "/boot/kernel-earlykdump"
|
||||
ln_r "$KDUMP_INITRD" "/boot/initramfs-earlykdump"
|
||||
|
||||
chmod -x "${initdir}/$KDUMP_KERNEL"
|
||||
}
|
83
SOURCES/dracut-early-kdump.sh
Executable file
83
SOURCES/dracut-early-kdump.sh
Executable file
@ -0,0 +1,83 @@
|
||||
#! /bin/sh
|
||||
|
||||
KEXEC=/sbin/kexec
|
||||
standard_kexec_args="-p"
|
||||
|
||||
EARLY_KDUMP_INITRD=""
|
||||
EARLY_KDUMP_KERNEL=""
|
||||
EARLY_KDUMP_CMDLINE=""
|
||||
EARLY_KDUMP_KERNELVER=""
|
||||
EARLY_KEXEC_ARGS=""
|
||||
|
||||
. /etc/sysconfig/kdump
|
||||
. /lib/dracut-lib.sh
|
||||
. /lib/kdump-lib.sh
|
||||
. /lib/kdump-logger.sh
|
||||
|
||||
#initiate the kdump logger
|
||||
dlog_init
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "failed to initiate the kdump logger."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
prepare_parameters()
|
||||
{
|
||||
EARLY_KDUMP_CMDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}")
|
||||
EARLY_KDUMP_KERNEL="/boot/kernel-earlykdump"
|
||||
EARLY_KDUMP_INITRD="/boot/initramfs-earlykdump"
|
||||
}
|
||||
|
||||
early_kdump_load()
|
||||
{
|
||||
check_kdump_feasibility
|
||||
if [ $? -ne 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if is_fadump_capable; then
|
||||
dwarn "WARNING: early kdump doesn't support fadump."
|
||||
return 1
|
||||
fi
|
||||
|
||||
check_current_kdump_status
|
||||
if [ $? == 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
prepare_parameters
|
||||
|
||||
EARLY_KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}")
|
||||
|
||||
# Here, only output the messages, but do not save these messages
|
||||
# to a file because the target disk may not be mounted yet, the
|
||||
# earlykdump is too early.
|
||||
ddebug "earlykdump: $KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \
|
||||
--command-line=$EARLY_KDUMP_CMDLINE --initrd=$EARLY_KDUMP_INITRD \
|
||||
$EARLY_KDUMP_KERNEL"
|
||||
|
||||
$KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \
|
||||
--command-line="$EARLY_KDUMP_CMDLINE" \
|
||||
--initrd=$EARLY_KDUMP_INITRD $EARLY_KDUMP_KERNEL
|
||||
if [ $? == 0 ]; then
|
||||
dinfo "kexec: loaded early-kdump kernel"
|
||||
return 0
|
||||
else
|
||||
derror "kexec: failed to load early-kdump kernel"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
set_early_kdump()
|
||||
{
|
||||
if getargbool 0 rd.earlykdump; then
|
||||
dinfo "early-kdump is enabled."
|
||||
early_kdump_load
|
||||
else
|
||||
dinfo "early-kdump is disabled."
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
set_early_kdump
|
48
SOURCES/dracut-fadump-init-fadump.sh
Executable file
48
SOURCES/dracut-fadump-init-fadump.sh
Executable file
@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
export PATH=/usr/bin:/usr/sbin
|
||||
export SYSTEMD_IN_INITRD=lenient
|
||||
|
||||
[ -e /proc/mounts ] ||
|
||||
(mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc)
|
||||
|
||||
grep -q '^sysfs /sys sysfs' /proc/mounts ||
|
||||
(mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys)
|
||||
|
||||
grep -q '^none / ' /proc/mounts || grep -q '^rootfs / ' /proc/mounts && ROOTFS_IS_RAMFS=1
|
||||
|
||||
if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then
|
||||
mkdir /newroot
|
||||
mount -t ramfs ramfs /newroot
|
||||
|
||||
if [ $ROOTFS_IS_RAMFS ]; then
|
||||
for FILE in $(ls -A /fadumproot/); do
|
||||
mv /fadumproot/$FILE /newroot/
|
||||
done
|
||||
exec switch_root /newroot /init
|
||||
else
|
||||
mkdir /newroot/sys /newroot/proc /newroot/dev /newroot/run /newroot/oldroot
|
||||
|
||||
grep -q '^devtmpfs /dev devtmpfs' /proc/mounts && mount --move /dev /newroot/dev
|
||||
grep -q '^tmpfs /run tmpfs' /proc/mounts && mount --move /run /newroot/run
|
||||
mount --move /sys /newroot/sys
|
||||
mount --move /proc /newroot/proc
|
||||
|
||||
cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr /fadumproot/. /newroot/
|
||||
cd /newroot && pivot_root . oldroot
|
||||
|
||||
loop=1
|
||||
while [ $loop ]; do
|
||||
unset loop
|
||||
while read -r _ mp _; do
|
||||
case $mp in
|
||||
/oldroot/*) umount -d "$mp" && loop=1 ;;
|
||||
esac
|
||||
done </proc/mounts
|
||||
done
|
||||
umount -d -l oldroot
|
||||
|
||||
exec /init
|
||||
fi
|
||||
else
|
||||
exec /init.dracut
|
||||
fi
|
23
SOURCES/dracut-fadump-module-setup.sh
Normal file
23
SOURCES/dracut-fadump-module-setup.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
check() {
|
||||
return 255
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
mv -f "$initdir/init" "$initdir/init.dracut"
|
||||
inst_script "$moddir/init-fadump.sh" /init
|
||||
chmod a+x "$initdir/init"
|
||||
|
||||
# Install required binaries for the init script (init-fadump.sh)
|
||||
inst_multiple sh modprobe grep mkdir mount
|
||||
if dracut_module_included "squash"; then
|
||||
inst_multiple cp pivot_root umount
|
||||
else
|
||||
inst_multiple ls mv switch_root
|
||||
fi
|
||||
}
|
30
SOURCES/dracut-kdump-capture.service
Normal file
30
SOURCES/dracut-kdump-capture.service
Normal file
@ -0,0 +1,30 @@
|
||||
# This file is part of systemd.
|
||||
#
|
||||
# systemd is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
[Unit]
|
||||
Description=Kdump Vmcore Save Service
|
||||
After=initrd.target initrd-parse-etc.service sysroot.mount
|
||||
After=dracut-initqueue.service dracut-pre-mount.service dracut-mount.service dracut-pre-pivot.service
|
||||
Before=initrd-cleanup.service
|
||||
ConditionPathExists=/etc/initrd-release
|
||||
OnFailure=emergency.target
|
||||
OnFailureJobMode=isolate
|
||||
|
||||
[Service]
|
||||
Environment=DRACUT_SYSTEMD=1
|
||||
Environment=NEWROOT=/sysroot
|
||||
Type=oneshot
|
||||
ExecStart=/bin/kdump.sh
|
||||
StandardInput=null
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog+console
|
||||
KillMode=process
|
||||
RemainAfterExit=yes
|
||||
|
||||
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
|
||||
# terminates cleanly.
|
||||
KillSignal=SIGHUP
|
28
SOURCES/dracut-kdump-emergency.service
Normal file
28
SOURCES/dracut-kdump-emergency.service
Normal file
@ -0,0 +1,28 @@
|
||||
# This file is part of systemd.
|
||||
#
|
||||
# systemd is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This service will be placed in kdump initramfs and replace both the systemd
|
||||
# emergency service and dracut emergency shell. IOW, any emergency will be
|
||||
# kick this service and in turn isolating to kdump error handler.
|
||||
|
||||
[Unit]
|
||||
Description=Kdump Emergency
|
||||
DefaultDependencies=no
|
||||
IgnoreOnIsolate=yes
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/systemctl --no-block isolate kdump-error-handler.service
|
||||
Type=oneshot
|
||||
StandardInput=tty-force
|
||||
StandardOutput=inherit
|
||||
StandardError=inherit
|
||||
KillMode=process
|
||||
IgnoreSIGPIPE=no
|
||||
|
||||
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
|
||||
# terminates cleanly.
|
||||
KillSignal=SIGHUP
|
14
SOURCES/dracut-kdump-emergency.target
Normal file
14
SOURCES/dracut-kdump-emergency.target
Normal file
@ -0,0 +1,14 @@
|
||||
# This file is part of systemd.
|
||||
#
|
||||
# systemd is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
[Unit]
|
||||
Description=Emergency Mode
|
||||
Documentation=man:systemd.special(7)
|
||||
Requires=emergency.service
|
||||
After=emergency.service
|
||||
AllowIsolate=yes
|
||||
IgnoreOnIsolate=yes
|
33
SOURCES/dracut-kdump-error-handler.service
Normal file
33
SOURCES/dracut-kdump-error-handler.service
Normal file
@ -0,0 +1,33 @@
|
||||
# This file is part of systemd.
|
||||
#
|
||||
# systemd is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This service will run the real kdump error handler code. Executing the
|
||||
# failure action configured in kdump.conf
|
||||
|
||||
[Unit]
|
||||
Description=Kdump Error Handler
|
||||
DefaultDependencies=no
|
||||
After=systemd-vconsole-setup.service
|
||||
Wants=systemd-vconsole-setup.service
|
||||
AllowIsolate=yes
|
||||
|
||||
[Service]
|
||||
Environment=HOME=/
|
||||
Environment=DRACUT_SYSTEMD=1
|
||||
Environment=NEWROOT=/sysroot
|
||||
WorkingDirectory=/
|
||||
ExecStart=/bin/kdump-error-handler.sh
|
||||
Type=oneshot
|
||||
StandardInput=tty-force
|
||||
StandardOutput=inherit
|
||||
StandardError=inherit
|
||||
KillMode=process
|
||||
IgnoreSIGPIPE=no
|
||||
|
||||
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
|
||||
# terminates cleanly.
|
||||
KillSignal=SIGHUP
|
10
SOURCES/dracut-kdump-error-handler.sh
Executable file
10
SOURCES/dracut-kdump-error-handler.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/kdump-lib-initramfs.sh
|
||||
|
||||
set -o pipefail
|
||||
export PATH=$PATH:$KDUMP_SCRIPT_DIR
|
||||
|
||||
get_kdump_confs
|
||||
do_failure_action
|
||||
do_final_action
|
324
SOURCES/dracut-kdump.sh
Executable file
324
SOURCES/dracut-kdump.sh
Executable file
@ -0,0 +1,324 @@
|
||||
#!/bin/sh
|
||||
|
||||
# continue here only if we have to save dump.
|
||||
if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
. /lib/dracut-lib.sh
|
||||
. /lib/kdump-lib-initramfs.sh
|
||||
|
||||
set -o pipefail
|
||||
DUMP_RETVAL=0
|
||||
|
||||
export PATH=$PATH:$KDUMP_SCRIPT_DIR
|
||||
|
||||
do_dump()
|
||||
{
|
||||
local _ret
|
||||
|
||||
eval $DUMP_INSTRUCTION
|
||||
_ret=$?
|
||||
|
||||
if [ $_ret -ne 0 ]; then
|
||||
derror "saving vmcore failed"
|
||||
fi
|
||||
|
||||
return $_ret
|
||||
}
|
||||
|
||||
do_kdump_pre()
|
||||
{
|
||||
local _ret
|
||||
|
||||
if [ -n "$KDUMP_PRE" ]; then
|
||||
"$KDUMP_PRE"
|
||||
_ret=$?
|
||||
if [ $_ret -ne 0 ]; then
|
||||
derror "$KDUMP_PRE exited with $_ret status"
|
||||
return $_ret
|
||||
fi
|
||||
fi
|
||||
|
||||
# if any script fails, it just raises warning and continues
|
||||
if [ -d /etc/kdump/pre.d ]; then
|
||||
for file in /etc/kdump/pre.d/*; do
|
||||
"$file"
|
||||
_ret=$?
|
||||
if [ $_ret -ne 0 ]; then
|
||||
derror "$file exited with $_ret status"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
do_kdump_post()
|
||||
{
|
||||
local _ret
|
||||
|
||||
if [ -d /etc/kdump/post.d ]; then
|
||||
for file in /etc/kdump/post.d/*; do
|
||||
"$file" "$1"
|
||||
_ret=$?
|
||||
if [ $_ret -ne 0 ]; then
|
||||
derror "$file exited with $_ret status"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "$KDUMP_POST" ]; then
|
||||
"$KDUMP_POST" "$1"
|
||||
_ret=$?
|
||||
if [ $_ret -ne 0 ]; then
|
||||
derror "$KDUMP_POST exited with $_ret status"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
add_dump_code()
|
||||
{
|
||||
DUMP_INSTRUCTION=$1
|
||||
}
|
||||
|
||||
dump_raw()
|
||||
{
|
||||
local _raw=$1
|
||||
|
||||
[ -b "$_raw" ] || return 1
|
||||
|
||||
dinfo "saving to raw disk $_raw"
|
||||
|
||||
if ! $(echo -n $CORE_COLLECTOR|grep -q makedumpfile); then
|
||||
_src_size=`ls -l /proc/vmcore | cut -d' ' -f5`
|
||||
_src_size_mb=$(($_src_size / 1048576))
|
||||
monitor_dd_progress $_src_size_mb &
|
||||
fi
|
||||
|
||||
dinfo "saving vmcore"
|
||||
$CORE_COLLECTOR /proc/vmcore | dd of=$_raw bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1
|
||||
sync
|
||||
|
||||
dinfo "saving vmcore complete"
|
||||
return 0
|
||||
}
|
||||
|
||||
dump_ssh()
|
||||
{
|
||||
local _ret=0
|
||||
local _exitcode=0 _exitcode2=0
|
||||
local _opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes"
|
||||
local _dir="$KDUMP_PATH/$HOST_IP-$DATEDIR"
|
||||
local _host=$2
|
||||
local _vmcore="vmcore"
|
||||
local _ipv6_addr="" _username=""
|
||||
|
||||
dinfo "saving to $_host:$_dir"
|
||||
|
||||
cat /var/lib/random-seed > /dev/urandom
|
||||
ssh -q $_opt $_host mkdir -p $_dir || return 1
|
||||
|
||||
save_vmcore_dmesg_ssh ${DMESG_COLLECTOR} ${_dir} "${_opt}" $_host
|
||||
save_opalcore_ssh ${_dir} "${_opt}" $_host
|
||||
|
||||
dinfo "saving vmcore"
|
||||
|
||||
if is_ipv6_address "$_host"; then
|
||||
_username=${_host%@*}
|
||||
_ipv6_addr="[${_host#*@}]"
|
||||
fi
|
||||
|
||||
if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then
|
||||
if [ -n "$_username" ] && [ -n "$_ipv6_addr" ]; then
|
||||
scp -q $_opt /proc/vmcore "$_username@$_ipv6_addr:$_dir/vmcore-incomplete"
|
||||
else
|
||||
scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete"
|
||||
fi
|
||||
_exitcode=$?
|
||||
else
|
||||
$CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "umask 0077 && dd bs=512 of=$_dir/vmcore-incomplete"
|
||||
_exitcode=$?
|
||||
_vmcore="vmcore.flat"
|
||||
fi
|
||||
|
||||
if [ $_exitcode -eq 0 ]; then
|
||||
ssh $_opt $_host "mv $_dir/vmcore-incomplete $_dir/$_vmcore"
|
||||
_exitcode2=$?
|
||||
if [ $_exitcode2 -ne 0 ]; then
|
||||
derror "moving vmcore failed, _exitcode:$_exitcode2"
|
||||
else
|
||||
dinfo "saving vmcore complete"
|
||||
fi
|
||||
else
|
||||
derror "saving vmcore failed, _exitcode:$_exitcode"
|
||||
fi
|
||||
|
||||
dinfo "saving the $KDUMP_LOG_FILE to $_host:$_dir/"
|
||||
save_log
|
||||
if [ -n "$_username" ] && [ -n "$_ipv6_addr" ]; then
|
||||
scp -q $_opt $KDUMP_LOG_FILE "$_username@$_ipv6_addr:$_dir/"
|
||||
else
|
||||
scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/"
|
||||
fi
|
||||
_ret=$?
|
||||
if [ $_ret -ne 0 ]; then
|
||||
derror "saving log file failed, _exitcode:$_ret"
|
||||
fi
|
||||
|
||||
if [ $_exitcode -ne 0 ] || [ $_exitcode2 -ne 0 ];then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
save_opalcore_ssh() {
|
||||
local _path=$1
|
||||
local _opts="$2"
|
||||
local _location=$3
|
||||
local _user_name="" _ipv6addr=""
|
||||
|
||||
ddebug "_path=$_path _opts=$_opts _location=$_location"
|
||||
|
||||
if [ ! -f $OPALCORE ]; then
|
||||
# Check if we are on an old kernel that uses a different path
|
||||
if [ -f /sys/firmware/opal/core ]; then
|
||||
OPALCORE="/sys/firmware/opal/core"
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if is_ipv6_address "$_host"; then
|
||||
_user_name=${_location%@*}
|
||||
_ipv6addr="[${_location#*@}]"
|
||||
fi
|
||||
|
||||
dinfo "saving opalcore:$OPALCORE to $_location:$_path"
|
||||
|
||||
if [ -n "$_user_name" ] && [ -n "$_ipv6addr" ]; then
|
||||
scp $_opts $OPALCORE $_user_name@$_ipv6addr:$_path/opalcore-incomplete
|
||||
else
|
||||
scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
derror "saving opalcore failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
ssh $_opts $_location mv $_path/opalcore-incomplete $_path/opalcore
|
||||
dinfo "saving opalcore complete"
|
||||
return 0
|
||||
}
|
||||
|
||||
save_vmcore_dmesg_ssh() {
|
||||
local _dmesg_collector=$1
|
||||
local _path=$2
|
||||
local _opts="$3"
|
||||
local _location=$4
|
||||
|
||||
dinfo "saving vmcore-dmesg.txt to $_location:$_path"
|
||||
$_dmesg_collector /proc/vmcore | ssh $_opts $_location "umask 0077 && dd of=$_path/vmcore-dmesg-incomplete.txt"
|
||||
_exitcode=$?
|
||||
|
||||
if [ $_exitcode -eq 0 ]; then
|
||||
ssh -q $_opts $_location mv $_path/vmcore-dmesg-incomplete.txt $_path/vmcore-dmesg.txt
|
||||
dinfo "saving vmcore-dmesg.txt complete"
|
||||
else
|
||||
derror "saving vmcore-dmesg.txt failed"
|
||||
fi
|
||||
}
|
||||
|
||||
get_host_ip()
|
||||
{
|
||||
local _host
|
||||
if is_nfs_dump_target || is_ssh_dump_target
|
||||
then
|
||||
kdumpnic=$(getarg kdumpnic=)
|
||||
[ -z "$kdumpnic" ] && derror "failed to get kdumpnic!" && return 1
|
||||
_host=`ip addr show dev $kdumpnic|grep '[ ]*inet'`
|
||||
[ $? -ne 0 ] && derror "wrong kdumpnic: $kdumpnic" && return 1
|
||||
_host=`echo $_host | head -n 1 | cut -d' ' -f2`
|
||||
_host="${_host%%/*}"
|
||||
[ -z "$_host" ] && derror "wrong kdumpnic: $kdumpnic" && return 1
|
||||
HOST_IP=$_host
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
read_kdump_conf()
|
||||
{
|
||||
if [ ! -f "$KDUMP_CONF" ]; then
|
||||
derror "$KDUMP_CONF not found"
|
||||
return
|
||||
fi
|
||||
|
||||
get_kdump_confs
|
||||
|
||||
# rescan for add code for dump target
|
||||
while read config_opt config_val;
|
||||
do
|
||||
# remove inline comments after the end of a directive.
|
||||
case "$config_opt" in
|
||||
dracut_args)
|
||||
config_val=$(get_dracut_args_target "$config_val")
|
||||
if [ -n "$config_val" ]; then
|
||||
config_val=$(get_mntpoint_from_target "$config_val")
|
||||
add_dump_code "dump_fs $config_val"
|
||||
fi
|
||||
;;
|
||||
ext[234]|xfs|btrfs|minix|nfs)
|
||||
config_val=$(get_mntpoint_from_target "$config_val")
|
||||
add_dump_code "dump_fs $config_val"
|
||||
;;
|
||||
raw)
|
||||
add_dump_code "dump_raw $config_val"
|
||||
;;
|
||||
ssh)
|
||||
add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val"
|
||||
;;
|
||||
esac
|
||||
done <<< "$(read_strip_comments $KDUMP_CONF)"
|
||||
}
|
||||
|
||||
fence_kdump_notify()
|
||||
{
|
||||
if [ -n "$FENCE_KDUMP_NODES" ]; then
|
||||
$FENCE_KDUMP_SEND $FENCE_KDUMP_ARGS $FENCE_KDUMP_NODES &
|
||||
fi
|
||||
}
|
||||
|
||||
read_kdump_conf
|
||||
fence_kdump_notify
|
||||
|
||||
get_host_ip
|
||||
if [ $? -ne 0 ]; then
|
||||
derror "get_host_ip exited with non-zero status!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$DUMP_INSTRUCTION" ]; then
|
||||
add_dump_code "dump_fs $NEWROOT"
|
||||
fi
|
||||
|
||||
do_kdump_pre
|
||||
if [ $? -ne 0 ]; then
|
||||
derror "kdump_pre script exited with non-zero status!"
|
||||
do_final_action
|
||||
# During systemd service to reboot the machine, stop this shell script running
|
||||
exit 1
|
||||
fi
|
||||
make_trace_mem "kdump saving vmcore" '1:shortmem' '2+:mem' '3+:slab'
|
||||
do_dump
|
||||
DUMP_RETVAL=$?
|
||||
|
||||
do_kdump_post $DUMP_RETVAL
|
||||
if [ $? -ne 0 ]; then
|
||||
derror "kdump_post script exited with non-zero status!"
|
||||
fi
|
||||
|
||||
if [ $DUMP_RETVAL -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
do_final_action
|
1154
SOURCES/dracut-module-setup.sh
Executable file
1154
SOURCES/dracut-module-setup.sh
Executable file
File diff suppressed because it is too large
Load Diff
28
SOURCES/dracut-monitor_dd_progress
Normal file
28
SOURCES/dracut-monitor_dd_progress
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
SRC_FILE_MB=$1
|
||||
|
||||
while true
|
||||
do
|
||||
DD_PID=`pidof dd`
|
||||
if [ -n "$DD_PID" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
while true
|
||||
do
|
||||
sleep 5
|
||||
if [ ! -d /proc/$DD_PID ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
kill -s USR1 $DD_PID
|
||||
CURRENT_SIZE=`tail -n 1 /tmp/dd_progress_file | sed "s/[^0-9].*//g"`
|
||||
[ -n "$CURRENT_SIZE" ] && {
|
||||
CURRENT_MB=$(($CURRENT_SIZE / 1048576))
|
||||
echo -e "Copied $CURRENT_MB MB / $SRC_FILE_MB MB\r"
|
||||
}
|
||||
done
|
||||
|
||||
rm -f /tmp/dd_progress_file
|
95
SOURCES/early-kdump-howto.txt
Normal file
95
SOURCES/early-kdump-howto.txt
Normal file
@ -0,0 +1,95 @@
|
||||
Early Kdump HOWTO
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Early kdump is a mechanism to make kdump operational earlier than normal kdump
|
||||
service. The kdump service starts early enough for general crash cases, but
|
||||
there are some cases where it has no chance to make kdump operational in boot
|
||||
sequence, such as detecting devices and starting early services. If you hit
|
||||
such a case, early kdump may allow you to get more information of it.
|
||||
|
||||
Early kdump is implemented as a dracut module. It adds a kernel (vmlinuz) and
|
||||
initramfs for kdump to your system's initramfs in order to load them as early
|
||||
as possible. After that, if you provide "rd.earlykdump" in kernel command line,
|
||||
then in the initramfs, early kdump will load those files like the normal kdump
|
||||
service. This is disabled by default.
|
||||
|
||||
For the normal kdump service, it can check whether the early kdump has loaded
|
||||
the crash kernel and initramfs. It has no conflict with the early kdump.
|
||||
|
||||
How to configure early kdump
|
||||
----------------------------
|
||||
|
||||
We assume if you're reading this document, you should already have kexec-tools
|
||||
installed.
|
||||
|
||||
You can rebuild the initramfs with earlykdump support with below steps:
|
||||
|
||||
1. start kdump service to make sure kdump initramfs is created.
|
||||
|
||||
# systemctl start kdump
|
||||
|
||||
NOTE: If a crash occurs during boot process, early kdump captures a vmcore
|
||||
and reboot the system by default, so the system might go into crash loop.
|
||||
You can avoid such a crash loop by adding the following settings, which
|
||||
power off the system after dump capturing, to kdump.conf in advance:
|
||||
|
||||
final_action poweroff
|
||||
failure_action poweroff
|
||||
|
||||
For the failure_action, you can choose anything other than "reboot".
|
||||
|
||||
2. rebuild system initramfs with earlykdump support.
|
||||
|
||||
# dracut --force --add earlykdump
|
||||
|
||||
NOTE: Recommend to backup the original system initramfs before performing
|
||||
this step to put it back if something happens during boot-up.
|
||||
|
||||
3. add rd.earlykdump in grub kernel command line.
|
||||
|
||||
After making said changes, reboot your system to take effect. Of course, if you
|
||||
want to disable early kdump, you can simply remove "rd.earlykdump" from kernel
|
||||
boot parameters in grub, and reboot system like above.
|
||||
|
||||
Once the boot is completed, you can check the status of the early kdump support
|
||||
on the command prompt:
|
||||
|
||||
# journalctl -b | grep early-kdump
|
||||
|
||||
Then, you will see some useful logs, for example:
|
||||
|
||||
- if early kdump is successful.
|
||||
|
||||
Mar 09 09:57:56 localhost dracut-cmdline[190]: early-kdump is enabled.
|
||||
Mar 09 09:57:56 localhost dracut-cmdline[190]: kexec: loaded early-kdump kernel
|
||||
|
||||
- if early kdump is disabled.
|
||||
|
||||
Mar 09 10:02:47 localhost dracut-cmdline[189]: early-kdump is disabled.
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
- The size of early kdump initramfs will be large because it includes vmlinuz
|
||||
and kdump initramfs.
|
||||
|
||||
- Early kdump inherits the settings of normal kdump, so any changes that
|
||||
caused normal kdump rebuilding also require rebuilding the system initramfs
|
||||
to make sure that the changes take effect for early kdump. Therefore, after
|
||||
the rebuilding of kdump initramfs is completed, provide a prompt message to
|
||||
tell the fact.
|
||||
|
||||
- If you install an updated kernel and reboot the system with it, the early
|
||||
kdump will be disabled by default. To enable it with the new kernel, you
|
||||
need to take the above steps again.
|
||||
|
||||
Limitation
|
||||
----------
|
||||
|
||||
- At present, early kdump doesn't support fadump.
|
||||
|
||||
- Early kdump loads a crash kernel and initramfs at the beginning of the
|
||||
process in system's initramfs, so a crash at earlier than that (e.g. in
|
||||
kernel initialization) cannot be captured even with the early kdump.
|
352
SOURCES/fadump-howto.txt
Normal file
352
SOURCES/fadump-howto.txt
Normal file
@ -0,0 +1,352 @@
|
||||
Firmware assisted dump (fadump) HOWTO
|
||||
|
||||
Introduction
|
||||
|
||||
Firmware assisted dump is a new feature in the 3.4 mainline kernel supported
|
||||
only on powerpc architecture. The goal of firmware-assisted dump is to enable
|
||||
the dump of a crashed system, and to do so from a fully-reset system, and to
|
||||
minimize the total elapsed time until the system is back in production use. A
|
||||
complete documentation on implementation can be found at
|
||||
Documentation/powerpc/firmware-assisted-dump.txt in upstream linux kernel tree
|
||||
from 3.4 version and above.
|
||||
|
||||
Please note that the firmware-assisted dump feature is only available on Power6
|
||||
and above systems with recent firmware versions.
|
||||
|
||||
Overview
|
||||
|
||||
Fadump
|
||||
|
||||
Fadump is a robust kernel crash dumping mechanism to get reliable kernel crash
|
||||
dump with assistance from firmware. This approach does not use kexec, instead
|
||||
firmware assists in booting the kdump kernel while preserving memory contents.
|
||||
Unlike kdump, the system is fully reset, and loaded with a fresh copy of the
|
||||
kernel. In particular, PCI and I/O devices are reinitialized and are in a
|
||||
clean, consistent state. This second kernel, often called a capture kernel,
|
||||
boots with very little memory and captures the dump image.
|
||||
|
||||
The first kernel registers the sections of memory with the Power firmware for
|
||||
dump preservation during OS initialization. These registered sections of memory
|
||||
are reserved by the first kernel during early boot. When a system crashes, the
|
||||
Power firmware fully resets the system, preserves all the system memory
|
||||
contents, save the low memory (boot memory of size larger of 5% of system
|
||||
RAM or 256MB) of RAM to the previous registered region. It will also save
|
||||
system registers, and hardware PTE's.
|
||||
|
||||
Fadump is supported only on ppc64 platform. The standard kernel and capture
|
||||
kernel are one and the same on ppc64.
|
||||
|
||||
If you're reading this document, you should already have kexec-tools
|
||||
installed. If not, you install it via the following command:
|
||||
|
||||
# yum install kexec-tools
|
||||
|
||||
Fadump Operational Flow:
|
||||
|
||||
Like kdump, fadump also exports the ELF formatted kernel crash dump through
|
||||
/proc/vmcore. Hence existing kdump infrastructure can be used to capture fadump
|
||||
vmcore. The idea is to keep the functionality transparent to end user. From
|
||||
user perspective there is no change in the way kdump init script works.
|
||||
|
||||
However, unlike kdump, fadump does not pre-load kdump kernel and initrd into
|
||||
reserved memory, instead it always uses default OS initrd during second boot
|
||||
after crash. Hence, for fadump, we rebuild the new kdump initrd and replace it
|
||||
with default initrd. Before replacing existing default initrd we take a backup
|
||||
of original default initrd for user's reference. The dracut package has been
|
||||
enhanced to rebuild the default initrd with vmcore capture steps. The initrd
|
||||
image is rebuilt as per the configuration in /etc/kdump.conf file.
|
||||
|
||||
The control flow of fadump works as follows:
|
||||
01. System panics.
|
||||
02. At the crash, kernel informs power firmware that kernel has crashed.
|
||||
03. Firmware takes the control and reboots the entire system preserving
|
||||
only the memory (resets all other devices).
|
||||
04. The reboot follows the normal booting process (non-kexec).
|
||||
05. The boot loader loads the default kernel and initrd from /boot
|
||||
06. The default initrd loads and runs /init
|
||||
07. dracut-kdump.sh script present in fadump aware default initrd checks if
|
||||
'/proc/device-tree/rtas/ibm,kernel-dump' file exists before executing
|
||||
steps to capture vmcore.
|
||||
(This check will help to bypass the vmcore capture steps during normal boot
|
||||
process.)
|
||||
09. Captures dump according to /etc/kdump.conf
|
||||
10. Is dump capture successful (yes goto 12, no goto 11)
|
||||
11. Perform the failure action specified in /etc/kdump.conf
|
||||
(The default failure action is reboot, if unspecified)
|
||||
12. Perform the final action specified in /etc/kdump.conf
|
||||
(The default final action is reboot, if unspecified)
|
||||
|
||||
|
||||
How to configure fadump:
|
||||
|
||||
Again, we assume if you're reading this document, you should already have
|
||||
kexec-tools installed. If not, you install it via the following command:
|
||||
|
||||
# yum install kexec-tools
|
||||
|
||||
Make the kernel to be configured with FADump as the default boot entry, if
|
||||
it isn't already:
|
||||
|
||||
# grubby --set-default=/boot/vmlinuz-<kver>
|
||||
|
||||
Boot into the kernel to be configured for FADump. To be able to do much of
|
||||
anything interesting in the way of debug analysis, you'll also need to install
|
||||
the kernel-debuginfo package, of the same arch as your running kernel, and the
|
||||
crash utility:
|
||||
|
||||
# yum --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash
|
||||
|
||||
Next up, we need to modify some boot parameters to enable firmware assisted
|
||||
dump. With the help of grubby, it's very easy to append "fadump=on" to the end
|
||||
of your kernel boot parameters. To reserve the appropriate amount of memory
|
||||
for boot memory preservation, pass 'crashkernel=X' kernel cmdline parameter.
|
||||
For the recommended value of X, see 'FADump Memory Requirements' section.
|
||||
|
||||
# grubby --args="fadump=on crashkernel=6G" --update-kernel=/boot/vmlinuz-`uname -r`
|
||||
|
||||
By default, FADump reserved memory will be initialized as CMA area to make the
|
||||
memory available through CMA allocator on the production kernel. We can opt out
|
||||
of this, making reserved memory unavailable to production kernel, by booting the
|
||||
linux kernel with 'fadump=nocma' instead of 'fadump=on'.
|
||||
|
||||
The term 'boot memory' means size of the low memory chunk that is required for
|
||||
a kernel to boot successfully when booted with restricted memory. By default,
|
||||
the boot memory size will be the larger of 5% of system RAM or 256MB.
|
||||
Alternatively, user can also specify boot memory size through boot parameter
|
||||
'fadump_reserve_mem=' which will override the default calculated size. Use this
|
||||
option if default boot memory size is not sufficient for second kernel to boot
|
||||
successfully.
|
||||
|
||||
After making said changes, reboot your system, so that the specified memory is
|
||||
reserved and left untouched by the normal system. Take note that the output of
|
||||
'free -m' will show X MB less memory than without this parameter, which is
|
||||
expected. If you see OOM (Out Of Memory) error messages while loading capture
|
||||
kernel, then you should bump up the memory reservation size.
|
||||
|
||||
Now that you've got that reserved memory region set up, you want to turn on
|
||||
the kdump init script:
|
||||
|
||||
# systemctl enable kdump.service
|
||||
|
||||
Then, start up kdump as well:
|
||||
|
||||
# systemctl start kdump.service
|
||||
|
||||
This should turn on the firmware assisted functionality in kernel by
|
||||
echo'ing 1 to /sys/kernel/fadump_registered, leaving the system ready
|
||||
to capture a vmcore upon crashing. For journaling filesystems like XFS an
|
||||
additional step is required to ensure bootloader does not pick the
|
||||
older initrd (without vmcore capture scripts):
|
||||
|
||||
* If /boot is a separate partition, run the below commands as the root user,
|
||||
or as a user with CAP_SYS_ADMIN rights:
|
||||
|
||||
# fsfreeze -f
|
||||
# fsfreeze -u
|
||||
|
||||
* If /boot is not a separate partition, reboot the system.
|
||||
|
||||
After reboot check if the kdump service is up and running with:
|
||||
|
||||
# systemctl status kdump.service
|
||||
|
||||
To test out whether FADump is configured properly, you can force-crash your
|
||||
system by echo'ing a 'c' into /proc/sysrq-trigger:
|
||||
|
||||
# echo c > /proc/sysrq-trigger
|
||||
|
||||
You should see some panic output, followed by the system reset and booting into
|
||||
fresh copy of kernel. When default initrd loads and runs /init, vmcore should
|
||||
be copied out to disk (by default, in /var/crash/<YYYY.MM.DD-HH:MM:SS>/vmcore),
|
||||
then the system rebooted back into your normal kernel.
|
||||
|
||||
Once back to your normal kernel, you can use the previously installed crash
|
||||
kernel in conjunction with the previously installed kernel-debuginfo to
|
||||
perform postmortem analysis:
|
||||
|
||||
# crash /usr/lib/debug/lib/modules/2.6.17-1.2621.el5/vmlinux
|
||||
/var/crash/2006-08-23-15:34/vmcore
|
||||
|
||||
crash> bt
|
||||
|
||||
and so on...
|
||||
|
||||
Saving vmcore-dmesg.txt
|
||||
-----------------------
|
||||
Kernel log bufferes are one of the most important information available
|
||||
in vmcore. Now before saving vmcore, kernel log bufferes are extracted
|
||||
from /proc/vmcore and saved into a file vmcore-dmesg.txt. After
|
||||
vmcore-dmesg.txt, vmcore is saved. Destination disk and directory for
|
||||
vmcore-dmesg.txt is same as vmcore. Note that kernel log buffers will
|
||||
not be available if dump target is raw device.
|
||||
|
||||
FADump Memory Requirements:
|
||||
|
||||
System Memory Recommended memory
|
||||
--------------------- ----------------------
|
||||
4 GB - 16 GB : 768 MB
|
||||
16 GB - 64 GB : 1024 MB
|
||||
64 GB - 128 GB : 2 GB
|
||||
128 GB - 1 TB : 4 GB
|
||||
1 TB - 2 TB : 6 GB
|
||||
2 TB - 4 TB : 12 GB
|
||||
4 TB - 8 TB : 20 GB
|
||||
8 TB - 16 TB : 36 GB
|
||||
16 TB - 32 TB : 64 GB
|
||||
32 TB - 64 TB : 128 GB
|
||||
64 TB & above : 180 GB
|
||||
|
||||
Things to remember:
|
||||
|
||||
1) The memory required to boot capture Kernel is a moving target that depends
|
||||
on many factors like hardware attached to the system, kernel and modules in
|
||||
use, packages installed and services enabled, there is no one-size-fits-all.
|
||||
But the above recommendations are based on system memory. So, the above
|
||||
recommendations for FADump come with a few assumptions, based on available
|
||||
system memory, about the resources the system could have. So, please take
|
||||
the recommendations with a pinch of salt and remember to try capturing dump
|
||||
a few times to confirm that the system is configured successfully with dump
|
||||
capturing support.
|
||||
|
||||
2) Though the memory requirements for FADump seem high, this memory is not
|
||||
completely set aside but made available for userspace applications to use,
|
||||
through the CMA allocator.
|
||||
|
||||
3) As the same initrd is used for booting production kernel as well as capture
|
||||
kernel and with dump being captured in a restricted memory environment, few
|
||||
optimizations (like not inclding network dracut module, disabling multipath
|
||||
and such) are applied while building the initrd. In case, the production
|
||||
environment needs these optimizations to be avoided, dracut_args option in
|
||||
/etc/kdump.conf file could be leveraged. For example, if a user wishes for
|
||||
network module to be included in the initrd, adding the below entry in
|
||||
/etc/kdump.conf file and restarting kdump service would take care of it.
|
||||
|
||||
dracut_args --add "network"
|
||||
|
||||
4) If FADump is configured to capture vmcore to a remote dump target using SSH
|
||||
or NFS protocol, the corresponding network interface '<interface-name>' is
|
||||
renamed to 'kdump-<interface-name>', if it is generic (like *eth# or net#).
|
||||
It happens because vmcore capture scripts in the initial RAM disk (initrd)
|
||||
add the 'kdump-' prefix to the network interface name to secure persistent
|
||||
naming. And as capture kernel and production kernel use the same initrd in
|
||||
case of FADump, the interface name is changed for the production kernel too.
|
||||
This is likely to impact network configuration setup for production kernel.
|
||||
So, it is recommended to use a non-generic name for a network interface,
|
||||
before setting up FADump to capture vmcore to a remote dump target based on
|
||||
that network interface, to avoid running into network configuration issues.
|
||||
|
||||
Dump Triggering methods:
|
||||
|
||||
This section talks about the various ways, other than a Kernel Panic, in which
|
||||
fadump can be triggered. The following methods assume that fadump is configured
|
||||
on your system, with the scripts enabled as described in the section above.
|
||||
|
||||
1) AltSysRq C
|
||||
|
||||
FAdump can be triggered with the combination of the 'Alt','SysRq' and 'C'
|
||||
keyboard keys. Please refer to the following link for more details:
|
||||
|
||||
https://fedoraproject.org/wiki/QA/Sysrq
|
||||
|
||||
In addition, on PowerPC boxes, fadump can also be triggered via Hardware
|
||||
Management Console(HMC) using 'Ctrl', 'O' and 'C' keyboard keys.
|
||||
|
||||
2) Kernel OOPs
|
||||
|
||||
If we want to generate a dump everytime the Kernel OOPses, we can achieve this
|
||||
by setting the 'Panic On OOPs' option as follows:
|
||||
|
||||
# echo 1 > /proc/sys/kernel/panic_on_oops
|
||||
|
||||
3) PowerPC specific methods:
|
||||
|
||||
On IBM PowerPC machines, issuing a soft reset invokes the XMON debugger(if
|
||||
XMON is configured). To configure XMON one needs to compile the kernel with
|
||||
the CONFIG_XMON and CONFIG_XMON_DEFAULT options, or by compiling with
|
||||
CONFIG_XMON and booting the kernel with xmon=on option.
|
||||
|
||||
Following are the ways to remotely issue a soft reset on PowerPC boxes, which
|
||||
would drop you to XMON. Pressing a 'X' (capital alphabet X) followed by an
|
||||
'Enter' here will trigger the dump.
|
||||
|
||||
3.1) HMC
|
||||
|
||||
Hardware Management Console(HMC) available on Power4 and Power5 machines allow
|
||||
partitions to be reset remotely. This is specially useful in hang situations
|
||||
where the system is not accepting any keyboard inputs.
|
||||
|
||||
Once you have HMC configured, the following steps will enable you to trigger
|
||||
fadump via a soft reset:
|
||||
|
||||
On Power4
|
||||
Using GUI
|
||||
|
||||
* In the right pane, right click on the partition you wish to dump.
|
||||
* Select "Operating System->Reset".
|
||||
* Select "Soft Reset".
|
||||
* Select "Yes".
|
||||
|
||||
Using HMC Commandline
|
||||
|
||||
# reset_partition -m <machine> -p <partition> -t soft
|
||||
|
||||
On Power5
|
||||
Using GUI
|
||||
|
||||
* In the right pane, right click on the partition you wish to dump.
|
||||
* Select "Restart Partition".
|
||||
* Select "Dump".
|
||||
* Select "OK".
|
||||
|
||||
Using HMC Commandline
|
||||
|
||||
# chsysstate -m <managed system name> -n <lpar name> -o dumprestart -r lpar
|
||||
|
||||
3.2) Blade Management Console for Blade Center
|
||||
|
||||
To initiate a dump operation, go to Power/Restart option under "Blade Tasks" in
|
||||
the Blade Management Console. Select the corresponding blade for which you want
|
||||
to initate the dump and then click "Restart blade with NMI". This issues a
|
||||
system reset and invokes xmon debugger.
|
||||
|
||||
|
||||
Advanced Setups & Failure action:
|
||||
|
||||
Kdump and fadump exhibit similar behavior in terms of setup & failure action.
|
||||
For fadump advanced setup related information see section "Advanced Setups" in
|
||||
"kexec-kdump-howto.txt" document. Refer to "Failure action" section in "kexec-
|
||||
kdump-howto.txt" document for fadump failure action related information.
|
||||
|
||||
Compression and filtering
|
||||
|
||||
Refer "Compression and filtering" section in "kexec-kdump-howto.txt" document.
|
||||
Compression and filtering are same for kdump & fadump.
|
||||
|
||||
|
||||
Notes on rootfs mount:
|
||||
Dracut is designed to mount rootfs by default. If rootfs mounting fails it
|
||||
will refuse to go on. So fadump leaves rootfs mounting to dracut currently.
|
||||
We make the assumtion that proper root= cmdline is being passed to dracut
|
||||
initramfs for the time being. If you need modify "KDUMP_COMMANDLINE=" in
|
||||
/etc/sysconfig/kdump, you will need to make sure that appropriate root=
|
||||
options are copied from /proc/cmdline. In general it is best to append
|
||||
command line options using "KDUMP_COMMANDLINE_APPEND=" instead of replacing
|
||||
the original command line completely.
|
||||
|
||||
How to disable FADump:
|
||||
|
||||
Remove "fadump=on"/"fadump=nocma" from kernel cmdline parameters OR replace
|
||||
it with "fadump=off" kernel cmdline parameter:
|
||||
|
||||
# grubby --update-kernel=/boot/vmlinuz-`uname -r` --remove-args="fadump=on"
|
||||
or
|
||||
# grubby --update-kernel=/boot/vmlinuz-`uname -r` --remove-args="fadump=nocma"
|
||||
OR
|
||||
# grubby --update-kernel=/boot/vmlinuz-`uname -r` --args="fadump=off"
|
||||
|
||||
If KDump is to be used as the dump capturing mechanism, update the crashkernel
|
||||
parameter (Else, remove "crashkernel=" parameter too, using grubby):
|
||||
|
||||
# grubby --update-kernel=/boot/vmlinuz-$kver --args="crashkernl=auto"
|
||||
|
||||
Reboot the system for the settings to take effect.
|
223
SOURCES/gen-kdump-conf.sh
Executable file
223
SOURCES/gen-kdump-conf.sh
Executable file
@ -0,0 +1,223 @@
|
||||
#!/bin/bash
|
||||
# $1: target arch
|
||||
|
||||
|
||||
SED_EXP=""
|
||||
|
||||
generate()
|
||||
{
|
||||
sed "$SED_EXP" << EOF
|
||||
# This file contains a series of commands to perform (in order) in the kdump
|
||||
# kernel after a kernel crash in the crash kernel(1st kernel) has happened.
|
||||
#
|
||||
# Directives in this file are only applicable to the kdump initramfs, and have
|
||||
# no effect once the root filesystem is mounted and the normal init scripts are
|
||||
# processed.
|
||||
#
|
||||
# Currently, only one dump target and path can be specified. If the dumping to
|
||||
# the configured target fails, the failure action which can be configured via
|
||||
# the "failure_action" directive will be performed.
|
||||
#
|
||||
# Supported options:
|
||||
#
|
||||
# raw <partition>
|
||||
# - Will dd /proc/vmcore into <partition>.
|
||||
# Use persistent device names for partition devices,
|
||||
# such as /dev/vg/<devname>.
|
||||
#
|
||||
# nfs <nfs mount>
|
||||
# - Will mount nfs to <mnt>, and copy /proc/vmcore to
|
||||
# <mnt>/<path>/%HOST-%DATE/, supports DNS.
|
||||
#
|
||||
# ssh <user@server>
|
||||
# - Will save /proc/vmcore to <user@server>:<path>/%HOST-%DATE/,
|
||||
# supports DNS.
|
||||
# NOTE: make sure the user has write permissions on the server.
|
||||
#
|
||||
# sshkey <path>
|
||||
# - Will use the sshkey to do ssh dump.
|
||||
# Specify the path of the ssh key to use when dumping
|
||||
# via ssh. The default value is /root/.ssh/kdump_id_rsa.
|
||||
#
|
||||
# <fs type> <partition>
|
||||
# - Will mount -t <fs type> <partition> <mnt>, and copy
|
||||
# /proc/vmcore to <mnt>/<path>/%DATE/.
|
||||
# NOTE: <partition> can be a device node, label or uuid.
|
||||
# It's recommended to use persistent device names
|
||||
# such as /dev/vg/<devname>.
|
||||
# Otherwise it's suggested to use label or uuid.
|
||||
#
|
||||
# path <path>
|
||||
# - "path" represents the file system path in which vmcore
|
||||
# will be saved. If a dump target is specified in
|
||||
# kdump.conf, then "path" is relative to the specified
|
||||
# dump target.
|
||||
#
|
||||
# Interpretation of "path" changes a bit if the user didn't
|
||||
# specify any dump target explicitly in kdump.conf. In this
|
||||
# case, "path" represents the absolute path from root. The
|
||||
# dump target and adjusted path are arrived at automatically
|
||||
# depending on what's mounted in the current system.
|
||||
#
|
||||
# Ignored for raw device dumps. If unset, will use the default
|
||||
# "/var/crash".
|
||||
#
|
||||
# core_collector <command> <options>
|
||||
# - This allows you to specify the command to copy
|
||||
# the vmcore. The default is makedumpfile, which on
|
||||
# some architectures can drastically reduce vmcore size.
|
||||
# See /sbin/makedumpfile --help for a list of options.
|
||||
# Note that the -i and -g options are not needed here,
|
||||
# as the initrd will automatically be populated with a
|
||||
# config file appropriate for the running kernel.
|
||||
# The default core_collector for raw/ssh dump is:
|
||||
# "makedumpfile -F -l --message-level 7 -d 31".
|
||||
# The default core_collector for other targets is:
|
||||
# "makedumpfile -l --message-level 7 -d 31".
|
||||
#
|
||||
# "makedumpfile -F" will create a flattened vmcore.
|
||||
# You need to use "makedumpfile -R" to rearrange the dump data to
|
||||
# a normal dumpfile readable with analysis tools. For example:
|
||||
# "makedumpfile -R vmcore < vmcore.flat".
|
||||
#
|
||||
# For core_collector format details, you can refer to
|
||||
# kexec-kdump-howto.txt or kdump.conf manpage.
|
||||
#
|
||||
# kdump_post <binary | script>
|
||||
# - This directive allows you to run a executable binary
|
||||
# or script after the vmcore dump process terminates.
|
||||
# The exit status of the current dump process is fed to
|
||||
# the executable binary or script as its first argument.
|
||||
# All files under /etc/kdump/post.d are collectively sorted
|
||||
# and executed in lexical order, before binary or script
|
||||
# specified kdump_post parameter is executed.
|
||||
#
|
||||
# kdump_pre <binary | script>
|
||||
# - Works like the "kdump_post" directive, but instead of running
|
||||
# after the dump process, runs immediately before it.
|
||||
# Exit status of this binary is interpreted as follows:
|
||||
# 0 - continue with dump process as usual
|
||||
# non 0 - run the final action (reboot/poweroff/halt)
|
||||
# All files under /etc/kdump/pre.d are collectively sorted and
|
||||
# executed in lexical order, after binary or script specified
|
||||
# kdump_pre parameter is executed.
|
||||
# Even if the binary or script in /etc/kdump/pre.d directory
|
||||
# returns non 0 exit status, the processing is continued.
|
||||
#
|
||||
# extra_bins <binaries | shell scripts>
|
||||
# - This directive allows you to specify additional binaries or
|
||||
# shell scripts to be included in the kdump initrd.
|
||||
# Generally they are useful in conjunction with a kdump_post
|
||||
# or kdump_pre binary or script which depends on these extra_bins.
|
||||
#
|
||||
# extra_modules <module(s)>
|
||||
# - This directive allows you to specify extra kernel modules
|
||||
# that you want to be loaded in the kdump initrd.
|
||||
# Multiple modules can be listed, separated by spaces, and any
|
||||
# dependent modules will automatically be included.
|
||||
#
|
||||
# failure_action <reboot | halt | poweroff | shell | dump_to_rootfs>
|
||||
# - Action to perform in case dumping fails.
|
||||
# reboot: Reboot the system.
|
||||
# halt: Halt the system.
|
||||
# poweroff: Power down the system.
|
||||
# shell: Drop to a bash shell.
|
||||
# Exiting the shell reboots the system by default,
|
||||
# or perform "final_action".
|
||||
# dump_to_rootfs: Dump vmcore to rootfs from initramfs context and
|
||||
# reboot by default or perform "final_action".
|
||||
# Useful when non-root dump target is specified.
|
||||
# The default option is "reboot".
|
||||
#
|
||||
# default <reboot | halt | poweroff | shell | dump_to_rootfs>
|
||||
# - Same as the "failure_action" directive above, but this directive
|
||||
# is obsolete and will be removed in the future.
|
||||
#
|
||||
# final_action <reboot | halt | poweroff>
|
||||
# - Action to perform in case dumping succeeds. Also performed
|
||||
# when "shell" or "dump_to_rootfs" failure action finishes.
|
||||
# Each action is same as the "failure_action" directive above.
|
||||
# The default is "reboot".
|
||||
#
|
||||
# force_rebuild <0 | 1>
|
||||
# - By default, kdump initrd will only be rebuilt when necessary.
|
||||
# Specify 1 to force rebuilding kdump initrd every time when kdump
|
||||
# service starts.
|
||||
#
|
||||
# force_no_rebuild <0 | 1>
|
||||
# - By default, kdump initrd will be rebuilt when necessary.
|
||||
# Specify 1 to bypass rebuilding of kdump initrd.
|
||||
#
|
||||
# force_no_rebuild and force_rebuild options are mutually
|
||||
# exclusive and they should not be set to 1 simultaneously.
|
||||
#
|
||||
# override_resettable <0 | 1>
|
||||
# - Usually an unresettable block device can't be a dump target.
|
||||
# Specifying 1 when you want to dump even though the block
|
||||
# target is unresettable
|
||||
# By default, it is 0, which will not try dumping destined to fail.
|
||||
#
|
||||
# dracut_args <arg(s)>
|
||||
# - Pass extra dracut options when rebuilding kdump initrd.
|
||||
#
|
||||
# fence_kdump_args <arg(s)>
|
||||
# - Command line arguments for fence_kdump_send (it can contain
|
||||
# all valid arguments except hosts to send notification to).
|
||||
#
|
||||
# fence_kdump_nodes <node(s)>
|
||||
# - List of cluster node(s) except localhost, separated by spaces,
|
||||
# to send fence_kdump notifications to.
|
||||
# (this option is mandatory to enable fence_kdump).
|
||||
#
|
||||
|
||||
#raw /dev/vg/lv_kdump
|
||||
#ext4 /dev/vg/lv_kdump
|
||||
#ext4 LABEL=/boot
|
||||
#ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937
|
||||
#nfs my.server.com:/export/tmp
|
||||
#nfs [2001:db8::1:2:3:4]:/export/tmp
|
||||
#ssh user@my.server.com
|
||||
#ssh user@2001:db8::1:2:3:4
|
||||
#sshkey /root/.ssh/kdump_id_rsa
|
||||
path /var/crash
|
||||
core_collector makedumpfile -l --message-level 7 -d 31
|
||||
#core_collector scp
|
||||
#kdump_post /var/crash/scripts/kdump-post.sh
|
||||
#kdump_pre /var/crash/scripts/kdump-pre.sh
|
||||
#extra_bins /usr/bin/lftp
|
||||
#extra_modules gfs2
|
||||
#failure_action shell
|
||||
#force_rebuild 1
|
||||
#force_no_rebuild 1
|
||||
#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"
|
||||
#fence_kdump_args -p 7410 -f auto -c 0 -i 10
|
||||
#fence_kdump_nodes node1 node2
|
||||
EOF
|
||||
}
|
||||
|
||||
update_param()
|
||||
{
|
||||
SED_EXP="${SED_EXP}s/^$1.*$/$1 $2/;"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
aarch64)
|
||||
;;
|
||||
i386)
|
||||
;;
|
||||
ppc64)
|
||||
;;
|
||||
ppc64le)
|
||||
;;
|
||||
s390x)
|
||||
update_param core_collector \
|
||||
"makedumpfile -c --message-level 7 -d 31"
|
||||
;;
|
||||
x86_64)
|
||||
;;
|
||||
*)
|
||||
echo "Warning: Unknown architecture '$1', using default kdump.conf template."
|
||||
;;
|
||||
esac
|
||||
|
||||
generate
|
23
SOURCES/kdump-dep-generator.sh
Normal file
23
SOURCES/kdump-dep-generator.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
# More details about systemd generator:
|
||||
# http://www.freedesktop.org/wiki/Software/systemd/Generators/
|
||||
|
||||
. /usr/lib/kdump/kdump-lib.sh
|
||||
. /usr/lib/kdump/kdump-logger.sh
|
||||
|
||||
# If invokded with no arguments for testing purpose, output to /tmp to
|
||||
# avoid overriding the existing.
|
||||
dest_dir="/tmp"
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
dest_dir=$1
|
||||
fi
|
||||
|
||||
systemd_dir=/usr/lib/systemd/system
|
||||
kdump_wants=$dest_dir/kdump.service.wants
|
||||
|
||||
if is_ssh_dump_target; then
|
||||
mkdir -p $kdump_wants
|
||||
ln -sf $systemd_dir/network-online.target $kdump_wants/
|
||||
fi
|
91
SOURCES/kdump-in-cluster-environment.txt
Normal file
91
SOURCES/kdump-in-cluster-environment.txt
Normal file
@ -0,0 +1,91 @@
|
||||
Kdump-in-cluster-environment HOWTO
|
||||
|
||||
Introduction
|
||||
|
||||
Kdump is a kexec based crash dumping mechansim for Linux. This docuement
|
||||
illustrate how to configure kdump in cluster environment to allow the kdump
|
||||
crash recovery service complete without being preempted by traditional power
|
||||
fencing methods.
|
||||
|
||||
Overview
|
||||
|
||||
Kexec/Kdump
|
||||
|
||||
Details about Kexec/Kdump are available in Kexec-Kdump-howto file and will not
|
||||
be described here.
|
||||
|
||||
fence_kdump
|
||||
|
||||
fence_kdump is an I/O fencing agent to be used with the kdump crash recovery
|
||||
service. When the fence_kdump agent is invoked, it will listen for a message
|
||||
from the failed node that acknowledges that the failed node is executing the
|
||||
kdump crash kernel. Note that fence_kdump is not a replacement for traditional
|
||||
fencing methods. The fence_kdump agent can only detect that a node has entered
|
||||
the kdump crash recovery service. This allows the kdump crash recovery service
|
||||
complete without being preempted by traditional power fencing methods.
|
||||
|
||||
fence_kdump_send
|
||||
|
||||
fence_kdump_send is a utility used to send messages that acknowledge that the
|
||||
node itself has entered the kdump crash recovery service. The fence_kdump_send
|
||||
utility is typically run in the kdump kernel after a cluster node has
|
||||
encountered a kernel panic. Once the cluster node has entered the kdump crash
|
||||
recovery service, fence_kdump_send will periodically send messages to all
|
||||
cluster nodes. When the fence_kdump agent receives a valid message from the
|
||||
failed nodes, fencing is complete.
|
||||
|
||||
How to configure Pacemaker cluster environment:
|
||||
|
||||
If we want to use kdump in Pacemaker cluster environment, fence-agents-kdump
|
||||
should be installed in every nodes in the cluster. You can achieve this via
|
||||
the following command:
|
||||
|
||||
# yum install -y fence-agents-kdump
|
||||
|
||||
Next is to add kdump_fence to the cluster. Assuming that the cluster consists
|
||||
of three nodes, they are node1, node2 and node3, and use Pacemaker to perform
|
||||
resource management and pcs as cli configuration tool.
|
||||
|
||||
With pcs it is easy to add a stonith resource to the cluster. For example, add
|
||||
a stonith resource named mykdumpfence with fence type of fence_kdump via the
|
||||
following commands:
|
||||
|
||||
# pcs stonith create mykdumpfence fence_kdump \
|
||||
pcmk_host_check=static-list pcmk_host_list="node1 node2 node3"
|
||||
# pcs stonith update mykdumpfence pcmk_monitor_action=metadata --force
|
||||
# pcs stonith update mykdumpfence pcmk_status_action=metadata --force
|
||||
# pcs stonith update mykdumpfence pcmk_reboot_action=off --force
|
||||
|
||||
Then enable stonith
|
||||
# pcs property set stonith-enabled=true
|
||||
|
||||
How to configure kdump:
|
||||
|
||||
Actually there are two ways how to configure fence_kdump support:
|
||||
|
||||
1) Pacemaker based clusters
|
||||
If you have successfully configured fence_kdump in Pacemaker, there is
|
||||
no need to add some special configuration in kdump. So please refer to
|
||||
Kexec-Kdump-howto file for more information.
|
||||
|
||||
2) Generic clusters
|
||||
For other types of clusters there are two configuration options in
|
||||
kdump.conf which enables fence_kdump support:
|
||||
|
||||
fence_kdump_nodes <node(s)>
|
||||
Contains list of cluster node(s) separated by space to send
|
||||
fence_kdump notification to (this option is mandatory to enable
|
||||
fence_kdump)
|
||||
|
||||
fence_kdump_args <arg(s)>
|
||||
Command line arguments for fence_kdump_send (it can contain
|
||||
all valid arguments except hosts to send notification to)
|
||||
|
||||
These options will most probably be configured by your cluster software,
|
||||
so please refer to your cluster documentation how to enable fence_kdump
|
||||
support.
|
||||
|
||||
Please be aware that these two ways cannot be combined and 2) has precedence
|
||||
over 1). It means that if fence_kdump is configured using fence_kdump_nodes
|
||||
and fence_kdump_args options in kdump.conf, Pacemaker configuration is not
|
||||
used even if it exists.
|
248
SOURCES/kdump-lib-initramfs.sh
Executable file
248
SOURCES/kdump-lib-initramfs.sh
Executable file
@ -0,0 +1,248 @@
|
||||
# These variables and functions are useful in 2nd kernel
|
||||
|
||||
. /lib/kdump-lib.sh
|
||||
. /lib/kdump-logger.sh
|
||||
|
||||
KDUMP_PATH="/var/crash"
|
||||
KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log"
|
||||
CORE_COLLECTOR=""
|
||||
DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 7 -d 31"
|
||||
DMESG_COLLECTOR="/sbin/vmcore-dmesg"
|
||||
FAILURE_ACTION="systemctl reboot -f"
|
||||
DATEDIR=`date +%Y-%m-%d-%T`
|
||||
HOST_IP='127.0.0.1'
|
||||
DUMP_INSTRUCTION=""
|
||||
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
|
||||
KDUMP_SCRIPT_DIR="/kdumpscripts"
|
||||
DD_BLKSIZE=512
|
||||
FINAL_ACTION="systemctl reboot -f"
|
||||
KDUMP_CONF="/etc/kdump.conf"
|
||||
KDUMP_PRE=""
|
||||
KDUMP_POST=""
|
||||
NEWROOT="/sysroot"
|
||||
OPALCORE="/sys/firmware/opal/mpipl/core"
|
||||
|
||||
#initiate the kdump logger
|
||||
dlog_init
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "failed to initiate the kdump logger."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
get_kdump_confs()
|
||||
{
|
||||
local config_opt config_val
|
||||
|
||||
while read config_opt config_val;
|
||||
do
|
||||
# remove inline comments after the end of a directive.
|
||||
case "$config_opt" in
|
||||
path)
|
||||
KDUMP_PATH="$config_val"
|
||||
;;
|
||||
core_collector)
|
||||
[ -n "$config_val" ] && CORE_COLLECTOR="$config_val"
|
||||
;;
|
||||
sshkey)
|
||||
if [ -f "$config_val" ]; then
|
||||
SSH_KEY_LOCATION=$config_val
|
||||
fi
|
||||
;;
|
||||
kdump_pre)
|
||||
KDUMP_PRE="$config_val"
|
||||
;;
|
||||
kdump_post)
|
||||
KDUMP_POST="$config_val"
|
||||
;;
|
||||
fence_kdump_args)
|
||||
FENCE_KDUMP_ARGS="$config_val"
|
||||
;;
|
||||
fence_kdump_nodes)
|
||||
FENCE_KDUMP_NODES="$config_val"
|
||||
;;
|
||||
failure_action|default)
|
||||
case $config_val in
|
||||
shell)
|
||||
FAILURE_ACTION="kdump_emergency_shell"
|
||||
;;
|
||||
reboot)
|
||||
FAILURE_ACTION="systemctl reboot -f && exit"
|
||||
;;
|
||||
halt)
|
||||
FAILURE_ACTION="halt && exit"
|
||||
;;
|
||||
poweroff)
|
||||
FAILURE_ACTION="systemctl poweroff -f && exit"
|
||||
;;
|
||||
dump_to_rootfs)
|
||||
FAILURE_ACTION="dump_to_rootfs"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
final_action)
|
||||
case $config_val in
|
||||
reboot)
|
||||
FINAL_ACTION="systemctl reboot -f"
|
||||
;;
|
||||
halt)
|
||||
FINAL_ACTION="halt"
|
||||
;;
|
||||
poweroff)
|
||||
FINAL_ACTION="systemctl poweroff -f"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done <<< "$(read_strip_comments $KDUMP_CONF)"
|
||||
|
||||
if [ -z "$CORE_COLLECTOR" ]; then
|
||||
CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR"
|
||||
if is_ssh_dump_target || is_raw_dump_target; then
|
||||
CORE_COLLECTOR="$CORE_COLLECTOR -F"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# store the kexec kernel log to a file.
|
||||
save_log()
|
||||
{
|
||||
dmesg -T > $KDUMP_LOG_FILE
|
||||
|
||||
if command -v journalctl > /dev/null; then
|
||||
journalctl -ab >> $KDUMP_LOG_FILE
|
||||
fi
|
||||
chmod 600 $KDUMP_LOG_FILE
|
||||
}
|
||||
|
||||
# dump_fs <mount point>
|
||||
dump_fs()
|
||||
{
|
||||
local _exitcode
|
||||
local _mp=$1
|
||||
ddebug "dump_fs _mp=$_mp"
|
||||
|
||||
if ! is_mounted "$_mp"; then
|
||||
dinfo "dump path \"$_mp\" is not mounted, trying to mount..."
|
||||
mount --target $_mp
|
||||
if [ $? -ne 0 ]; then
|
||||
derror "failed to dump to \"$_mp\", it's not a mount point!"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Remove -F in makedumpfile case. We don't want a flat format dump here.
|
||||
[[ $CORE_COLLECTOR = *makedumpfile* ]] && CORE_COLLECTOR=`echo $CORE_COLLECTOR | sed -e "s/-F//g"`
|
||||
|
||||
dinfo "saving to $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
|
||||
|
||||
mount -o remount,rw $_mp || return 1
|
||||
mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1
|
||||
|
||||
save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
|
||||
save_opalcore_fs "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
|
||||
|
||||
dinfo "saving vmcore"
|
||||
$CORE_COLLECTOR /proc/vmcore $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete
|
||||
_exitcode=$?
|
||||
if [ $_exitcode -eq 0 ]; then
|
||||
sync -f "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete"
|
||||
_sync_exitcode=$?
|
||||
if [ $_sync_exitcode -eq 0 ]; then
|
||||
mv "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete" "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore"
|
||||
dinfo "saving vmcore complete"
|
||||
else
|
||||
derror "sync vmcore failed, _exitcode:$_sync_exitcode"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
derror "saving vmcore failed, _exitcode:$_exitcode"
|
||||
fi
|
||||
|
||||
dinfo "saving the $KDUMP_LOG_FILE to $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
|
||||
save_log
|
||||
mv $KDUMP_LOG_FILE $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/
|
||||
if [ $_exitcode -ne 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure
|
||||
return 0
|
||||
}
|
||||
|
||||
save_vmcore_dmesg_fs() {
|
||||
local _dmesg_collector=$1
|
||||
local _path=$2
|
||||
|
||||
dinfo "saving vmcore-dmesg.txt to ${_path}"
|
||||
$_dmesg_collector /proc/vmcore > ${_path}/vmcore-dmesg-incomplete.txt
|
||||
_exitcode=$?
|
||||
if [ $_exitcode -eq 0 ]; then
|
||||
mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt
|
||||
chmod 600 ${_path}/vmcore-dmesg.txt
|
||||
|
||||
# Make sure file is on disk. There have been instances where later
|
||||
# saving vmcore failed and system rebooted without sync and there
|
||||
# was no vmcore-dmesg.txt available.
|
||||
sync
|
||||
dinfo "saving vmcore-dmesg.txt complete"
|
||||
else
|
||||
derror "saving vmcore-dmesg.txt failed"
|
||||
fi
|
||||
}
|
||||
|
||||
save_opalcore_fs() {
|
||||
local _path=$1
|
||||
|
||||
if [ ! -f $OPALCORE ]; then
|
||||
# Check if we are on an old kernel that uses a different path
|
||||
if [ -f /sys/firmware/opal/core ]; then
|
||||
OPALCORE="/sys/firmware/opal/core"
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
dinfo "saving opalcore:$OPALCORE to ${_path}/opalcore"
|
||||
cp $OPALCORE ${_path}/opalcore
|
||||
if [ $? -ne 0 ]; then
|
||||
derror "saving opalcore failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
sync
|
||||
dinfo "saving opalcore complete"
|
||||
return 0
|
||||
}
|
||||
|
||||
dump_to_rootfs()
|
||||
{
|
||||
|
||||
dinfo "Trying to bring up rootfs device"
|
||||
systemctl start dracut-initqueue
|
||||
dinfo "Waiting for rootfs mount, will timeout after 90 seconds"
|
||||
systemctl start sysroot.mount
|
||||
|
||||
ddebug "NEWROOT=$NEWROOT"
|
||||
|
||||
dump_fs $NEWROOT
|
||||
}
|
||||
|
||||
kdump_emergency_shell()
|
||||
{
|
||||
echo "PS1=\"kdump:\\\${PWD}# \"" >/etc/profile
|
||||
ddebug "Switching to dracut emergency..."
|
||||
/bin/dracut-emergency
|
||||
rm -f /etc/profile
|
||||
}
|
||||
|
||||
do_failure_action()
|
||||
{
|
||||
dinfo "Executing failure action $FAILURE_ACTION"
|
||||
eval $FAILURE_ACTION
|
||||
}
|
||||
|
||||
do_final_action()
|
||||
{
|
||||
dinfo "Executing final action $FINAL_ACTION"
|
||||
eval $FINAL_ACTION
|
||||
}
|
1113
SOURCES/kdump-lib.sh
Executable file
1113
SOURCES/kdump-lib.sh
Executable file
File diff suppressed because it is too large
Load Diff
348
SOURCES/kdump-logger.sh
Executable file
348
SOURCES/kdump-logger.sh
Executable file
@ -0,0 +1,348 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This comes from the dracut-logger.sh
|
||||
#
|
||||
# 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 (3)
|
||||
# The INFO level designates informational messages that highlight the
|
||||
# progress of the application at coarse-grained level.
|
||||
# - dwarn (2)
|
||||
# The WARN level designates potentially harmful situations.
|
||||
# - derror (1)
|
||||
# The ERROR level designates error events that might still allow the
|
||||
# application to continue running.
|
||||
#
|
||||
# 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, the function dlog_init() sets it to default:
|
||||
# - In the first kernel:
|
||||
# - @var kdump_stdloglvl = 3 (info)
|
||||
# - @var kdump_sysloglvl = 0 (no logging)
|
||||
# - @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!
|
||||
#
|
||||
|
||||
# Define vairables for the log levels in this module.
|
||||
kdump_stdloglvl=""
|
||||
kdump_sysloglvl=""
|
||||
kdump_kmsgloglvl=""
|
||||
|
||||
# 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.
|
||||
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.
|
||||
#
|
||||
check_loglvl()
|
||||
{
|
||||
case "$1" in
|
||||
0|1|2|3|4)
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# @brief Initializes Logger.
|
||||
# @retval 1 if something has gone wrong
|
||||
# @retval 0 on success.
|
||||
#
|
||||
dlog_init() {
|
||||
local ret=0; local errmsg
|
||||
|
||||
if [ -s /proc/vmcore ];then
|
||||
get_kdump_loglvl
|
||||
if [ $? -ne 0 ];then
|
||||
logger -t "kdump[$$]" -p warn -- "Kdump is using the default log level(3)."
|
||||
kdump_sysloglvl=3
|
||||
fi
|
||||
kdump_stdloglvl=0
|
||||
kdump_kmsgloglvl=0
|
||||
else
|
||||
kdump_stdloglvl=$KDUMP_STDLOGLVL
|
||||
kdump_sysloglvl=$KDUMP_SYSLOGLVL
|
||||
kdump_kmsgloglvl=$KDUMP_KMSGLOGLVL
|
||||
fi
|
||||
|
||||
[ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=3
|
||||
[ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=0
|
||||
[ -z "$kdump_kmsgloglvl" ] && kdump_kmsgloglvl=0
|
||||
|
||||
for loglvl in "$kdump_stdloglvl" "$kdump_kmsgloglvl" "$kdump_sysloglvl"; do
|
||||
check_loglvl "$loglvl"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Illegal log level: $kdump_stdloglvl $kdump_kmsgloglvl $kdump_sysloglvl"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Skip initialization if it's already done.
|
||||
[ -n "$kdump_maxloglvl" ] && return 0
|
||||
|
||||
if [[ $UID -ne 0 ]]; then
|
||||
kdump_kmsgloglvl=0
|
||||
kdump_sysloglvl=0
|
||||
fi
|
||||
|
||||
if [[ $kdump_sysloglvl -gt 0 ]]; then
|
||||
if [[ -d /run/systemd/journal ]] \
|
||||
&& type -P systemd-cat &>/dev/null \
|
||||
&& systemctl --quiet is-active systemd-journald.socket &>/dev/null; then
|
||||
readonly _systemdcatfile="/var/tmp/systemd-cat"
|
||||
mkfifo "$_systemdcatfile" &>/dev/null
|
||||
readonly _dlogfd=15
|
||||
systemd-cat -t 'kdump' --level-prefix=true <"$_systemdcatfile" &
|
||||
exec 15>"$_systemdcatfile"
|
||||
elif ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null; then
|
||||
# We cannot log to syslog, so turn this facility off.
|
||||
kdump_kmsgloglvl=$kdump_sysloglvl
|
||||
kdump_sysloglvl=0
|
||||
ret=1
|
||||
errmsg="No '/dev/log' or 'logger' included for syslog logging"
|
||||
fi
|
||||
fi
|
||||
|
||||
local lvl; local maxloglvl_l=0
|
||||
for lvl in $kdump_stdloglvl $kdump_sysloglvl $kdump_kmsgloglvl; do
|
||||
[[ $lvl -gt $maxloglvl_l ]] && maxloglvl_l=$lvl
|
||||
done
|
||||
readonly kdump_maxloglvl=$maxloglvl_l
|
||||
export kdump_maxloglvl
|
||||
|
||||
if [[ $kdump_stdloglvl -lt 4 ]] && [[ $kdump_kmsgloglvl -lt 4 ]] && [[ $kdump_sysloglvl -lt 4 ]]; then
|
||||
unset ddebug
|
||||
ddebug() { :; };
|
||||
fi
|
||||
|
||||
if [[ $kdump_stdloglvl -lt 3 ]] && [[ $kdump_kmsgloglvl -lt 3 ]] && [[ $kdump_sysloglvl -lt 3 ]]; then
|
||||
unset dinfo
|
||||
dinfo() { :; };
|
||||
fi
|
||||
|
||||
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 1 ]] && [[ $kdump_kmsgloglvl -lt 1 ]] && [[ $kdump_sysloglvl -lt 1 ]]; then
|
||||
unset derror
|
||||
derror() { :; };
|
||||
fi
|
||||
|
||||
[ -n "$errmsg" ] && derror "$errmsg"
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
## @brief Converts numeric level to logger priority defined by POSIX.2.
|
||||
#
|
||||
# @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 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 4.
|
||||
# @retval 1 if @a lvl is out of range.
|
||||
# @retval 0 if @a lvl is correct.
|
||||
# @result Echoes kernel console numeric log level
|
||||
#
|
||||
# Conversion is done as follows:
|
||||
#
|
||||
# <tt>
|
||||
# none -> LOG_EMERG (0)
|
||||
# none -> LOG_ALERT (1)
|
||||
# none -> LOG_CRIT (2)
|
||||
# ERROR(1) -> LOG_ERR (3)
|
||||
# WARN(2) -> LOG_WARNING (4)
|
||||
# none -> LOG_NOTICE (5)
|
||||
# INFO(3) -> LOG_INFO (6)
|
||||
# DEBUG(4) -> LOG_DEBUG (7)
|
||||
# </tt>
|
||||
#
|
||||
# @see /usr/include/sys/syslog.h
|
||||
_dlvl2syslvl() {
|
||||
local lvl
|
||||
|
||||
case "$1" in
|
||||
1) lvl=3;;
|
||||
2) lvl=4;;
|
||||
3) lvl=6;;
|
||||
4) lvl=7;;
|
||||
*) return 1;;
|
||||
esac
|
||||
|
||||
# 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, 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
|
||||
# dinfo(), ddebug(), or others instead which wrap this one.
|
||||
#
|
||||
# This is core logging function which logs given message to standard error
|
||||
# and/or syslog (with POSIX shell command <tt>logger</tt>) and/or to /dev/kmsg.
|
||||
# The format is following:
|
||||
#
|
||||
# <tt>X: some message</tt>
|
||||
#
|
||||
# where @c X is the first letter of logging level. See module description for
|
||||
# details on that.
|
||||
#
|
||||
# Message to syslog is sent with tag @c kdump. Priorities are mapped as
|
||||
# following:
|
||||
# - @c ERROR to @c error
|
||||
# - @c WARN to @c warning
|
||||
# - @c INFO to @c info
|
||||
# - @c DEBUG to @c debug
|
||||
_do_dlog() {
|
||||
local lvl="$1"; shift
|
||||
local msg="$*"
|
||||
|
||||
[[ $lvl -le $kdump_stdloglvl ]] && printf -- 'kdump: %s\n' "$msg" >&2
|
||||
|
||||
if [[ $lvl -le $kdump_sysloglvl ]]; then
|
||||
if [[ "$_dlogfd" ]]; then
|
||||
printf -- "<%s>%s\n" "$(($(_dlvl2syslvl $lvl) & 7))" "$msg" >&$_dlogfd
|
||||
else
|
||||
logger -t "kdump[$$]" -p $(_lvl2syspri $lvl) -- "$msg"
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ $lvl -le $kdump_kmsgloglvl ]] && \
|
||||
echo "<$(_dlvl2syslvl $lvl)>kdump[$$] $msg" >/dev/kmsg
|
||||
}
|
||||
|
||||
## @brief Internal helper function for _do_dlog()
|
||||
#
|
||||
# @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
|
||||
# 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
|
||||
# a message.
|
||||
#
|
||||
# This enables:
|
||||
# dwarn "This is a warning"
|
||||
# echo "This is a warning" | dwarn
|
||||
dlog() {
|
||||
[ -z "$kdump_maxloglvl" ] && return 0
|
||||
[[ $1 -le $kdump_maxloglvl ]] || return 0
|
||||
|
||||
if [[ $# -gt 1 ]]; then
|
||||
_do_dlog "$@"
|
||||
else
|
||||
while read line || [ -n "$line" ]; do
|
||||
_do_dlog "$1" "$line"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
## @brief Logs message at DEBUG level (4)
|
||||
#
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
ddebug() {
|
||||
set +x
|
||||
dlog 4 "$@"
|
||||
[ -n "$debug" ] && set -x || :
|
||||
}
|
||||
|
||||
## @brief Logs message at INFO level (3)
|
||||
#
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
dinfo() {
|
||||
set +x
|
||||
dlog 3 "$@"
|
||||
[ -n "$debug" ] && set -x || :
|
||||
}
|
||||
|
||||
## @brief Logs message at WARN level (2)
|
||||
#
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
dwarn() {
|
||||
set +x
|
||||
dlog 2 "$@"
|
||||
[ -n "$debug" ] && set -x || :
|
||||
}
|
||||
|
||||
## @brief It's an alias to dwarn() function.
|
||||
#
|
||||
# @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 (1)
|
||||
#
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
derror() {
|
||||
set +x
|
||||
dlog 1 "$@"
|
||||
[ -n "$debug" ] && set -x || :
|
||||
}
|
8
SOURCES/kdump-migrate-action.sh
Executable file
8
SOURCES/kdump-migrate-action.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
systemctl is-active kdump
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
/usr/lib/kdump/kdump-restart.sh
|
8
SOURCES/kdump-restart.sh
Normal file
8
SOURCES/kdump-restart.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
export PATH="$PATH:/usr/bin:/usr/sbin"
|
||||
|
||||
exec >>/var/log/kdump-migration.log 2>&1
|
||||
|
||||
echo "kdump: Partition Migration detected. Rebuilding initramfs image to reload."
|
||||
/usr/bin/kdumpctl rebuild
|
||||
/usr/bin/kdumpctl reload
|
42
SOURCES/kdump-udev-throttler
Executable file
42
SOURCES/kdump-udev-throttler
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
# This util helps to reduce the workload of kdump service restarting
|
||||
# on udev event. When hotplugging memory / CPU, multiple udev
|
||||
# events may be triggered concurrently, and obviously, we don't want
|
||||
# to restart kdump service for each event.
|
||||
|
||||
# This script will be called by udev, and make sure kdump service is
|
||||
# restart after all events we are watching are settled.
|
||||
|
||||
# On each call, this script will update try to aquire the $throttle_lock
|
||||
# The first instance acquired the file lock will keep waiting for events
|
||||
# to settle and then reload kdump. Other instances will just exit
|
||||
# In this way, we can make sure kdump service is restarted immediately
|
||||
# and for exactly once after udev events are settled.
|
||||
|
||||
throttle_lock="/var/lock/kdump-udev-throttle"
|
||||
|
||||
exec 9>$throttle_lock
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to create the lock file! Fallback to non-throttled kdump service restart"
|
||||
/bin/kdumpctl reload
|
||||
exit 1
|
||||
fi
|
||||
|
||||
flock -n 9
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Throttling kdump restart for concurrent udev event"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Wait for at least 1 second, at most 4 seconds for udev to settle
|
||||
# Idealy we will have a less than 1 second lag between udev events settle
|
||||
# and kdump reload
|
||||
sleep 1 && udevadm settle --timeout 3
|
||||
|
||||
# Release the lock, /bin/kdumpctl will block and make the process
|
||||
# holding two locks at the same time and we might miss some events
|
||||
exec 9>&-
|
||||
|
||||
/bin/kdumpctl reload
|
||||
|
||||
exit 0
|
381
SOURCES/kdump.conf.5
Normal file
381
SOURCES/kdump.conf.5
Normal file
@ -0,0 +1,381 @@
|
||||
.TH KDUMP.CONF 5 "07/23/2008" "kexec-tools"
|
||||
|
||||
.SH NAME
|
||||
kdump.conf \- configuration file for kdump kernel.
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
kdump.conf is a configuration file for the kdump kernel crash
|
||||
collection service.
|
||||
|
||||
kdump.conf provides post-kexec instructions to the kdump kernel. It is
|
||||
stored in the initrd file managed by the kdump service. If you change
|
||||
this file and do not want to reboot in order for the changes to take
|
||||
effect, restart the kdump service to rebuild the initrd.
|
||||
|
||||
For most configurations, you can simply review the examples provided
|
||||
in the stock /etc/kdump.conf.
|
||||
|
||||
.B NOTE:
|
||||
For filesystem dumps the dump target must be mounted before building
|
||||
kdump initramfs.
|
||||
|
||||
kdump.conf only affects the behavior of the initramfs. Please read the
|
||||
kdump operational flow section of kexec-kdump-howto.txt in the docs to better
|
||||
understand how this configuration file affects the behavior of kdump.
|
||||
|
||||
.SH OPTIONS
|
||||
|
||||
.B raw <partition>
|
||||
.RS
|
||||
Will dd /proc/vmcore into <partition>. Use persistent device names for
|
||||
partition devices, such as /dev/vg/<devname>.
|
||||
.RE
|
||||
|
||||
.B nfs <nfs mount>
|
||||
.RS
|
||||
Will mount nfs to <mnt>, and copy /proc/vmcore to <mnt>/<path>/%HOST-%DATE/,
|
||||
supports DNS. Note that a fqdn should be used as the server name in the
|
||||
mount point.
|
||||
.RE
|
||||
|
||||
.B ssh <user@server>
|
||||
.RS
|
||||
Will scp /proc/vmcore to <user@server>:<path>/%HOST-%DATE/,
|
||||
supports DNS. NOTE: make sure user has necessary write permissions on
|
||||
server and that a fqdn is used as the server name.
|
||||
.RE
|
||||
|
||||
.B sshkey <path>
|
||||
.RS
|
||||
Specify the path of the ssh key to use when dumping via ssh.
|
||||
The default value is /root/.ssh/kdump_id_rsa.
|
||||
.RE
|
||||
|
||||
.B <fs type> <partition>
|
||||
.RS
|
||||
Will mount -t <fs type> <partition> <mnt>, and copy /proc/vmcore to
|
||||
<mnt>/<path>/%DATE/. NOTE: <partition> can be a device node, label
|
||||
or uuid. It's recommended to use persistent device names such as
|
||||
/dev/vg/<devname>. Otherwise it's suggested to use label or uuid.
|
||||
.RE
|
||||
|
||||
.B path <path>
|
||||
.RS
|
||||
"path" represents the file system path in which vmcore will be saved.
|
||||
If a dump target is specified in kdump.conf, then "path" is relative to the
|
||||
specified dump target.
|
||||
.PP
|
||||
Interpretation of "path" changes a bit if the user didn't specify any dump
|
||||
target explicitly in kdump.conf. In this case, "path" represents the
|
||||
absolute path from root. The dump target and adjusted path are arrived
|
||||
at automatically depending on what's mounted in the current system.
|
||||
.PP
|
||||
Ignored for raw device dumps. If unset, will use the default "/var/crash".
|
||||
.RE
|
||||
|
||||
.B core_collector <command> <options>
|
||||
.RS
|
||||
This allows you to specify the command to copy the vmcore.
|
||||
The default is makedumpfile, which on some architectures can drastically reduce
|
||||
core file size. See /sbin/makedumpfile --help for a list of options.
|
||||
Note that the -i and -g options are not needed here, as the initrd
|
||||
will automatically be populated with a config file appropriate
|
||||
for the running kernel.
|
||||
.PP
|
||||
Note 1: About default core collector:
|
||||
The default core_collector for raw/ssh dump is:
|
||||
"makedumpfile -F -l --message-level 7 -d 31".
|
||||
The default core_collector for other targets is:
|
||||
"makedumpfile -l --message-level 7 -d 31".
|
||||
Even if core_collector option is commented out in kdump.conf, makedumpfile
|
||||
is the default core collector and kdump uses it internally.
|
||||
If one does not want makedumpfile as default core_collector, then they
|
||||
need to specify one using core_collector option to change the behavior.
|
||||
.PP
|
||||
Note 2: If "makedumpfile -F" is used then you will get a flattened format
|
||||
vmcore.flat, you will need to use "makedumpfile -R" to rearrange the
|
||||
dump data from standard input to a normal dumpfile (readable with analysis
|
||||
tools).
|
||||
ie. "makedumpfile -R vmcore < vmcore.flat"
|
||||
.PP
|
||||
Note 3: If specified core_collector simply copy the vmcore file to the
|
||||
dump target (eg: cp, scp), the vmcore could be significantly large.
|
||||
Please make sure the dump target has enough space, at leaset larger
|
||||
than the system's RAM.
|
||||
|
||||
.RE
|
||||
|
||||
.B kdump_post <binary | script>
|
||||
.RS
|
||||
This directive allows you to run a specified executable
|
||||
just after the vmcore dump process terminates. The exit
|
||||
status of the current dump process is fed to the kdump_post
|
||||
executable as its first argument($1). Executable can modify
|
||||
it to indicate the new exit status of succeeding dump process,
|
||||
.PP
|
||||
All files under /etc/kdump/post.d are collectively sorted
|
||||
and executed in lexical order, before binary or script
|
||||
specified kdump_post parameter is executed.
|
||||
.PP
|
||||
Note that scripts written for use with this directive must use the /bin/bash
|
||||
interpreter. And since these scripts run in kdump enviroment, the reference to
|
||||
the storage or network device in the scripts should adhere to the section
|
||||
\'Supported dump target types and requirements\' in kexec-kdump-howto.txt.
|
||||
|
||||
.RE
|
||||
|
||||
.B kdump_pre <binary | script>
|
||||
.RS
|
||||
Works just like the "kdump_post" directive, but instead
|
||||
of running after the dump process, runs immediately
|
||||
before. Exit status of this binary is interpreted
|
||||
as follows:
|
||||
.PP
|
||||
0 - continue with dump process as usual
|
||||
.PP
|
||||
non 0 - run the final action (reboot/poweroff/halt)
|
||||
.PP
|
||||
All files under /etc/kdump/pre.d are collectively sorted and
|
||||
executed in lexical order, after binary or script specified
|
||||
kdump_pre parameter is executed.
|
||||
Even if the binary or script in /etc/kdump/pre.d directory
|
||||
returns non 0 exit status, the processing is continued.
|
||||
.PP
|
||||
Note that scripts written for use with this directive must use the /bin/bash
|
||||
interpreter. And since these scripts run in kdump enviroment, the reference to
|
||||
the storage or network device in the scripts should adhere to the section
|
||||
\'Supported dump target types and requirements\' in kexec-kdump-howto.txt.
|
||||
|
||||
.RE
|
||||
|
||||
.B extra_bins <binaries | shell scripts>
|
||||
.RS
|
||||
This directive allows you to specify additional
|
||||
binaries or shell scripts you'd like to include in
|
||||
your kdump initrd. Generally only useful in
|
||||
conjunction with a kdump_post binary or script that
|
||||
relies on other binaries or scripts.
|
||||
.RE
|
||||
|
||||
.B extra_modules <module(s)>
|
||||
.RS
|
||||
This directive allows you to specify extra kernel
|
||||
modules that you want to be loaded in the kdump
|
||||
initrd, typically used to set up access to
|
||||
non-boot-path dump targets that might otherwise
|
||||
not be accessible in the kdump environment. Multiple
|
||||
modules can be listed, separated by spaces, and any
|
||||
dependent modules will automatically be included.
|
||||
.RE
|
||||
|
||||
.B failure_action <reboot | halt | poweroff | shell | dump_to_rootfs>
|
||||
.RS
|
||||
Action to perform in case dumping to the intended target fails. The default is "reboot".
|
||||
reboot: Reboot the system (this is what most people will want, as it returns the system
|
||||
to a normal state). halt: Halt the system and lose the vmcore. poweroff: The system
|
||||
will be powered down. shell: Drop to a shell session inside the initramfs, from which
|
||||
you can manually perform additional recovery actions. Exiting this shell reboots the
|
||||
system by default or performs "final_action".
|
||||
Note: kdump uses bash as the default shell. dump_to_rootfs: If non-root dump
|
||||
target is specified, the failure action can be set as dump_to_rootfs. That means when
|
||||
dumping to target fails, dump vmcore to rootfs from initramfs context and reboot
|
||||
by default or perform "final_action".
|
||||
.RE
|
||||
|
||||
.B default <reboot | halt | poweroff | shell | dump_to_rootfs>
|
||||
.RS
|
||||
Same as the "failure_action" directive above, but this directive is obsolete
|
||||
and will be removed in the future.
|
||||
.RE
|
||||
|
||||
.B final_action <reboot | halt | poweroff>
|
||||
.RS
|
||||
Action to perform in case dumping to the intended target succeeds.
|
||||
Also performed when "shell" or "dump_to_rootfs" failure action finishes.
|
||||
Each action is same as the "failure_action" directive above.
|
||||
The default is "reboot".
|
||||
.RE
|
||||
|
||||
.B force_rebuild <0 | 1>
|
||||
.RS
|
||||
By default, kdump initrd will only be rebuilt when necessary.
|
||||
Specify 1 to force rebuilding kdump initrd every time when kdump service starts.
|
||||
.RE
|
||||
|
||||
.B force_no_rebuild <0 | 1>
|
||||
.RS
|
||||
By default, kdump initrd will be rebuilt when necessary.
|
||||
Specify 1 to bypass rebuilding of kdump initrd.
|
||||
|
||||
.PP
|
||||
force_no_rebuild and force_rebuild options are mutually exclusive and
|
||||
they should not be set to 1 simultaneously.
|
||||
.RE
|
||||
|
||||
.B override_resettable <0 | 1>
|
||||
.RS
|
||||
Usually an unresettable block device can't be a dump target. Specifying 1 means
|
||||
that even though the block target is unresettable, the user wants to try dumping anyway.
|
||||
By default, it's set to 0, which will not try something destined to fail.
|
||||
.RE
|
||||
|
||||
|
||||
.B dracut_args <arg(s)>
|
||||
.RS
|
||||
Kdump uses dracut to generate initramfs for second kernel. This option
|
||||
allows a user to pass arguments to dracut directly.
|
||||
.RE
|
||||
|
||||
|
||||
.B fence_kdump_args <arg(s)>
|
||||
.RS
|
||||
Command line arguments for fence_kdump_send (it can contain all valid
|
||||
arguments except hosts to send notification to).
|
||||
.RE
|
||||
|
||||
|
||||
.B fence_kdump_nodes <node(s)>
|
||||
.RS
|
||||
List of cluster node(s) except localhost, separated by spaces, to send fence_kdump notification
|
||||
to (this option is mandatory to enable fence_kdump).
|
||||
.RE
|
||||
|
||||
|
||||
.SH DEPRECATED OPTIONS
|
||||
|
||||
.B net <nfs mount>|<user@server>
|
||||
.RS
|
||||
net option is replaced by nfs and ssh options. Use nfs or ssh options
|
||||
directly.
|
||||
.RE
|
||||
|
||||
.B options <module> <option list>
|
||||
.RS
|
||||
Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump to add module options as
|
||||
kernel command line parameters. For example, specify 'loop.max_loop=1' to limit
|
||||
maximum loop devices to 1.
|
||||
.RE
|
||||
|
||||
.B link_delay <seconds>
|
||||
.RS
|
||||
link_delay was used to wait for a network device to initialize before using it.
|
||||
Now dracut network module takes care of this issue automatically.
|
||||
.RE
|
||||
|
||||
.B disk_timeout <seconds>
|
||||
.RS
|
||||
Similar to link_delay, dracut ensures disks are ready before kdump uses them.
|
||||
.RE
|
||||
|
||||
.B debug_mem_level <0-3>
|
||||
.RS
|
||||
Turn on verbose debug output of kdump scripts regarding free/used memory at
|
||||
various points of execution. This feature has been
|
||||
moved to dracut now.
|
||||
Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump and
|
||||
append dracut cmdline param rd.memdebug=[0-3] to enable the debug output.
|
||||
|
||||
Higher level means more debugging output.
|
||||
.PP
|
||||
0 - no output
|
||||
.PP
|
||||
1 - partial /proc/meminfo
|
||||
.PP
|
||||
2 - /proc/meminfo
|
||||
.PP
|
||||
3 - /proc/meminfo + /proc/slabinfo
|
||||
.RE
|
||||
|
||||
.B blacklist <list of kernel modules>
|
||||
.RS
|
||||
blacklist option was recently being used to prevent loading modules in
|
||||
initramfs. General terminology for blacklist has been that module is
|
||||
present in initramfs but it is not actually loaded in kernel. Hence
|
||||
retaining blacklist option creates more confusing behavior. It has been
|
||||
deprecated.
|
||||
.PP
|
||||
Instead, use rd.driver.blacklist option on second kernel to blacklist
|
||||
a certain module. One can edit /etc/sysconfig/kdump and edit
|
||||
KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer
|
||||
to dracut.cmdline man page for more details on module blacklist option.
|
||||
.RE
|
||||
|
||||
.RE
|
||||
|
||||
.SH EXAMPLES
|
||||
Here are some examples for core_collector option:
|
||||
.PP
|
||||
Core collector command format depends on dump target type. Typically for
|
||||
filesystem (local/remote), core_collector should accept two arguments.
|
||||
First one is source file and second one is target file. For ex.
|
||||
.TP
|
||||
ex1.
|
||||
core_collector "cp --sparse=always"
|
||||
|
||||
Above will effectively be translated to:
|
||||
|
||||
cp --sparse=always /proc/vmcore <dest-path>/vmcore
|
||||
.TP
|
||||
ex2.
|
||||
core_collector "makedumpfile -l --message-level 7 -d 31"
|
||||
|
||||
Above will effectively be translated to:
|
||||
|
||||
makedumpfile -l --message-level 7 -d 31 /proc/vmcore <dest-path>/vmcore
|
||||
.PP
|
||||
For dump targets like raw and ssh, in general, core collector should expect
|
||||
one argument (source file) and should output the processed core on standard
|
||||
output (There is one exception of "scp", discussed later). This standard
|
||||
output will be saved to destination using appropriate commands.
|
||||
|
||||
raw dumps examples:
|
||||
.TP
|
||||
ex3.
|
||||
core_collector "cat"
|
||||
|
||||
Above will effectively be translated to.
|
||||
|
||||
cat /proc/vmcore | dd of=<target-device>
|
||||
.TP
|
||||
ex4.
|
||||
core_collector "makedumpfile -F -l --message-level 7 -d 31"
|
||||
|
||||
Above will effectively be translated to.
|
||||
|
||||
makedumpfile -F -l --message-level 7 -d 31 | dd of=<target-device>
|
||||
.PP
|
||||
ssh dumps examples
|
||||
.TP
|
||||
ex5.
|
||||
core_collector "cat"
|
||||
|
||||
Above will effectively be translated to.
|
||||
|
||||
cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore"
|
||||
.TP
|
||||
ex6.
|
||||
core_collector "makedumpfile -F -l --message-level 7 -d 31"
|
||||
|
||||
Above will effectively be translated to.
|
||||
|
||||
makedumpfile -F -l --message-level 7 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore"
|
||||
|
||||
There is one exception to standard output rule for ssh dumps. And that is
|
||||
scp. As scp can handle ssh destinations for file transfers, one can
|
||||
specify "scp" as core collector for ssh targets (no output on stdout).
|
||||
.TP
|
||||
ex7.
|
||||
core_collector "scp"
|
||||
|
||||
Above will effectively be translated to.
|
||||
|
||||
scp /proc/vmcore <user@host>:path/vmcore
|
||||
|
||||
.PP
|
||||
examples for other options please see
|
||||
.I /etc/kdump.conf
|
||||
|
||||
.SH SEE ALSO
|
||||
|
||||
kexec(8) mkdumprd(8) dracut.cmdline(7)
|
16
SOURCES/kdump.service
Normal file
16
SOURCES/kdump.service
Normal file
@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=Crash recovery kernel arming
|
||||
After=network.target network-online.target remote-fs.target basic.target
|
||||
DefaultDependencies=no
|
||||
ConditionKernelCommandLine=crashkernel
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/kdumpctl start
|
||||
ExecStop=/usr/bin/kdumpctl stop
|
||||
ExecReload=/usr/bin/kdumpctl reload
|
||||
RemainAfterExit=yes
|
||||
StartLimitInterval=0
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
53
SOURCES/kdump.sysconfig
Normal file
53
SOURCES/kdump.sysconfig
Normal file
@ -0,0 +1,53 @@
|
||||
# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
|
||||
# If no version is specified, then the init script will try to find a
|
||||
# kdump kernel with the same version number as the running kernel.
|
||||
KDUMP_KERNELVER=""
|
||||
|
||||
# The kdump commandline is the command line that needs to be passed off to
|
||||
# the kdump kernel. This will likely match the contents of the grub kernel
|
||||
# line. For example:
|
||||
# KDUMP_COMMANDLINE="ro root=LABEL=/"
|
||||
# Dracut depends on proper root= options, so please make sure that appropriate
|
||||
# root= options are copied from /proc/cmdline. In general it is best to append
|
||||
# command line options using "KDUMP_COMMANDLINE_APPEND=".
|
||||
# If a command line is not specified, the default will be taken from
|
||||
# /proc/cmdline
|
||||
KDUMP_COMMANDLINE=""
|
||||
|
||||
# This variable lets us remove arguments from the current kdump commandline
|
||||
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
|
||||
# NOTE: some arguments such as crashkernel will always be removed
|
||||
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len ignition.firstboot"
|
||||
|
||||
# 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"
|
||||
|
||||
# Any additional kexec arguments required. In most situations, this should
|
||||
# be left empty
|
||||
#
|
||||
# Example:
|
||||
# KEXEC_ARGS="--elf32-core-headers"
|
||||
KEXEC_ARGS=""
|
||||
|
||||
#Where to find the boot image
|
||||
#KDUMP_BOOTDIR="/boot"
|
||||
|
||||
#What is the image type used for kdump
|
||||
KDUMP_IMG="vmlinuz"
|
||||
|
||||
# Logging is controlled by following 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)
|
||||
#
|
||||
# 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: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
|
||||
#
|
||||
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
|
||||
#
|
||||
# KDUMP_STDLOGLVL=3
|
||||
# KDUMP_SYSLOGLVL=0
|
||||
# KDUMP_KMSGLOGLVL=0
|
53
SOURCES/kdump.sysconfig.aarch64
Normal file
53
SOURCES/kdump.sysconfig.aarch64
Normal file
@ -0,0 +1,53 @@
|
||||
# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
|
||||
# If no version is specified, then the init script will try to find a
|
||||
# kdump kernel with the same version number as the running kernel.
|
||||
KDUMP_KERNELVER=""
|
||||
|
||||
# The kdump commandline is the command line that needs to be passed off to
|
||||
# the kdump kernel. This will likely match the contents of the grub kernel
|
||||
# line. For example:
|
||||
# KDUMP_COMMANDLINE="ro root=LABEL=/"
|
||||
# Dracut depends on proper root= options, so please make sure that appropriate
|
||||
# root= options are copied from /proc/cmdline. In general it is best to append
|
||||
# command line options using "KDUMP_COMMANDLINE_APPEND=".
|
||||
# If a command line is not specified, the default will be taken from
|
||||
# /proc/cmdline
|
||||
KDUMP_COMMANDLINE=""
|
||||
|
||||
# This variable lets us remove arguments from the current kdump commandline
|
||||
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
|
||||
# NOTE: some arguments such as crashkernel will always be removed
|
||||
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb ignition.firstboot"
|
||||
|
||||
# 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"
|
||||
|
||||
# Any additional kexec arguments required. In most situations, this should
|
||||
# be left empty
|
||||
#
|
||||
# Example:
|
||||
# KEXEC_ARGS="--elf32-core-headers"
|
||||
KEXEC_ARGS="-s"
|
||||
|
||||
#Where to find the boot image
|
||||
#KDUMP_BOOTDIR="/boot"
|
||||
|
||||
#What is the image type used for kdump
|
||||
KDUMP_IMG="vmlinuz"
|
||||
|
||||
# Logging is controlled by following 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)
|
||||
#
|
||||
# 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: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
|
||||
#
|
||||
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
|
||||
#
|
||||
# KDUMP_STDLOGLVL=3
|
||||
# KDUMP_SYSLOGLVL=0
|
||||
# KDUMP_KMSGLOGLVL=0
|
56
SOURCES/kdump.sysconfig.i386
Normal file
56
SOURCES/kdump.sysconfig.i386
Normal file
@ -0,0 +1,56 @@
|
||||
# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
|
||||
# If no version is specified, then the init script will try to find a
|
||||
# kdump kernel with the same version number as the running kernel.
|
||||
KDUMP_KERNELVER=""
|
||||
|
||||
# The kdump commandline is the command line that needs to be passed off to
|
||||
# the kdump kernel. This will likely match the contents of the grub kernel
|
||||
# line. For example:
|
||||
# KDUMP_COMMANDLINE="ro root=LABEL=/"
|
||||
# Dracut depends on proper root= options, so please make sure that appropriate
|
||||
# root= options are copied from /proc/cmdline. In general it is best to append
|
||||
# command line options using "KDUMP_COMMANDLINE_APPEND=".
|
||||
# If a command line is not specified, the default will be taken from
|
||||
# /proc/cmdline
|
||||
KDUMP_COMMANDLINE=""
|
||||
|
||||
# This variable lets us remove arguments from the current kdump commandline
|
||||
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
|
||||
# NOTE: some arguments such as crashkernel will always be removed
|
||||
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb ignition.firstboot"
|
||||
|
||||
# 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 rootflags=nofail transparent_hugepage=never novmcoredd"
|
||||
|
||||
# Any additional kexec arguments required. In most situations, this should
|
||||
# be left empty
|
||||
#
|
||||
# Example:
|
||||
# KEXEC_ARGS="--elf32-core-headers"
|
||||
KEXEC_ARGS=""
|
||||
|
||||
#Where to find the boot image
|
||||
#KDUMP_BOOTDIR="/boot"
|
||||
|
||||
#What is the image type used for kdump
|
||||
KDUMP_IMG="vmlinuz"
|
||||
|
||||
#What is the images extension. Relocatable kernels don't have one
|
||||
KDUMP_IMG_EXT=""
|
||||
|
||||
# Logging is controlled by following 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)
|
||||
#
|
||||
# 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: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
|
||||
#
|
||||
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
|
||||
#
|
||||
# KDUMP_STDLOGLVL=3
|
||||
# KDUMP_SYSLOGLVL=0
|
||||
# KDUMP_KMSGLOGLVL=0
|
58
SOURCES/kdump.sysconfig.ppc64
Normal file
58
SOURCES/kdump.sysconfig.ppc64
Normal file
@ -0,0 +1,58 @@
|
||||
# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
|
||||
# If no version is specified, then the init script will try to find a
|
||||
# kdump kernel with the same version number as the running kernel.
|
||||
KDUMP_KERNELVER=""
|
||||
|
||||
# The kdump commandline is the command line that needs to be passed off to
|
||||
# the kdump kernel. This will likely match the contents of the grub kernel
|
||||
# line. For example:
|
||||
# KDUMP_COMMANDLINE="ro root=LABEL=/"
|
||||
# Dracut depends on proper root= options, so please make sure that appropriate
|
||||
# root= options are copied from /proc/cmdline. In general it is best to append
|
||||
# command line options using "KDUMP_COMMANDLINE_APPEND=".
|
||||
# If a command line is not specified, the default will be taken from
|
||||
# /proc/cmdline
|
||||
KDUMP_COMMANDLINE=""
|
||||
|
||||
# This variable lets us remove arguments from the current kdump commandline
|
||||
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
|
||||
# NOTE: some arguments such as crashkernel will always be removed
|
||||
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb ignition.firstboot"
|
||||
|
||||
# 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 rootflags=nofail kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd"
|
||||
|
||||
# Any additional kexec arguments required. In most situations, this should
|
||||
# be left empty
|
||||
#
|
||||
# Example:
|
||||
# KEXEC_ARGS="--elf32-core-headers"
|
||||
KEXEC_ARGS="--dt-no-old-root"
|
||||
|
||||
#Where to find the boot image
|
||||
#KDUMP_BOOTDIR="/boot"
|
||||
|
||||
#What is the image type used for kdump
|
||||
KDUMP_IMG="vmlinuz"
|
||||
|
||||
#What is the images extension. Relocatable kernels don't have one
|
||||
KDUMP_IMG_EXT=""
|
||||
|
||||
#Specify the action after failure
|
||||
|
||||
# Logging is controlled by following 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)
|
||||
#
|
||||
# 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: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
|
||||
#
|
||||
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
|
||||
#
|
||||
# KDUMP_STDLOGLVL=3
|
||||
# KDUMP_SYSLOGLVL=0
|
||||
# KDUMP_KMSGLOGLVL=0
|
58
SOURCES/kdump.sysconfig.ppc64le
Normal file
58
SOURCES/kdump.sysconfig.ppc64le
Normal file
@ -0,0 +1,58 @@
|
||||
# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
|
||||
# If no version is specified, then the init script will try to find a
|
||||
# kdump kernel with the same version number as the running kernel.
|
||||
KDUMP_KERNELVER=""
|
||||
|
||||
# The kdump commandline is the command line that needs to be passed off to
|
||||
# the kdump kernel. This will likely match the contents of the grub kernel
|
||||
# line. For example:
|
||||
# KDUMP_COMMANDLINE="ro root=LABEL=/"
|
||||
# Dracut depends on proper root= options, so please make sure that appropriate
|
||||
# root= options are copied from /proc/cmdline. In general it is best to append
|
||||
# command line options using "KDUMP_COMMANDLINE_APPEND=".
|
||||
# If a command line is not specified, the default will be taken from
|
||||
# /proc/cmdline
|
||||
KDUMP_COMMANDLINE=""
|
||||
|
||||
# This variable lets us remove arguments from the current kdump commandline
|
||||
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
|
||||
# NOTE: some arguments such as crashkernel will always be removed
|
||||
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb ignition.firstboot"
|
||||
|
||||
# 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 rootflags=nofail kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd"
|
||||
|
||||
# Any additional kexec arguments required. In most situations, this should
|
||||
# be left empty
|
||||
#
|
||||
# Example:
|
||||
# KEXEC_ARGS="--elf32-core-headers"
|
||||
KEXEC_ARGS="--dt-no-old-root"
|
||||
|
||||
#Where to find the boot image
|
||||
#KDUMP_BOOTDIR="/boot"
|
||||
|
||||
#What is the image type used for kdump
|
||||
KDUMP_IMG="vmlinuz"
|
||||
|
||||
#What is the images extension. Relocatable kernels don't have one
|
||||
KDUMP_IMG_EXT=""
|
||||
|
||||
#Specify the action after failure
|
||||
|
||||
# Logging is controlled by following 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)
|
||||
#
|
||||
# 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: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
|
||||
#
|
||||
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
|
||||
#
|
||||
# KDUMP_STDLOGLVL=3
|
||||
# KDUMP_SYSLOGLVL=0
|
||||
# KDUMP_KMSGLOGLVL=0
|
59
SOURCES/kdump.sysconfig.s390x
Normal file
59
SOURCES/kdump.sysconfig.s390x
Normal file
@ -0,0 +1,59 @@
|
||||
# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
|
||||
# If no version is specified, then the init script will try to find a
|
||||
# kdump kernel with the same version number as the running kernel.
|
||||
KDUMP_KERNELVER=""
|
||||
|
||||
# The kdump commandline is the command line that needs to be passed off to
|
||||
# the kdump kernel. This will likely match the contents of the grub kernel
|
||||
# line. For example:
|
||||
# KDUMP_COMMANDLINE="ro root=LABEL=/"
|
||||
# Dracut depends on proper root= options, so please make sure that appropriate
|
||||
# root= options are copied from /proc/cmdline. In general it is best to append
|
||||
# command line options using "KDUMP_COMMANDLINE_APPEND=".
|
||||
# If a command line is not specified, the default will be taken from
|
||||
# /proc/cmdline
|
||||
KDUMP_COMMANDLINE=""
|
||||
|
||||
# This variable lets us remove arguments from the current kdump commandline
|
||||
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
|
||||
# NOTE: some arguments such as crashkernel will always be removed
|
||||
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb prot_virt ignition.firstboot zfcp.allow_lun_scan"
|
||||
|
||||
# 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 rootflags=nofail transparent_hugepage=never novmcoredd"
|
||||
|
||||
# Any additional /sbin/mkdumprd arguments required.
|
||||
MKDUMPRD_ARGS=""
|
||||
|
||||
# Any additional kexec arguments required. In most situations, this should
|
||||
# be left empty
|
||||
#
|
||||
# Example:
|
||||
# KEXEC_ARGS="--elf32-core-headers"
|
||||
KEXEC_ARGS="-s"
|
||||
|
||||
#Where to find the boot image
|
||||
#KDUMP_BOOTDIR="/boot"
|
||||
|
||||
#What is the image type used for kdump
|
||||
KDUMP_IMG="vmlinuz"
|
||||
|
||||
#What is the images extension. Relocatable kernels don't have one
|
||||
KDUMP_IMG_EXT=""
|
||||
|
||||
# Logging is controlled by following 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)
|
||||
#
|
||||
# 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: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
|
||||
#
|
||||
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
|
||||
#
|
||||
# KDUMP_STDLOGLVL=3
|
||||
# KDUMP_SYSLOGLVL=0
|
||||
# KDUMP_KMSGLOGLVL=0
|
56
SOURCES/kdump.sysconfig.x86_64
Normal file
56
SOURCES/kdump.sysconfig.x86_64
Normal file
@ -0,0 +1,56 @@
|
||||
# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
|
||||
# If no version is specified, then the init script will try to find a
|
||||
# kdump kernel with the same version number as the running kernel.
|
||||
KDUMP_KERNELVER=""
|
||||
|
||||
# The kdump commandline is the command line that needs to be passed off to
|
||||
# the kdump kernel. This will likely match the contents of the grub kernel
|
||||
# line. For example:
|
||||
# KDUMP_COMMANDLINE="ro root=LABEL=/"
|
||||
# Dracut depends on proper root= options, so please make sure that appropriate
|
||||
# root= options are copied from /proc/cmdline. In general it is best to append
|
||||
# command line options using "KDUMP_COMMANDLINE_APPEND=".
|
||||
# If a command line is not specified, the default will be taken from
|
||||
# /proc/cmdline
|
||||
KDUMP_COMMANDLINE=""
|
||||
|
||||
# This variable lets us remove arguments from the current kdump commandline
|
||||
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
|
||||
# NOTE: some arguments such as crashkernel will always be removed
|
||||
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb ignition.firstboot"
|
||||
|
||||
# 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 rootflags=nofail acpi_no_memhotplug transparent_hugepage=never nokaslr novmcoredd hest_disable"
|
||||
|
||||
# Any additional kexec arguments required. In most situations, this should
|
||||
# be left empty
|
||||
#
|
||||
# Example:
|
||||
# KEXEC_ARGS="--elf32-core-headers"
|
||||
KEXEC_ARGS="-s"
|
||||
|
||||
#Where to find the boot image
|
||||
#KDUMP_BOOTDIR="/boot"
|
||||
|
||||
#What is the image type used for kdump
|
||||
KDUMP_IMG="vmlinuz"
|
||||
|
||||
#What is the images extension. Relocatable kernels don't have one
|
||||
KDUMP_IMG_EXT=""
|
||||
|
||||
# Logging is controlled by following 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)
|
||||
#
|
||||
# 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: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND
|
||||
#
|
||||
# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4)
|
||||
#
|
||||
# KDUMP_STDLOGLVL=3
|
||||
# KDUMP_SYSLOGLVL=0
|
||||
# KDUMP_KMSGLOGLVL=0
|
1385
SOURCES/kdumpctl
Executable file
1385
SOURCES/kdumpctl
Executable file
File diff suppressed because it is too large
Load Diff
55
SOURCES/kdumpctl.8
Normal file
55
SOURCES/kdumpctl.8
Normal file
@ -0,0 +1,55 @@
|
||||
.TH KDUMPCTL 8 2015-07-13 kexec-tools
|
||||
|
||||
.SH NAME
|
||||
kdumpctl \- control interface for kdump
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B kdumpctl
|
||||
.I COMMAND
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B kdumpctl
|
||||
is used to check or control the kdump service.
|
||||
In most cases, you should use
|
||||
.B systemctl
|
||||
to start / stop / enable kdump service instead. However,
|
||||
.B kdumpctl
|
||||
provides more details for debug and a helper to setup ssh key authentication.
|
||||
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
.I start
|
||||
Start the service.
|
||||
.TP
|
||||
.I stop
|
||||
Stop the service.
|
||||
.TP
|
||||
.I status
|
||||
Prints the current status of kdump service.
|
||||
It returns non-zero value if kdump is not operational.
|
||||
.TP
|
||||
.I restart
|
||||
Is equal to
|
||||
.I start; stop
|
||||
.TP
|
||||
.I reload
|
||||
reload crash kernel image and initramfs without triggering a rebuild.
|
||||
.TP
|
||||
.I rebuild
|
||||
rebuild the crash kernel initramfs.
|
||||
.TP
|
||||
.I propagate
|
||||
Helps to setup key authentication for ssh storage since it's
|
||||
impossible to use password authentication during kdump.
|
||||
.TP
|
||||
.I showmem
|
||||
Prints the size of reserved memory for crash kernel in megabytes.
|
||||
.TP
|
||||
.I estimate
|
||||
Estimate a suitable crashkernel value for current machine. This is a
|
||||
best-effort estimate. It will print a recommanded crashkernel value
|
||||
based on current kdump setup, and list some details of memory usage.
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.BR kdump.conf (5),
|
||||
.BR mkdumprd (8)
|
1047
SOURCES/kexec-kdump-howto.txt
Normal file
1047
SOURCES/kexec-kdump-howto.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,72 @@
|
||||
From 58553ad03187f0cf208d6c4a0dc026c6338e5edd Mon Sep 17 00:00:00 2001
|
||||
From: "Daisuke Hatayama (Fujitsu)" <d.hatayama@fujitsu.com>
|
||||
Date: Wed, 29 Mar 2023 12:44:10 +0000
|
||||
Subject: [PATCH] [PATCH] sadump: fix failure of reading memory when 5-level
|
||||
paging is enabled
|
||||
|
||||
makedumpfile fails as follows for memory dumps collected by sadump
|
||||
when 5-level paging is enabled on the corresponding systems:
|
||||
|
||||
# makedumpfile -l -d 31 -x ./vmlinux ./dump.sadump dump.sadump-ld31
|
||||
__vtop4_x86_64: Can't get a valid pgd.
|
||||
...snip...
|
||||
__vtop4_x86_64: Can't get a valid pgd.
|
||||
calc_kaslr_offset: failed to calculate kaslr_offset and phys_base; default to 0
|
||||
__vtop4_x86_64: Can't get a valid pgd.
|
||||
readmem: Can't convert a virtual address(ffffffff82fce960) to physical address.
|
||||
readmem: type_addr: 0, addr:ffffffff82fce960, size:1024
|
||||
cpu_online_mask_init: Can't read cpu_online_mask memory.
|
||||
|
||||
makedumpfile Failed.
|
||||
|
||||
This is because 5-level paging support has not been done yet for
|
||||
sadump; the work of the 5-level paging support was done by the commit
|
||||
30a3214a7193e94c551c0cebda5918a72a35c589 (PATCH 4/4 arch/x86_64: Add
|
||||
5-level paging support) but that was focused on the core part only.
|
||||
|
||||
Having said that, most of things has already been finished in the
|
||||
commit. What needs to be newly added for sadump is just how to check
|
||||
if 5-level paging is enabled for a given memory dump.
|
||||
|
||||
For that purpose, let's refer to CR4.LA57, bit 12 of CR4, representing
|
||||
whether 5-level paging is enabled or not. We can do this because
|
||||
memory dumps collected by sadump have SMRAM as note information and
|
||||
they include CR4 together with the other control registers.
|
||||
|
||||
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
|
||||
---
|
||||
sadump_info.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/makedumpfile-1.7.2/sadump_info.c b/makedumpfile-1.7.2/sadump_info.c
|
||||
index adfa8dc..2c44068 100644
|
||||
--- a/makedumpfile-1.7.2/sadump_info.c
|
||||
+++ b/makedumpfile-1.7.2/sadump_info.c
|
||||
@@ -1362,6 +1362,7 @@ static int linux_banner_sanity_check(ulong cr3)
|
||||
#define PTI_USER_PGTABLE_BIT (info->page_shift)
|
||||
#define PTI_USER_PGTABLE_MASK (1 << PTI_USER_PGTABLE_BIT)
|
||||
#define CR3_PCID_MASK 0xFFFull
|
||||
+#define CR4_LA57 (1 << 12)
|
||||
int
|
||||
calc_kaslr_offset(void)
|
||||
{
|
||||
@@ -1397,6 +1398,8 @@ calc_kaslr_offset(void)
|
||||
else
|
||||
cr3 = smram.Cr3 & ~CR3_PCID_MASK;
|
||||
|
||||
+ NUMBER(pgtable_l5_enabled) = !!(smram.Cr4 & CR4_LA57);
|
||||
+
|
||||
/* Convert virtual address of IDT table to physical address */
|
||||
idtr_paddr = vtop4_x86_64_pagetable(idtr, cr3);
|
||||
if (idtr_paddr == NOT_PADDR) {
|
||||
@@ -1417,6 +1420,7 @@ calc_kaslr_offset(void)
|
||||
|
||||
DEBUG_MSG("sadump: idtr=%" PRIx64 "\n", idtr);
|
||||
DEBUG_MSG("sadump: cr3=%" PRIx64 "\n", cr3);
|
||||
+ DEBUG_MSG("sadump: cr4=%" PRIx32 "\n", smram.Cr4);
|
||||
DEBUG_MSG("sadump: idtr(phys)=%" PRIx64 "\n", idtr_paddr);
|
||||
DEBUG_MSG("sadump: devide_error(vmlinux)=%lx\n",
|
||||
divide_error_vmlinux);
|
||||
--
|
||||
2.31.1
|
||||
|
25
SOURCES/live-image-kdump-howto.txt
Normal file
25
SOURCES/live-image-kdump-howto.txt
Normal file
@ -0,0 +1,25 @@
|
||||
Kdump now works on live images with some manual configurations. Here is the step
|
||||
by step guide.
|
||||
|
||||
1. Enable crashkernel reservation
|
||||
|
||||
Since there isn't any config file that can be used to configure kernel
|
||||
parameters for live images before booting them, we have to append 'crashkernel'
|
||||
argument in boot menu every time we boot a live image.
|
||||
|
||||
2. Change dump target in /etc/kdump.conf
|
||||
|
||||
When kdump kernel boots in a live environment, the default target /var/crash is
|
||||
in RAM so you need to change the dump target to an external disk or a network
|
||||
dump target.
|
||||
|
||||
Besides, make sure that "default dump_to_rootfs" is not specified.
|
||||
|
||||
3. Start kdump service
|
||||
|
||||
$ kdumpctl start
|
||||
|
||||
4. Trigger a kdump test
|
||||
|
||||
$ echo 1 > /proc/sys/kernel/sysrq
|
||||
$ echo c > /proc/sysrq-trigger
|
452
SOURCES/mkdumprd
Normal file
452
SOURCES/mkdumprd
Normal file
@ -0,0 +1,452 @@
|
||||
#!/bin/bash --norc
|
||||
# New mkdumprd
|
||||
#
|
||||
# Copyright 2011 Red Hat, Inc.
|
||||
#
|
||||
# Written by Cong Wang <amwang@redhat.com>
|
||||
#
|
||||
|
||||
if [ -f /etc/sysconfig/kdump ]; then
|
||||
. /etc/sysconfig/kdump
|
||||
fi
|
||||
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||
. $dracutbasedir/dracut-functions.sh
|
||||
. /lib/kdump/kdump-lib.sh
|
||||
. /lib/kdump/kdump-logger.sh
|
||||
export IN_KDUMP=1
|
||||
|
||||
#initiate the kdump logger
|
||||
dlog_init
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "failed to initiate the kdump logger."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
conf_file="/etc/kdump.conf"
|
||||
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
|
||||
SAVE_PATH=$(get_save_path)
|
||||
OVERRIDE_RESETTABLE=0
|
||||
|
||||
extra_modules=""
|
||||
dracut_args="--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict --hostonly-nics '' -o \"plymouth dash resume ifcfg earlykdump\" --compress=xz"
|
||||
|
||||
readonly MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)"
|
||||
[ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed."
|
||||
readonly MKDUMPRD_TMPMNT="$MKDUMPRD_TMPDIR/target"
|
||||
|
||||
trap '
|
||||
ret=$?;
|
||||
is_mounted $MKDUMPRD_TMPMNT && umount -f $MKDUMPRD_TMPMNT;
|
||||
[[ -d $MKDUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKDUMPRD_TMPDIR";
|
||||
exit $ret;
|
||||
' EXIT
|
||||
|
||||
# clean up after ourselves no matter how we die.
|
||||
trap 'exit 1;' SIGINT
|
||||
|
||||
add_dracut_arg() {
|
||||
dracut_args="$dracut_args $@"
|
||||
}
|
||||
|
||||
add_dracut_mount() {
|
||||
add_dracut_arg "--mount" "\"$1\""
|
||||
}
|
||||
|
||||
add_dracut_sshkey() {
|
||||
add_dracut_arg "--sshkey" "\"$1\""
|
||||
}
|
||||
|
||||
# caller should ensure $1 is valid and mounted in 1st kernel
|
||||
to_mount() {
|
||||
local _target=$1 _fstype=$2 _options=$3 _new_mntpoint _pdev
|
||||
|
||||
_new_mntpoint=$(get_kdump_mntpoint_from_target $_target)
|
||||
_fstype="${_fstype:-$(get_fs_type_from_target $_target)}"
|
||||
_options="${_options:-$(get_mntopt_from_target $_target)}"
|
||||
_options="${_options:-defaults}"
|
||||
|
||||
if [[ "$_fstype" == "nfs"* ]]; then
|
||||
_pdev=$_target
|
||||
_options=$(echo $_options | sed 's/,\(mount\)\?addr=[^,]*//g')
|
||||
_options=$(echo $_options | sed 's/,\(mount\)\?proto=[^,]*//g')
|
||||
_options=$(echo $_options | sed 's/,clientaddr=[^,]*//')
|
||||
else
|
||||
# for non-nfs _target converting to use udev persistent name
|
||||
_pdev="$(kdump_get_persistent_dev $_target)"
|
||||
if [ -z "$_pdev" ]; then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
#mount fs target as rw in 2nd kernel
|
||||
_options=$(echo $_options | sed 's/\(^\|,\)ro\($\|,\)/\1rw\2/g')
|
||||
# with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd
|
||||
# kernel, filter it out here.
|
||||
_options=$(echo $_options | sed 's/\(^\|,\)noauto\($\|,\)/\1/g')
|
||||
# use both nofail and x-systemd.before to ensure systemd will try best to
|
||||
# mount it before kdump starts, this is an attempt to improve robustness
|
||||
_options="$_options,nofail,x-systemd.before=initrd-fs.target"
|
||||
|
||||
echo "$_pdev $_new_mntpoint $_fstype $_options"
|
||||
}
|
||||
|
||||
#Function: get_ssh_size
|
||||
#$1=dump target
|
||||
#called from while loop and shouldn't read from stdin, so we're using "ssh -n"
|
||||
get_ssh_size() {
|
||||
local _opt _out _size
|
||||
_opt="-i $SSH_KEY_LOCATION -o BatchMode=yes -o StrictHostKeyChecking=yes"
|
||||
_out=$(ssh -q -n $_opt $1 "df -P $SAVE_PATH")
|
||||
[ $? -ne 0 ] && {
|
||||
perror_exit "checking remote ssh server available size failed."
|
||||
}
|
||||
|
||||
#ssh output removed the line break, so print field NF-2
|
||||
_size=$(echo -n $_out| awk '{avail=NF-2; print $avail}')
|
||||
echo -n $_size
|
||||
}
|
||||
|
||||
#mkdir if save path does not exist on ssh dump target
|
||||
#$1=ssh dump target
|
||||
#caller should ensure write permission on $1:$SAVE_PATH
|
||||
#called from while loop and shouldn't read from stdin, so we're using "ssh -n"
|
||||
mkdir_save_path_ssh()
|
||||
{
|
||||
local _opt _dir
|
||||
_opt="-i $SSH_KEY_LOCATION -o BatchMode=yes -o StrictHostKeyChecking=yes"
|
||||
ssh -qn $_opt $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null
|
||||
_ret=$?
|
||||
if [ $_ret -ne 0 ]; then
|
||||
perror_exit "mkdir failed on $1:$SAVE_PATH"
|
||||
fi
|
||||
|
||||
#check whether user has write permission on $1:$SAVE_PATH
|
||||
_dir=$(ssh -qn $_opt $1 mktemp -dqp $SAVE_PATH 2>/dev/null)
|
||||
_ret=$?
|
||||
if [ $_ret -ne 0 ]; then
|
||||
perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination"
|
||||
fi
|
||||
ssh -qn $_opt $1 rmdir $_dir
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#Function: get_fs_size
|
||||
#$1=dump target
|
||||
get_fs_size() {
|
||||
local _mnt=$(get_mntpoint_from_target $1)
|
||||
echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
|
||||
}
|
||||
|
||||
#Function: get_raw_size
|
||||
#$1=dump target
|
||||
get_raw_size() {
|
||||
echo -n $(fdisk -s "$1")
|
||||
}
|
||||
|
||||
#Function: check_size
|
||||
#$1: dump type string ('raw', 'fs', 'ssh')
|
||||
#$2: dump target
|
||||
check_size() {
|
||||
local avail memtotal
|
||||
|
||||
memtotal=$(awk '/MemTotal/{print $2}' /proc/meminfo)
|
||||
case "$1" in
|
||||
raw)
|
||||
avail=$(get_raw_size "$2")
|
||||
;;
|
||||
ssh)
|
||||
avail=$(get_ssh_size "$2")
|
||||
;;
|
||||
fs)
|
||||
avail=$(get_fs_size "$2")
|
||||
;;
|
||||
*)
|
||||
return
|
||||
esac
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
perror_exit "Check dump target size failed"
|
||||
fi
|
||||
|
||||
if [ $avail -lt $memtotal ]; then
|
||||
dwarn "Warning: There might not be enough space to save a vmcore."
|
||||
dwarn " The size of $2 should be greater than $memtotal kilo bytes."
|
||||
fi
|
||||
}
|
||||
|
||||
check_save_path_fs()
|
||||
{
|
||||
local _path=$1
|
||||
|
||||
if [ ! -d $_path ]; then
|
||||
perror_exit "Dump path $_path does not exist."
|
||||
fi
|
||||
}
|
||||
|
||||
check_user_configured_target()
|
||||
{
|
||||
local _target=$1 _cfg_fs_type=$2 _mounted
|
||||
local _mnt=$(get_mntpoint_from_target $_target)
|
||||
local _opt=$(get_mntopt_from_target $_target)
|
||||
local _fstype=$(get_fs_type_from_target $_target)
|
||||
|
||||
if [ -n "$_fstype" ]; then
|
||||
# In case of nfs4, nfs should be used instead, nfs* options is deprecated in kdump.conf
|
||||
[[ $_fstype = "nfs"* ]] && _fstype=nfs
|
||||
|
||||
if [ -n "$_cfg_fs_type" ] && [ "$_fstype" != "$_cfg_fs_type" ]; then
|
||||
perror_exit "\"$_target\" have a wrong type config \"$_cfg_fs_type\", expected \"$_fstype\""
|
||||
fi
|
||||
else
|
||||
_fstype="$_cfg_fs_type"
|
||||
_fstype="$_cfg_fs_type"
|
||||
fi
|
||||
|
||||
# For noauto mount, mount it inplace with default value.
|
||||
# Else use the temporary target directory
|
||||
if [ -n "$_mnt" ]; then
|
||||
if ! is_mounted "$_mnt"; then
|
||||
if [[ $_opt = *",noauto"* ]]; then
|
||||
mount $_mnt
|
||||
[ $? -ne 0 ] && perror_exit "Failed to mount $_target on $_mnt for kdump preflight check."
|
||||
_mounted=$_mnt
|
||||
else
|
||||
perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\""
|
||||
fi
|
||||
fi
|
||||
else
|
||||
_mnt=$MKDUMPRD_TMPMNT
|
||||
mkdir -p $_mnt
|
||||
mount $_target $_mnt -t $_fstype -o defaults
|
||||
[ $? -ne 0 ] && perror_exit "Failed to mount $_target for kdump preflight check."
|
||||
_mounted=$_mnt
|
||||
fi
|
||||
|
||||
# For user configured target, use $SAVE_PATH as the dump path within the target
|
||||
if [ ! -d "$_mnt/$SAVE_PATH" ]; then
|
||||
perror_exit "Dump path \"$SAVE_PATH\" does not exist in dump target \"$_target\""
|
||||
fi
|
||||
|
||||
check_size fs "$_target"
|
||||
|
||||
# Unmount it early, if function is interrupted and didn't reach here, the shell trap will clear it up anyway
|
||||
if [ -n "$_mounted" ]; then
|
||||
umount -f -- $_mounted
|
||||
fi
|
||||
}
|
||||
|
||||
# $1: core_collector config value
|
||||
verify_core_collector() {
|
||||
local _cmd="${1%% *}"
|
||||
local _params="${1#${_cmd}}"
|
||||
|
||||
if [ "$_cmd" != "makedumpfile" ]; then
|
||||
if is_raw_dump_target; then
|
||||
dwarn "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
if is_ssh_dump_target || is_raw_dump_target; then
|
||||
if ! strstr "$_params" "-F"; then
|
||||
perror_exit "The specified dump target needs makedumpfile \"-F\" option."
|
||||
fi
|
||||
_params="$_params vmcore"
|
||||
else
|
||||
_params="$_params vmcore dumpfile"
|
||||
fi
|
||||
|
||||
if ! $_cmd --check-params $_params; then
|
||||
perror_exit "makedumpfile parameter check failed."
|
||||
fi
|
||||
}
|
||||
|
||||
add_mount() {
|
||||
local _mnt=$(to_mount $@)
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
add_dracut_mount "$_mnt"
|
||||
}
|
||||
|
||||
#handle the case user does not specify the dump target explicitly
|
||||
handle_default_dump_target()
|
||||
{
|
||||
local _target
|
||||
local _mntpoint
|
||||
|
||||
is_user_configured_dump_target && return
|
||||
|
||||
check_save_path_fs $SAVE_PATH
|
||||
|
||||
_save_path=$(get_bind_mount_source $SAVE_PATH)
|
||||
_target=$(get_target_from_path $_save_path)
|
||||
_mntpoint=$(get_mntpoint_from_target $_target)
|
||||
|
||||
SAVE_PATH=${_save_path##"$_mntpoint"}
|
||||
add_mount "$_target"
|
||||
check_size fs $_target
|
||||
}
|
||||
|
||||
get_override_resettable()
|
||||
{
|
||||
local override_resettable
|
||||
|
||||
override_resettable=$(grep "^override_resettable" $conf_file)
|
||||
if [ -n "$override_resettable" ]; then
|
||||
OVERRIDE_RESETTABLE=$(echo $override_resettable | cut -d' ' -f2)
|
||||
if [ "$OVERRIDE_RESETTABLE" != "0" ] && [ "$OVERRIDE_RESETTABLE" != "1" ];then
|
||||
perror_exit "override_resettable value $OVERRIDE_RESETTABLE is invalid"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# $1: function name
|
||||
for_each_block_target()
|
||||
{
|
||||
local dev majmin
|
||||
|
||||
for dev in $(get_kdump_targets); do
|
||||
[ -b "$dev" ] || continue
|
||||
majmin=$(get_maj_min $dev)
|
||||
check_block_and_slaves $1 $majmin && return 1
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#judge if a specific device with $1 is unresettable
|
||||
#return false if unresettable.
|
||||
is_unresettable()
|
||||
{
|
||||
local path="/sys/$(udevadm info --query=all --path=/sys/dev/block/$1 | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable"
|
||||
local resettable=1
|
||||
|
||||
if [ -f "$path" ]
|
||||
then
|
||||
resettable="$(cat $path)"
|
||||
[ $resettable -eq 0 -a "$OVERRIDE_RESETTABLE" -eq 0 ] && {
|
||||
local device=$(udevadm info --query=all --path=/sys/dev/block/$1 | awk -F= '/DEVNAME/{print $2}')
|
||||
derror "Error: Can not save vmcore because device $device is unresettable"
|
||||
return 0
|
||||
}
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
#check if machine is resettable.
|
||||
#return true if resettable
|
||||
check_resettable()
|
||||
{
|
||||
local _ret _target
|
||||
|
||||
get_override_resettable
|
||||
|
||||
for_each_block_target is_unresettable
|
||||
_ret=$?
|
||||
|
||||
[ $_ret -eq 0 ] && return
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
check_crypt()
|
||||
{
|
||||
local _dev
|
||||
|
||||
for _dev in $(get_kdump_targets); do
|
||||
if [[ -n $(get_luks_crypt_dev "$(get_maj_min "$_dev")") ]]; then
|
||||
derror "Device $_dev is encrypted." && return 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if ! check_resettable; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! check_crypt; then
|
||||
dwarn "Warning: Encrypted device is in dump path. User will prompted for password during second kernel boot."
|
||||
fi
|
||||
|
||||
# firstly get right SSH_KEY_LOCATION
|
||||
keyfile=$(awk '/^sshkey/ {print $2}' $conf_file)
|
||||
if [ -f "$keyfile" ]; then
|
||||
# canonicalize the path
|
||||
SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile)
|
||||
fi
|
||||
|
||||
while read config_opt config_val;
|
||||
do
|
||||
# remove inline comments after the end of a directive.
|
||||
case "$config_opt" in
|
||||
extra_modules)
|
||||
extra_modules="$extra_modules $config_val"
|
||||
;;
|
||||
ext[234]|xfs|btrfs|minix|nfs)
|
||||
check_user_configured_target "$config_val" "$config_opt"
|
||||
add_mount "$config_val" "$config_opt"
|
||||
;;
|
||||
raw)
|
||||
# checking raw disk writable
|
||||
dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || {
|
||||
perror_exit "Bad raw disk $config_val"
|
||||
}
|
||||
_praw=$(persistent_policy="by-id" kdump_get_persistent_dev $config_val)
|
||||
if [ -z "$_praw" ]; then
|
||||
exit 1
|
||||
fi
|
||||
add_dracut_arg "--device" "$_praw"
|
||||
check_size raw $config_val
|
||||
;;
|
||||
ssh)
|
||||
if strstr "$config_val" "@";
|
||||
then
|
||||
mkdir_save_path_ssh $config_val
|
||||
check_size ssh $config_val
|
||||
add_dracut_sshkey "$SSH_KEY_LOCATION"
|
||||
else
|
||||
perror_exit "Bad ssh dump target $config_val"
|
||||
fi
|
||||
;;
|
||||
core_collector)
|
||||
verify_core_collector "$config_val"
|
||||
;;
|
||||
dracut_args)
|
||||
add_dracut_arg $config_val
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done <<< "$(read_strip_comments $conf_file)"
|
||||
|
||||
handle_default_dump_target
|
||||
|
||||
if [ -n "$extra_modules" ]
|
||||
then
|
||||
add_dracut_arg "--add-drivers" \"$extra_modules\"
|
||||
fi
|
||||
|
||||
# TODO: The below check is not needed anymore with the introduction of
|
||||
# 'zz-fadumpinit' module, that isolates fadump's capture kernel initrd,
|
||||
# but still sysroot.mount unit gets generated based on 'root=' kernel
|
||||
# parameter available in fadump case. So, find a way to fix that first
|
||||
# before removing this check.
|
||||
if ! is_fadump_capable; then
|
||||
# The 2nd rootfs mount stays behind the normal dump target mount,
|
||||
# so it doesn't affect the logic of check_dump_fs_modified().
|
||||
is_dump_to_rootfs && add_mount "$(to_dev_name $(get_root_fs_device))"
|
||||
|
||||
add_dracut_arg "--no-hostonly-default-device"
|
||||
|
||||
if fips-mode-setup --is-enabled 2> /dev/null; then
|
||||
add_dracut_arg --add-device "$(findmnt -n -o SOURCE --target /boot)"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$dracut_args $@" | xargs dracut
|
39
SOURCES/mkdumprd.8
Normal file
39
SOURCES/mkdumprd.8
Normal file
@ -0,0 +1,39 @@
|
||||
.TH MKDUMRD 8 "Fri Feb 9 2007"
|
||||
.SH NAME
|
||||
mkdumprd \- creates initial ramdisk images for kdump crash recovery
|
||||
.SH SYNOPSIS
|
||||
\fBmkdumprd\fR [OPTION]
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBmkdumprd\fR creates an initial ram file system for use in conjunction with
|
||||
the booting of a kernel within the kdump framework for crash recovery.
|
||||
\fBmkdumprds\fR purpose is to create an initial ram filesystem capable of copying
|
||||
the crashed systems vmcore image to a location specified in \fI/etc/kdump.conf
|
||||
|
||||
\fBmkdumprd\fR interrogates the running system to understand what modules need to
|
||||
be loaded in the initramfs (based on configuration retrieved from
|
||||
\fI/etc/kdump.conf)\fR
|
||||
|
||||
\fBmkdumprd\fR add a new \fBdracut\fR module 99kdumpbase and use \fBdracut\fR
|
||||
utility to generate the initramfs. When generating a kdump initramfs, \fBmkdumprd\fR
|
||||
will determine how much disk space is available, if the dump target's available
|
||||
space is not greater than the total system memory, \fBmkdumprd\fR will print a
|
||||
warning to remind that there might not be enough space to save a vmcore. The
|
||||
warning covers extreme scenarios such as the slab explodes with non-zero data or
|
||||
a full vmcore, etc. Therefore, need to prevent users from having minimum disk
|
||||
space for crash dump.
|
||||
|
||||
\fBmkdumprd\fR was not intended for casual use outside of the service
|
||||
initialization script for the kdump utility, and should not be run manually. If
|
||||
you require a custom kdump initramfs image, it is suggested that you use the
|
||||
kdump service infrastructure to create one, and then manually unpack, modify and
|
||||
repack the image.
|
||||
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
All options here are passed to dracut directly, please refer \fBdracut\fR docs
|
||||
for the info.
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.BR dracut (8)
|
64
SOURCES/mkfadumprd
Normal file
64
SOURCES/mkfadumprd
Normal file
@ -0,0 +1,64 @@
|
||||
#!/bin/bash --norc
|
||||
# Generate an initramfs image that isolates dump capture capability within
|
||||
# the default initramfs using zz-fadumpinit dracut module.
|
||||
|
||||
if [ -f /etc/sysconfig/kdump ]; then
|
||||
. /etc/sysconfig/kdump
|
||||
fi
|
||||
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||
. $dracutbasedir/dracut-functions.sh
|
||||
. /lib/kdump/kdump-lib.sh
|
||||
. /lib/kdump/kdump-logger.sh
|
||||
|
||||
#initiate the kdump logger
|
||||
if ! dlog_init; then
|
||||
echo "mkfadumprd: failed to initiate the kdump logger."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
readonly MKFADUMPRD_TMPDIR="$(mktemp -d -t mkfadumprd.XXXXXX)"
|
||||
[ -d "$MKFADUMPRD_TMPDIR" ] || perror_exit "mkfadumprd: mktemp -d -t mkfadumprd.XXXXXX failed."
|
||||
trap '
|
||||
ret=$?;
|
||||
[[ -d $MKFADUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKFADUMPRD_TMPDIR";
|
||||
exit $ret;
|
||||
' EXIT
|
||||
|
||||
# clean up after ourselves no matter how we die.
|
||||
trap 'exit 1;' SIGINT
|
||||
|
||||
MKDUMPRD="/sbin/mkdumprd -f"
|
||||
# Default boot initramfs to be rebuilt
|
||||
REBUILD_INITRD="$1" && shift
|
||||
TARGET_INITRD="$1" && shift
|
||||
FADUMP_INITRD="$MKFADUMPRD_TMPDIR/fadump.img"
|
||||
|
||||
### First build an initramfs with dump capture capability
|
||||
# this file tells the initrd is fadump enabled
|
||||
touch "$MKFADUMPRD_TMPDIR/fadump.initramfs"
|
||||
ddebug "rebuild fadump initrd: $FADUMP_INITRD $DEFAULT_INITRD $KDUMP_KERNELVER"
|
||||
if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs; then
|
||||
perror_exit "mkfadumprd: failed to build image with dump capture support"
|
||||
fi
|
||||
|
||||
### Unpack the initramfs having dump capture capability
|
||||
mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot"
|
||||
if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$FADUMP_INITRD" && \
|
||||
popd > /dev/null); then
|
||||
derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Pack it into the normal boot initramfs with zz-fadumpinit module
|
||||
_dracut_isolate_args="--rebuild $REBUILD_INITRD --add zz-fadumpinit \
|
||||
-i $MKFADUMPRD_TMPDIR/fadumproot /fadumproot \
|
||||
-i $MKFADUMPRD_TMPDIR/fadumproot/usr/lib/dracut/loaded-kernel-modules.txt
|
||||
/usr/lib/dracut/fadump-kernel-modules.txt"
|
||||
|
||||
if is_squash_available; then
|
||||
_dracut_isolate_args="$_dracut_isolate_args --add squash"
|
||||
fi
|
||||
if ! dracut --force --quiet $_dracut_isolate_args $@ "$TARGET_INITRD"; then
|
||||
perror_exit "mkfadumprd: failed to setup '$TARGET_INITRD' with dump capture capability"
|
||||
fi
|
@ -0,0 +1,13 @@
|
||||
diff --git a/purgatory/Makefile b/purgatory/Makefile
|
||||
index 49ce80a..97b7a03 100644
|
||||
--- a/purgatory/Makefile
|
||||
+++ b/purgatory/Makefile
|
||||
@@ -67,7 +67,7 @@ $(PURGATORY): $(PURGATORY_OBJS)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@.sym $^
|
||||
# $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB)
|
||||
- $(STRIP) --strip-debug -o $@ $@.sym
|
||||
+ $(STRIP) --strip-debug --no-merge-notes -o $@ $@.sym
|
||||
|
||||
echo::
|
||||
@echo "PURGATORY_SRCS $(PURGATORY_SRCS)"
|
@ -0,0 +1,51 @@
|
||||
From ce720608d5933e62f77f2c2f216859cf4f06adf8 Mon Sep 17 00:00:00 2001
|
||||
From: Kairui Song <kasong@redhat.com>
|
||||
Date: Wed, 13 Feb 2019 00:03:51 +0800
|
||||
Subject: [PATCH] Fix eppic issue with hardening flags
|
||||
|
||||
This is stash of two commits:
|
||||
|
||||
commit f98cf5fe07f390554696755f0a5843f6bb9c4716
|
||||
Author: ryncsn <ryncsn@gmail.com>
|
||||
Date: Tue Mar 19 13:39:25 2019 +0800
|
||||
|
||||
Tell gcc not to omit frame pointer
|
||||
|
||||
After commit 0209874, it's now possible to enable optimization above O0.
|
||||
But eppic might call __builtin_return_address(1). With O1,
|
||||
-fomit-frame-pointer is enabled gcc may omit frame pointer.
|
||||
__builtin_return_address(1) relies on callee preserves RBP as the stack
|
||||
base, which is untrue if optimization is usded. In this case it may return
|
||||
wrong value or crash.
|
||||
|
||||
In case of any potential failure, use -fno-omit-frame-pointer globally.
|
||||
|
||||
Signed-off-by: Kairui Song <ryncsn@gmail.com>
|
||||
|
||||
commit 0209874f4b46b8af5a2d42662ba6775cf5a1dc44
|
||||
Author: Kairui Song <kasong@redhat.com>
|
||||
Date: Wed Feb 13 00:03:51 2019 +0800
|
||||
|
||||
Drop O0 CFLAGS override in Makefile
|
||||
|
||||
Signed-off-by: Kairui Song <kasong@redhat.com>
|
||||
---
|
||||
libeppic/Makefile | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libeppic/Makefile b/libeppic/Makefile
|
||||
index bcf2edf..8b97c87 100644
|
||||
--- a/eppic/libeppic/Makefile
|
||||
+++ b/eppic/libeppic/Makefile
|
||||
@@ -24,7 +24,7 @@ LDIRT = lex.eppic.c lex.eppicpp.c eppic.tab.c eppic.tab.h eppicpp.tab.c \
|
||||
LIBDIR = /usr/lib
|
||||
TARGETS = libeppic.a
|
||||
|
||||
-CFLAGS += -O0 -g -fPIC
|
||||
+CFLAGS += -g -fno-omit-frame-pointer -fPIC
|
||||
ifeq ($(TARGET), PPC64)
|
||||
CFLAGS += -m64
|
||||
endif
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,88 @@
|
||||
From 0f632fa180e5a44219ab6bbe0879c3583f8c65cf Mon Sep 17 00:00:00 2001
|
||||
From: Pingfan Liu <piliu@redhat.com>
|
||||
Date: Tue, 9 Nov 2021 11:24:22 +0800
|
||||
Subject: [PATCH] RHEL-only
|
||||
|
||||
Cope with RHEL8 kernel
|
||||
|
||||
Signed-off-by: Pingfan Liu <piliu@redhat.com>
|
||||
---
|
||||
arch/arm64.c | 14 +++++++++++++-
|
||||
makedumpfile.c | 2 ++
|
||||
makedumpfile.h | 1 +
|
||||
3 files changed, 16 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/makedumpfile-1.7.2/arch/arm64.c b/makedumpfile-1.7.2/arch/arm64.c
|
||||
index 1072178..95beae6 100644
|
||||
--- a/makedumpfile-1.7.2/arch/arm64.c
|
||||
+++ b/makedumpfile-1.7.2/arch/arm64.c
|
||||
@@ -50,6 +50,7 @@ static int va_bits;
|
||||
static int vabits_actual;
|
||||
static int flipped_va;
|
||||
static unsigned long kimage_voffset;
|
||||
+static int max_user_va_bits;
|
||||
|
||||
#define SZ_4K 4096
|
||||
#define SZ_16K 16384
|
||||
@@ -108,7 +109,7 @@ typedef unsigned long pgdval_t;
|
||||
#define PGDIR_SHIFT ARM64_HW_PGTABLE_LEVEL_SHIFT(4 - (pgtable_level))
|
||||
#define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT)
|
||||
#define PGDIR_MASK (~(PGDIR_SIZE-1))
|
||||
-#define PTRS_PER_PGD (1 << ((va_bits) - PGDIR_SHIFT))
|
||||
+#define PTRS_PER_PGD (1 << ((max_user_va_bits) - PGDIR_SHIFT))
|
||||
|
||||
/*
|
||||
* Section address mask and size definitions.
|
||||
@@ -449,6 +450,17 @@ get_machdep_info_arm64(void)
|
||||
ERRMSG("Can't determine platform config values\n");
|
||||
return FALSE;
|
||||
}
|
||||
+ if (NUMBER(MAX_USER_VA_BITS) != NOT_FOUND_NUMBER) {
|
||||
+ max_user_va_bits = NUMBER(MAX_USER_VA_BITS);
|
||||
+ DEBUG_MSG("max_user_va_bits : %d (vmcoreinfo)\n",
|
||||
+ max_user_va_bits);
|
||||
+ }
|
||||
+ if (!max_user_va_bits) {
|
||||
+ max_user_va_bits = va_bits;
|
||||
+ DEBUG_MSG("max_user_va_bits : %d (default = va_bits)\n",
|
||||
+ max_user_va_bits);
|
||||
+ }
|
||||
+
|
||||
|
||||
kimage_voffset = NUMBER(kimage_voffset);
|
||||
info->section_size_bits = SECTIONS_SIZE_BITS;
|
||||
diff --git a/makedumpfile-1.7.2/makedumpfile.c b/makedumpfile-1.7.2/makedumpfile.c
|
||||
index 3ad4443..018ea4c 100644
|
||||
--- a/makedumpfile-1.7.2/makedumpfile.c
|
||||
+++ b/makedumpfile-1.7.2/makedumpfile.c
|
||||
@@ -2417,6 +2417,7 @@ write_vmcoreinfo_data(void)
|
||||
|
||||
WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
|
||||
#ifdef __aarch64__
|
||||
+ WRITE_NUMBER("MAX_USER_VA_BITS", MAX_USER_VA_BITS);
|
||||
WRITE_NUMBER("VA_BITS", VA_BITS);
|
||||
/* WRITE_NUMBER("TCR_EL1_T1SZ", TCR_EL1_T1SZ); should not exists */
|
||||
WRITE_NUMBER_UNSIGNED("PHYS_OFFSET", PHYS_OFFSET);
|
||||
@@ -2863,6 +2864,7 @@ read_vmcoreinfo(void)
|
||||
READ_NUMBER("phys_base", phys_base);
|
||||
READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
|
||||
#ifdef __aarch64__
|
||||
+ READ_NUMBER("MAX_USER_VA_BITS", MAX_USER_VA_BITS);
|
||||
READ_NUMBER("VA_BITS", VA_BITS);
|
||||
READ_NUMBER("TCR_EL1_T1SZ", TCR_EL1_T1SZ);
|
||||
READ_NUMBER_UNSIGNED("PHYS_OFFSET", PHYS_OFFSET);
|
||||
diff --git a/makedumpfile-1.7.2/makedumpfile.h b/makedumpfile-1.7.2/makedumpfile.h
|
||||
index e59239d..b6236dd 100644
|
||||
--- a/makedumpfile-1.7.2/makedumpfile.h
|
||||
+++ b/makedumpfile-1.7.2/makedumpfile.h
|
||||
@@ -2064,6 +2064,7 @@ struct number_table {
|
||||
long phys_base;
|
||||
long KERNEL_IMAGE_SIZE;
|
||||
#ifdef __aarch64__
|
||||
+ long MAX_USER_VA_BITS;
|
||||
long VA_BITS;
|
||||
long TCR_EL1_T1SZ;
|
||||
unsigned long PHYS_OFFSET;
|
||||
--
|
||||
2.31.1
|
||||
|
128
SOURCES/supported-kdump-targets.txt
Normal file
128
SOURCES/supported-kdump-targets.txt
Normal file
@ -0,0 +1,128 @@
|
||||
Supported Kdump Targets
|
||||
|
||||
This document try to list all supported kdump targets, and those supported
|
||||
or unknown/tech-preview targets, this can help users to decide whether a dump
|
||||
solution is available.
|
||||
|
||||
Dump Target support status
|
||||
==========================
|
||||
This section tries to come up with some kind of guidelines in terms of
|
||||
what dump targets are supported/not supported. Whatever is listed here
|
||||
is not binding in any manner. It is just sharing of current understanding
|
||||
and if something is not right, this section needs to be edited.
|
||||
|
||||
Following are 3 lists. First one contains supported targets. These are
|
||||
generic configurations which should work and some configuration most
|
||||
likely has worked in testing. Second list is known unsupported targets.
|
||||
These targets we know either don't work or we don't support. And third
|
||||
list is unknown/tech-preview. We either don't yet know the status of kdump
|
||||
on these targets or these are under tech-preview.
|
||||
|
||||
Note, these lists are not set in stone and can be changed at any point of
|
||||
time. Also these lists might not be complete. We will add/remove items to
|
||||
it as we get more testing information. Also, there are many corner cases
|
||||
which can't possibly be listed. For example in general we might be
|
||||
supporting software iscsi but there might be some configurations of it
|
||||
which don't work.
|
||||
|
||||
So if any target is listed in supported section, it does not mean it works
|
||||
in all possible configurations. It just means that in common configurations
|
||||
it should work but there can be issues with particular configurations which
|
||||
are not supported. As we come to know of particular issues, we will keep on
|
||||
updating lists accordingly.
|
||||
|
||||
|
||||
Supported Dump targets
|
||||
----------------------
|
||||
storage:
|
||||
LVM volume
|
||||
Thin provisioning volume
|
||||
FC disks (qla2xxx, lpfc, bnx2fc, bfa)
|
||||
software initiator based iSCSI
|
||||
software RAID (mdraid)
|
||||
hardware RAID (cciss, hpsa, megaraid_sas, mpt2sas, aacraid)
|
||||
SCSI/SATA disks
|
||||
iSCSI HBA (all offload)
|
||||
hardware FCoE (qla2xxx, lpfc)
|
||||
software FCoE (bnx2fc) (Extra configuration required,
|
||||
please read "Note on FCoE" section below)
|
||||
|
||||
network:
|
||||
Hardware using kernel modules: (tg3, igb, ixgbe, sfc, e1000e, bna,
|
||||
cnic, netxen_nic, qlge, bnx2x, bnx, qlcnic, be2net, enic,
|
||||
virtio-net, ixgbevf, igbvf)
|
||||
protocol: ipv4
|
||||
bonding
|
||||
vlan
|
||||
bridge
|
||||
team
|
||||
vlan tagged bonding
|
||||
bridge over bond/team/vlan
|
||||
|
||||
hypervisor:
|
||||
kvm
|
||||
xen (Supported in select configurations only)
|
||||
|
||||
filesystem:
|
||||
ext[234]
|
||||
xfs
|
||||
nfs
|
||||
|
||||
firmware:
|
||||
BIOS
|
||||
UEFI
|
||||
|
||||
hypervisor:
|
||||
VMWare ESXi 4.1 and 5.1
|
||||
Hyper-V 2012 R2 (RHEL Gen1 UP Guest only)
|
||||
|
||||
Unsupported Dump targets
|
||||
------------------------
|
||||
storage:
|
||||
BIOS RAID
|
||||
Software iSCSI with iBFT (bnx2i, cxgb3i, cxgb4i)
|
||||
Software iSCSI with hybrid (be2iscsi)
|
||||
FCoE
|
||||
legacy IDE
|
||||
glusterfs
|
||||
gfs2/clvm/halvm
|
||||
|
||||
network:
|
||||
hardware using kernel modules: (sfc SRIOV, cxgb4vf, pch_gbe)
|
||||
protocol: ipv6
|
||||
wireless
|
||||
Infiniband (IB)
|
||||
vlan over bridge/team
|
||||
|
||||
filesystem:
|
||||
btrfs
|
||||
|
||||
Unknown/tech-preview
|
||||
--------------------
|
||||
storage:
|
||||
PCI Express based SSDs
|
||||
|
||||
hypervisor:
|
||||
Hyper-V 2008
|
||||
Hyper-V 2012
|
||||
|
||||
|
||||
Note on FCoE
|
||||
=====================
|
||||
If you are trying to dump to a software FCoE target, you may encounter OOM
|
||||
issue, because some software FCoE requires more memory to work. In such case,
|
||||
you may need to increase the kdump reserved memory size in "crashkernel="
|
||||
kernel parameter.
|
||||
|
||||
By default, RHEL systems have "crashkernel=auto" in kernel boot arguments.
|
||||
The auto reserved memory size is designed to balance the coverage of use cases
|
||||
and an acceptable memory overhead, so not every use case could fit in, software
|
||||
FCoE is one of the case.
|
||||
|
||||
For hardware FCoE, kdump should work naturally as firmware will do the
|
||||
initialization job. The capture kernel and kdump tools will run just fine.
|
||||
|
||||
Useful Links
|
||||
============
|
||||
[1] RHEL6: Enabling kdump for full-virt (HVM) Xen DomU
|
||||
(https://access.redhat.com/knowledge/solutions/92943)
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +0,0 @@
|
||||
--- !Policy
|
||||
product_versions:
|
||||
- rhel-10
|
||||
decision_context: osci_compose_gate
|
||||
rules:
|
||||
- !PassingTestCaseRule {test_case_name: kernel-qe.kernel-ci.general-kdump.tier0.functional}
|
1
sources
1
sources
@ -1 +0,0 @@
|
||||
SHA512 (kexec-tools-2.0.29.tar.xz) = 4c9e0b3df47b240f0eac2c31e8b515465f626ce043f64daa32b0b032d7132e54dada5d70875dab256345f66cf94a25dc3c160a9009ba60addd8dcb1e5205f5ca
|
@ -1,41 +0,0 @@
|
||||
#!/bin/bash
|
||||
Describe 'kdump-lib-initramfs'
|
||||
Include ./kdump-lib-initramfs.sh
|
||||
|
||||
Describe 'Test kdump_get_conf_val'
|
||||
KDUMP_CONFIG_FILE=/tmp/kdump_shellspec_test.conf
|
||||
kdump_config() {
|
||||
%text
|
||||
#|default shell
|
||||
#|nfs my.server.com:/export/tmp # trailing comment
|
||||
#| failure_action shell
|
||||
#|dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"
|
||||
#|sshkey /root/.ssh/kdump_id_rsa
|
||||
#|ssh user@my.server.com
|
||||
}
|
||||
kdump_config >$KDUMP_CONFIG_FILE
|
||||
Context 'Given different cases'
|
||||
# Test the following cases:
|
||||
# - there is trailing comment
|
||||
# - there is space before the parameter
|
||||
# - complicate value for dracut_args
|
||||
# - Given two parameters, retrive one parameter that has value specified
|
||||
# - Given two parameters (in reverse order), retrive one parameter that has value specified
|
||||
Parameters
|
||||
"#1" nfs my.server.com:/export/tmp
|
||||
"#2" ssh user@my.server.com
|
||||
"#3" failure_action shell
|
||||
"#4" dracut_args '--omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"'
|
||||
"#5" 'ssh\|aaa' user@my.server.com
|
||||
"#6" 'aaa\|ssh' user@my.server.com
|
||||
End
|
||||
|
||||
It 'should handle all cases correctly'
|
||||
When call kdump_get_conf_val "$2"
|
||||
The output should equal "$3"
|
||||
End
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
End
|
@ -1,121 +0,0 @@
|
||||
#!/bin/bash
|
||||
Describe 'kdump-lib'
|
||||
Include ./kdump-lib.sh
|
||||
|
||||
Describe 'get_system_size()'
|
||||
|
||||
PROC_IOMEM=$(mktemp -t spec_test_proc_iomem_file.XXXXXXXXXX)
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$PROC_IOMEM"
|
||||
}
|
||||
|
||||
AfterAll 'cleanup'
|
||||
|
||||
ONE_GIGABYTE='000000-3fffffff : System RAM'
|
||||
Parameters
|
||||
1
|
||||
3
|
||||
End
|
||||
|
||||
It 'should return correct system RAM size'
|
||||
echo -n >"$PROC_IOMEM"
|
||||
for _ in $(seq 1 "$1"); do echo "$ONE_GIGABYTE" >>"$PROC_IOMEM"; done
|
||||
When call get_system_size
|
||||
The output should equal "$1"
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe 'get_recommend_size()'
|
||||
# Testing stragety:
|
||||
# 1. inclusive for the lower bound of the range of crashkernel
|
||||
# 2. exclusive for the upper bound of the range of crashkernel
|
||||
# 3. supports ranges not sorted in increasing order
|
||||
|
||||
ck="4G-64G:256M,2G-4G:192M,64G-1T:512M,1T-:12345M"
|
||||
Parameters
|
||||
1 0M
|
||||
2 192M
|
||||
64 512M
|
||||
1024 12345M
|
||||
"$((64 * 1024))" 12345M
|
||||
End
|
||||
|
||||
It 'should handle all cases correctly'
|
||||
When call get_recommend_size "$1" $ck
|
||||
The output should equal "$2"
|
||||
End
|
||||
End
|
||||
|
||||
Describe "_crashkernel_add()"
|
||||
Context "For valid input values"
|
||||
Parameters
|
||||
"1G-4G:256M,4G-64G:320M,64G-:576M" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M"
|
||||
"1G-4G:256M" "100" "1G-4G:268435556" # avoids any rounding when size % 1024 != 0
|
||||
"1G-4G:256M,4G-64G:320M,64G-:576M@4G" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M@4G"
|
||||
"1G-4G:1G,4G-64G:2G,64G-:3G@4G" "100M" "1G-4G:1124M,4G-64G:2148M,64G-:3172M@4G"
|
||||
"1G-4G:10000K,4G-64G:20000K,64G-:40000K@4G" "100M" "1G-4G:112400K,4G-64G:122400K,64G-:142400K@4G"
|
||||
"1,high" "1" "2,high"
|
||||
"1K,low" "1" "1025,low"
|
||||
"128G-1T:4G" "0" "128G-1T:4G"
|
||||
"10T-100T:1T" "0" "10T-100T:1T"
|
||||
"128G-1T:4G" "0M" "128G-1T:4G"
|
||||
"128G-1P:4G" "0M" "128G-1P:4G"
|
||||
"128G-1E:4G" "0M" "128G-1E:4G"
|
||||
"1M@1G" "1k" "1025K@1G"
|
||||
"500M@1G" "-100m" "400M@1G"
|
||||
"1099511627776" "0" "1T"
|
||||
End
|
||||
It "should add delta to every value after ':'"
|
||||
When call _crashkernel_add "$1" "$2"
|
||||
The output should equal "$3"
|
||||
End
|
||||
End
|
||||
Context "For invalid input values"
|
||||
Parameters
|
||||
"1G-4G:256M.4G-64G:320M" "100M"
|
||||
"foo" "1"
|
||||
"1" "bar"
|
||||
End
|
||||
It "shall return an error"
|
||||
When call _crashkernel_add "$1" "$2"
|
||||
The output should equal ""
|
||||
The status should be failure
|
||||
End
|
||||
End
|
||||
End
|
||||
|
||||
Describe 'prepare_cmdline()'
|
||||
get_bootcpu_apicid() {
|
||||
echo 1
|
||||
}
|
||||
|
||||
get_watchdog_drvs() {
|
||||
echo foo
|
||||
}
|
||||
|
||||
add="disable_cpu_apicid=1 foo.pretimeout=0"
|
||||
|
||||
Parameters
|
||||
#test cmdline remove add result
|
||||
"#1" "a b c" "" "" "a b c"
|
||||
"#2" "a b c" "b" "" "a c"
|
||||
"#3" "a b=x c" "b" "" "a c"
|
||||
"#4" "a b='x y' c" "b" "" "a c"
|
||||
"#5" "a b='x y' c" "b=x" "" "a c"
|
||||
"#6" "a b='x y' c" "b='x y'" "" "a c"
|
||||
"#7" "a b c" "" "x" "a b c x"
|
||||
"#8" "a b c" "" "x=1" "a b c x=1"
|
||||
"#9" "a b c" "" "x='1 2'" "a b c x='1 2'"
|
||||
"#10" "a b c" "a" "x='1 2'" "b c x='1 2'"
|
||||
"#11" "a b c" "x" "x='1 2'" "a b c x='1 2'"
|
||||
End
|
||||
|
||||
It "Test $1: should generate the correct kernel command line"
|
||||
When call prepare_cmdline "$2" "$3" "$4"
|
||||
The output should equal "$5 $add"
|
||||
End
|
||||
End
|
||||
|
||||
End
|
@ -1,215 +0,0 @@
|
||||
#!/bin/bash
|
||||
Describe 'kdumpctl'
|
||||
Include ./kdumpctl
|
||||
|
||||
Describe 'get_grub_kernel_boot_parameter()'
|
||||
grubby() {
|
||||
%text
|
||||
#|index=1
|
||||
#|kernel="/boot/vmlinuz-5.14.14-200.fc34.x86_64"
|
||||
#|args="crashkernel=11M nvidia-drm.modeset=1 crashkernel=100M ro rhgb quiet crcrashkernel=200M crashkernel=32T-64T:128G,64T-102400T:180G fadump=on"
|
||||
#|root="UUID=45fdf703-3966-401b-b8f7-cf056affd2b0"
|
||||
}
|
||||
DUMMY_PARAM=/boot/vmlinuz
|
||||
|
||||
Context "when given a kernel parameter in different positions"
|
||||
# Test the following cases:
|
||||
# - the kernel parameter in the end
|
||||
# - the kernel parameter in the first
|
||||
# - the kernel parameter is crashkernel (suffix of crcrashkernel)
|
||||
# - the kernel parameter that does not exist
|
||||
# - the kernel parameter doesn't have a value
|
||||
Parameters
|
||||
# parameter answer
|
||||
fadump on
|
||||
nvidia-drm.modeset 1
|
||||
crashkernel 32T-64T:128G,64T-102400T:180G
|
||||
aaaa ""
|
||||
ro ""
|
||||
End
|
||||
|
||||
It 'should retrieve the value succesfully'
|
||||
When call get_grub_kernel_boot_parameter "$DUMMY_PARAM" "$2"
|
||||
The output should equal "$3"
|
||||
End
|
||||
End
|
||||
|
||||
It 'should retrive the last value if multiple <parameter=value> entries exist'
|
||||
When call get_grub_kernel_boot_parameter "$DUMMY_PARAM" crashkernel
|
||||
The output should equal '32T-64T:128G,64T-102400T:180G'
|
||||
End
|
||||
|
||||
It 'should fail when called with kernel_path=ALL'
|
||||
When call get_grub_kernel_boot_parameter ALL ro
|
||||
The status should be failure
|
||||
The error should include "kernel_path=ALL invalid"
|
||||
End
|
||||
End
|
||||
|
||||
Describe 'get_dump_mode_by_fadump_val()'
|
||||
|
||||
Context 'when given valid fadump values'
|
||||
Parameters
|
||||
"#1" on fadump
|
||||
"#2" nocma fadump
|
||||
"#3" "" kdump
|
||||
"#4" off kdump
|
||||
End
|
||||
It "should return the dump mode correctly"
|
||||
When call get_dump_mode_by_fadump_val "$2"
|
||||
The output should equal "$3"
|
||||
The status should be success
|
||||
End
|
||||
End
|
||||
|
||||
It 'should complain given invalid fadump value'
|
||||
When call get_dump_mode_by_fadump_val /boot/vmlinuz
|
||||
The status should be failure
|
||||
The error should include 'invalid fadump'
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe "read_proc_environ_var()"
|
||||
environ_test_file=$(mktemp -t spec_test_environ_test_file.XXXXXXXXXX)
|
||||
cleanup() {
|
||||
rm -rf "$environ_test_file"
|
||||
}
|
||||
AfterAll 'cleanup'
|
||||
echo -ne "container=bwrap-osbuild\x00SSH_AUTH_SOCK=/tmp/ssh-XXXXXXEbw33A/agent.1794\x00SSH_AGENT_PID=1929\x00env=test_env" >"$environ_test_file"
|
||||
Parameters
|
||||
container bwrap-osbuild
|
||||
SSH_AUTH_SOCK /tmp/ssh-XXXXXXEbw33A/agent.1794
|
||||
env test_env
|
||||
not_exist ""
|
||||
End
|
||||
It 'should read the environ variable value as expected'
|
||||
When call read_proc_environ_var "$1" "$environ_test_file"
|
||||
The output should equal "$2"
|
||||
The status should be success
|
||||
End
|
||||
End
|
||||
|
||||
Describe "_is_osbuild()"
|
||||
environ_test_file=$(mktemp -t spec_test_environ_test_file.XXXXXXXXXX)
|
||||
# shellcheck disable=SC2034
|
||||
# override the _OSBUILD_ENVIRON_PATH variable
|
||||
_OSBUILD_ENVIRON_PATH="$environ_test_file"
|
||||
Parameters
|
||||
'container=bwrap-osbuild' success
|
||||
'' failure
|
||||
End
|
||||
It 'should be able to tell if it is the osbuild environment'
|
||||
echo -ne "$1" >"$environ_test_file"
|
||||
When call _is_osbuild
|
||||
The status should be "$2"
|
||||
The stderr should equal ""
|
||||
End
|
||||
End
|
||||
|
||||
Describe "_get_dracut_arg"
|
||||
dracut_args='-o "foo bar baz" -t 1 --test="a b c" --omit bla'
|
||||
Parameters
|
||||
-o --omit 2 "foo bar baz bla"
|
||||
-e --empty 0 ""
|
||||
-t "" 1 "1"
|
||||
"" --test 1 "a b c"
|
||||
"" "" 0 ""
|
||||
End
|
||||
It "should parse the dracut_args correctly"
|
||||
When call _get_dracut_arg "$1" "$2" "$dracut_args"
|
||||
The status should equal $3
|
||||
The output should equal "$4"
|
||||
End
|
||||
End
|
||||
|
||||
Describe "is_dracut_mod_omitted()"
|
||||
KDUMP_CONFIG_FILE=$(mktemp -t kdump_conf.XXXXXXXXXX)
|
||||
cleanup() {
|
||||
rm -f "$kdump_conf"
|
||||
}
|
||||
AfterAll 'cleanup'
|
||||
|
||||
Parameters:dynamic
|
||||
for opt in '-o ' '--omit ' '--omit='; do
|
||||
for val in \
|
||||
'foo' \
|
||||
'"foo"' \
|
||||
'"foo bar baz"' \
|
||||
'"bar foo baz"' \
|
||||
'"bar baz foo"'; do
|
||||
%data success foo "$opt$val"
|
||||
%data success foo "-a x $opt$val -i y"
|
||||
%data failure xyz "$opt$val"
|
||||
%data failure xyz "-a x $opt$val -i y"
|
||||
done
|
||||
done
|
||||
%data success foo "-o xxx -o foo"
|
||||
%data failure foo "-a x -i y"
|
||||
End
|
||||
It "shall return $1 for module $2 and dracut_args '$3'"
|
||||
echo "dracut_args $3" > $KDUMP_CONFIG_FILE
|
||||
parse_config
|
||||
When call is_dracut_mod_omitted $2
|
||||
The status should be $1
|
||||
End
|
||||
End
|
||||
|
||||
Describe '_find_kernel_path_by_release()'
|
||||
# When the array length changes, the Parameters:dynamic should change as well
|
||||
kernel_paths=(/boot/vmlinuz-6.2.11-200.fc37.x86_64
|
||||
/boot/vmlinuz-5.14.0-316.el9.aarch64+64k
|
||||
/boot/vmlinuz-5.14.0-322.el9.aarch64
|
||||
/boot/efi/36b54597c46383/6.4.0-0.rc0.20230427git6e98b09da931.5.fc39.aarch64/linux)
|
||||
|
||||
kernels=(vmlinuz-6.2.11-200.fc37.x86_64
|
||||
vmlinuz-5.14.0-316.el9.aarch64+64k
|
||||
vmlinuz-5.14.0-322.el9.aarch64
|
||||
6.4.0-0.rc0.20230427git6e98b09da931.5.fc39.aarch64)
|
||||
|
||||
grubby() {
|
||||
for key in "${!kernel_paths[@]}"; do
|
||||
echo "kernel=\"${kernel_paths[$key]}\""
|
||||
done
|
||||
}
|
||||
|
||||
Parameters:dynamic
|
||||
# Due to a bug [1] in shellspec, hardcode the loop number instead of using the
|
||||
# array length
|
||||
# [1] https://github.com/shellspec/shellspec/issues/259
|
||||
for key in {0..3}; do
|
||||
%data "${kernels[$key]}" "${kernel_paths[$key]}"
|
||||
done
|
||||
End
|
||||
|
||||
It 'returns the kernel path for the given release'
|
||||
When call _find_kernel_path_by_release "$1"
|
||||
The output should equal "$2"
|
||||
End
|
||||
End
|
||||
|
||||
Describe 'parse_config()'
|
||||
KDUMP_CONFIG_FILE=$(mktemp -t kdump_conf.XXXXXXXXXX)
|
||||
cleanup() {
|
||||
rm -f "$KDUMP_CONFIG_FILE"
|
||||
}
|
||||
AfterAll 'cleanup'
|
||||
|
||||
It 'should not be happy with unkown option in kdump.conf'
|
||||
echo blabla > "$KDUMP_CONFIG_FILE"
|
||||
When call parse_config
|
||||
The status should be failure
|
||||
The stderr should include 'Invalid kdump config option blabla'
|
||||
End
|
||||
|
||||
Parameters:value aarch64 ppc64le s390x x86_64
|
||||
|
||||
It 'should be happy with the default kdump.conf'
|
||||
./gen-kdump-conf.sh "$1" > "$KDUMP_CONFIG_FILE"
|
||||
When call parse_config
|
||||
The status should be success
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
End
|
@ -1,118 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
Describe 'Management of the kernel crashkernel parameter.'
|
||||
Include ./kdumpctl
|
||||
kernel1=/boot/vmlinuz-5.15.6-100.fc34.x86_64
|
||||
kernel2=/boot/vmlinuz-5.14.14-200.fc34.x86_64
|
||||
old_ck=1G-4G:162M,4G-64G:256M,64G-:512M
|
||||
new_ck=1G-4G:196M,4G-64G:256M,64G-:512M
|
||||
KDUMP_SPEC_TEST_RUN_DIR=$(mktemp -u /tmp/spec_test.XXXXXXXXXX)
|
||||
GRUB_CFG="$KDUMP_SPEC_TEST_RUN_DIR/grub.cfg"
|
||||
|
||||
uname() {
|
||||
if [[ $1 == '-m' ]]; then
|
||||
echo -n x86_64
|
||||
elif [[ $1 == '-r' ]]; then
|
||||
echo -n $current_kernel
|
||||
fi
|
||||
}
|
||||
|
||||
# dinfo is a bit complex for unit tets, simply mock it
|
||||
dinfo() {
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
kdump_get_arch_recommend_crashkernel() {
|
||||
echo -n "$new_ck"
|
||||
}
|
||||
|
||||
setup() {
|
||||
mkdir -p "$KDUMP_SPEC_TEST_RUN_DIR"
|
||||
cp -r spec/support/boot_load_entries "$KDUMP_SPEC_TEST_RUN_DIR"
|
||||
cp spec/support/grub_env "$KDUMP_SPEC_TEST_RUN_DIR"/env_temp
|
||||
touch "$GRUB_CFG"
|
||||
|
||||
grubby --args crashkernel=$old_ck --update-kernel=$kernel1
|
||||
grubby --args crashkernel=$new_ck --update-kernel=$kernel2
|
||||
grubby --remove-args fadump --update-kernel=ALL
|
||||
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$KDUMP_SPEC_TEST_RUN_DIR"
|
||||
}
|
||||
|
||||
# the boot loader entries are for a system without a boot partition, mock
|
||||
# mountpoint to let grubby know it
|
||||
Mock mountpoint
|
||||
exit 1
|
||||
End
|
||||
|
||||
grubby() {
|
||||
# - --no-etc-grub-update, not update /etc/default/grub
|
||||
# - --bad-image-okay, don't check the validity of the image
|
||||
# - --env, specify custom grub2 environment block file to avoid modifying
|
||||
# the default /boot/grub2/grubenv
|
||||
# - --bls-directory, specify custom BootLoaderSpec config files to avoid
|
||||
# modifying the default /boot/loader/entries
|
||||
/usr/sbin/grubby --no-etc-grub-update --grub2 --config-file="$GRUB_CFG" --bad-image-okay --env="$KDUMP_SPEC_TEST_RUN_DIR"/env_temp -b "$KDUMP_SPEC_TEST_RUN_DIR"/boot_load_entries "$@"
|
||||
}
|
||||
|
||||
# The mocking breaks has_command. Mock it as well to fix the tests.
|
||||
has_command() {
|
||||
[[ "$1" == grubby ]]
|
||||
}
|
||||
|
||||
Describe "When kexec-tools have its default crashkernel updated, "
|
||||
|
||||
Context "if kexec-tools is updated alone, "
|
||||
BeforeAll 'setup'
|
||||
AfterAll 'cleanup'
|
||||
Specify 'reset_crashkernel_after_update should report updated kernels and note that auto_reset_crashkernel=yes'
|
||||
When call reset_crashkernel_after_update
|
||||
The output should include "For kernel=$kernel1, crashkernel=$new_ck now."
|
||||
The output should not include "For kernel=$kernel2, crashkernel=$new_ck now."
|
||||
# A hint on how to turn off auto update of crashkernel
|
||||
The output should include "auto_reset_crashkernel=no"
|
||||
End
|
||||
|
||||
Specify 'kernel1 should have crashkernel updated'
|
||||
When call grubby --info $kernel1
|
||||
The line 3 of output should include crashkernel="$new_ck"
|
||||
End
|
||||
|
||||
Specify 'kernel2 should also have crashkernel updated'
|
||||
When call grubby --info $kernel2
|
||||
The line 3 of output should include crashkernel="$new_ck"
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Context "If kernel package is installed alone, "
|
||||
BeforeAll 'setup'
|
||||
AfterAll 'cleanup'
|
||||
# BeforeAll somehow doesn't work as expected, manually call setup to bypass this issue.
|
||||
setup
|
||||
new_kernel_ver=new_kernel
|
||||
new_kernel=/boot/vmlinuz-$new_kernel_ver
|
||||
grubby --add-kernel=$new_kernel --initrd=/boot/initramfs-$new_kernel_ver.img --title=$new_kernel_ver
|
||||
|
||||
Specify 'reset_crashkernel_for_installed_kernel should report the new kernel has its crashkernel updated'
|
||||
When call reset_crashkernel_for_installed_kernel $new_kernel_ver
|
||||
The output should include "crashkernel=$new_ck"
|
||||
End
|
||||
|
||||
Specify 'the new kernel should have crashkernel updated'
|
||||
When call grubby --info $new_kernel
|
||||
The output should include crashkernel="$new_ck"
|
||||
End
|
||||
|
||||
Specify 'kernel1 keeps its crashkernel value'
|
||||
When call grubby --info $kernel1
|
||||
The output should include crashkernel="$old_ck"
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
End
|
||||
End
|
@ -1,225 +0,0 @@
|
||||
#!/bin/bash
|
||||
Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]'
|
||||
Include ./kdumpctl
|
||||
kernel1=/boot/vmlinuz-5.15.6-100.fc34.x86_64
|
||||
kernel2=/boot/vmlinuz-5.14.14-200.fc34.x86_64
|
||||
ck=222M
|
||||
KDUMP_SPEC_TEST_RUN_DIR=$(mktemp -d /tmp/spec_test.XXXXXXXXXX)
|
||||
current_kernel=5.15.6-100.fc34.x86_64
|
||||
|
||||
setup() {
|
||||
cp -r spec/support/boot_load_entries "$KDUMP_SPEC_TEST_RUN_DIR"
|
||||
cp spec/support/grub_env "$KDUMP_SPEC_TEST_RUN_DIR"/env_temp
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$KDUMP_SPEC_TEST_RUN_DIR"
|
||||
}
|
||||
|
||||
BeforeAll 'setup'
|
||||
AfterAll 'cleanup'
|
||||
|
||||
# the boot loader entries are for a system without a boot partition, mock
|
||||
# mountpoint to let grubby know it
|
||||
Mock mountpoint
|
||||
exit 1
|
||||
End
|
||||
|
||||
grubby() {
|
||||
# - --no-etc-grub-update, not update /etc/default/grub
|
||||
# - --bad-image-okay, don't check the validity of the image
|
||||
# - --env, specify custom grub2 environment block file to avoid modifying
|
||||
# the default /boot/grub2/grubenv
|
||||
# - --bls-directory, specify custom BootLoaderSpec config files to avoid
|
||||
# modifying the default /boot/loader/entries
|
||||
/usr/sbin/grubby --no-etc-grub-update --grub2 --bad-image-okay --env="$KDUMP_SPEC_TEST_RUN_DIR"/env_temp -b "$KDUMP_SPEC_TEST_RUN_DIR"/boot_load_entries "$@"
|
||||
}
|
||||
|
||||
# The mocking breaks has_command. Mock it as well to fix the tests.
|
||||
has_command() {
|
||||
[[ "$1" == grubby ]]
|
||||
}
|
||||
|
||||
Describe "Test the kdump dump mode "
|
||||
uname() {
|
||||
if [[ $1 == '-m' ]]; then
|
||||
echo -n x86_64
|
||||
elif [[ $1 == '-r' ]]; then
|
||||
echo -n $current_kernel
|
||||
fi
|
||||
}
|
||||
kdump_crashkernel=$(get_default_crashkernel kdump)
|
||||
Context "when --kernel not specified"
|
||||
grubby --args crashkernel=$ck --update-kernel ALL
|
||||
Specify 'kdumpctl should warn the user that crashkernel has been udpated'
|
||||
When call reset_crashkernel
|
||||
The error should include "Updated crashkernel=$kdump_crashkernel"
|
||||
End
|
||||
|
||||
Specify 'Current running kernel should have crashkernel updated'
|
||||
When call grubby --info $kernel1
|
||||
The line 3 of output should include crashkernel="$kdump_crashkernel"
|
||||
The line 3 of output should not include crashkernel=$ck
|
||||
End
|
||||
|
||||
Specify 'Other kernel still use the old crashkernel value'
|
||||
When call grubby --info $kernel2
|
||||
The line 3 of output should include crashkernel=$ck
|
||||
End
|
||||
End
|
||||
|
||||
Context "--kernel=ALL"
|
||||
grubby --args crashkernel=$ck --update-kernel ALL
|
||||
Specify 'kdumpctl should warn the user that crashkernel has been udpated'
|
||||
When call reset_crashkernel --kernel=ALL
|
||||
The error should include "Updated crashkernel=$kdump_crashkernel for kernel=$kernel1"
|
||||
The error should include "Updated crashkernel=$kdump_crashkernel for kernel=$kernel2"
|
||||
End
|
||||
|
||||
Specify 'kernel1 should have crashkernel updated'
|
||||
When call grubby --info $kernel1
|
||||
The line 3 of output should include crashkernel="$kdump_crashkernel"
|
||||
End
|
||||
|
||||
Specify 'kernel2 should have crashkernel updated'
|
||||
When call grubby --info $kernel2
|
||||
The line 3 of output should include crashkernel="$kdump_crashkernel"
|
||||
End
|
||||
End
|
||||
|
||||
Context "--kernel=/boot/one-kernel to update one specified kernel"
|
||||
grubby --args crashkernel=$ck --update-kernel ALL
|
||||
Specify 'kdumpctl should warn the user that crashkernel has been updated'
|
||||
When call reset_crashkernel --kernel=$kernel1
|
||||
The error should include "Updated crashkernel=$kdump_crashkernel for kernel=$kernel1"
|
||||
End
|
||||
|
||||
Specify 'kernel1 should have crashkernel updated'
|
||||
When call grubby --info $kernel1
|
||||
The line 3 of output should include crashkernel="$kdump_crashkernel"
|
||||
End
|
||||
|
||||
Specify 'kernel2 should have the old crashkernel'
|
||||
When call grubby --info $kernel2
|
||||
The line 3 of output should include crashkernel=$ck
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
Describe "FADump" fadump
|
||||
uname() {
|
||||
if [[ $1 == '-m' ]]; then
|
||||
echo -n ppc64le
|
||||
elif [[ $1 == '-r' ]]; then
|
||||
echo -n $current_kernel
|
||||
fi
|
||||
}
|
||||
|
||||
kdump_crashkernel=$(get_default_crashkernel kdump)
|
||||
fadump_crashkernel=$(get_default_crashkernel fadump)
|
||||
Context "when no --kernel specified"
|
||||
grubby --args crashkernel=$ck --update-kernel ALL
|
||||
grubby --remove-args=fadump --update-kernel ALL
|
||||
Specify 'kdumpctl should warn the user that crashkernel has been udpated'
|
||||
When call reset_crashkernel
|
||||
The error should include "Updated crashkernel=$kdump_crashkernel"
|
||||
End
|
||||
|
||||
Specify 'Current running kernel should have crashkernel updated'
|
||||
When call grubby --info $kernel1
|
||||
The line 3 of output should include crashkernel="$kdump_crashkernel"
|
||||
End
|
||||
|
||||
Specify 'Other kernel still use the old crashkernel value'
|
||||
When call grubby --info $kernel2
|
||||
The line 3 of output should include crashkernel=$ck
|
||||
End
|
||||
End
|
||||
|
||||
Context "--kernel=ALL --fadump=on"
|
||||
grubby --args crashkernel=$ck --update-kernel ALL
|
||||
Specify 'kdumpctl should warn the user that crashkernel has been udpated'
|
||||
When call reset_crashkernel --kernel=ALL --fadump=on
|
||||
The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel1"
|
||||
The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel2"
|
||||
End
|
||||
|
||||
Specify 'kernel1 should have crashkernel updated'
|
||||
When call grubby --info $kernel1
|
||||
The line 3 of output should include crashkernel="$fadump_crashkernel"
|
||||
End
|
||||
|
||||
Specify 'kernel2 should have crashkernel updated'
|
||||
When call get_grub_kernel_boot_parameter $kernel2 crashkernel
|
||||
The output should equal "$fadump_crashkernel"
|
||||
End
|
||||
End
|
||||
|
||||
Context "--kernel=/boot/one-kernel to update one specified kernel"
|
||||
grubby --args crashkernel=$ck --update-kernel ALL
|
||||
grubby --args fadump=on --update-kernel $kernel1
|
||||
Specify 'kdumpctl should warn the user that crashkernel has been updated'
|
||||
When call reset_crashkernel --kernel=$kernel1
|
||||
The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel1"
|
||||
End
|
||||
|
||||
Specify 'kernel1 should have crashkernel updated'
|
||||
When call grubby --info $kernel1
|
||||
The line 3 of output should include crashkernel="$fadump_crashkernel"
|
||||
End
|
||||
|
||||
Specify 'kernel2 should have the old crashkernel'
|
||||
When call get_grub_kernel_boot_parameter $kernel2 crashkernel
|
||||
The output should equal $ck
|
||||
End
|
||||
End
|
||||
|
||||
Context "Update all kernels but without --fadump specified"
|
||||
grubby --args crashkernel=$ck --update-kernel ALL
|
||||
grubby --args fadump=on --update-kernel $kernel1
|
||||
Specify 'kdumpctl should warn the user that crashkernel has been updated'
|
||||
When call reset_crashkernel --kernel=$kernel1
|
||||
The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel1"
|
||||
End
|
||||
|
||||
Specify 'kernel1 should have crashkernel updated'
|
||||
When call get_grub_kernel_boot_parameter $kernel1 crashkernel
|
||||
The output should equal "$fadump_crashkernel"
|
||||
End
|
||||
|
||||
Specify 'kernel2 should have the old crashkernel'
|
||||
When call get_grub_kernel_boot_parameter $kernel2 crashkernel
|
||||
The output should equal $ck
|
||||
End
|
||||
End
|
||||
|
||||
Context 'Switch between fadump=on and fadump=nocma'
|
||||
grubby --args crashkernel=$ck --update-kernel ALL
|
||||
grubby --args fadump=on --update-kernel ALL
|
||||
Specify 'fadump=on to fadump=nocma'
|
||||
When call reset_crashkernel --kernel=ALL --fadump=nocma
|
||||
The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel1"
|
||||
The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel2"
|
||||
End
|
||||
|
||||
Specify 'kernel1 should have fadump=nocma in cmdline'
|
||||
When call get_grub_kernel_boot_parameter $kernel1 fadump
|
||||
The output should equal nocma
|
||||
End
|
||||
|
||||
Specify 'fadump=nocma to fadump=on'
|
||||
When call reset_crashkernel --kernel=ALL --fadump=on
|
||||
The error should include "Updated fadump=on for kernel=$kernel1"
|
||||
End
|
||||
|
||||
Specify 'kernel2 should have fadump=on in cmdline'
|
||||
When call get_grub_kernel_boot_parameter $kernel1 fadump
|
||||
The output should equal on
|
||||
End
|
||||
|
||||
End
|
||||
|
||||
End
|
||||
End
|
@ -1,8 +0,0 @@
|
||||
title Fedora (0-rescue-e986846f63134c7295458cf36300ba5b) 33 (Workstation Edition)
|
||||
version 0-rescue-e986846f63134c7295458cf36300ba5b
|
||||
linux /boot/vmlinuz-0-rescue-e986846f63134c7295458cf36300ba5b
|
||||
initrd /boot/initramfs-0-rescue-e986846f63134c7295458cf36300ba5b.img
|
||||
options root=UUID=45fdf703-3966-401b-b8f7-cf056affd2b0 ro rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 crashkernel=4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-102400T:180G fadump=on
|
||||
grub_users $grub_users
|
||||
grub_arg --unrestricted
|
||||
grub_class kernel
|
@ -1,8 +0,0 @@
|
||||
title Fedora (5.14.14-200.fc34.x86_64) 34 (Workstation Edition)
|
||||
version 5.14.14-200.fc34.x86_64
|
||||
linux /boot/vmlinuz-5.14.14-200.fc34.x86_64
|
||||
initrd /boot/initramfs-5.14.14-200.fc34.x86_64.img
|
||||
options root=UUID=45fdf703-3966-401b-b8f7-cf056affd2b0 ro rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 crashkernel=4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-102400T:180G fadump=on
|
||||
grub_users $grub_users
|
||||
grub_arg --unrestricted
|
||||
grub_class kernel
|
@ -1,8 +0,0 @@
|
||||
title Fedora (5.15.6-100.fc34.x86_64) 34 (Workstation Edition)
|
||||
version 5.15.6-100.fc34.x86_64
|
||||
linux /boot/vmlinuz-5.15.6-100.fc34.x86_64
|
||||
initrd /boot/initramfs-5.15.6-100.fc34.x86_64.img
|
||||
options root=UUID=45fdf703-3966-401b-b8f7-cf056affd2b0 ro rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 crashkernel=4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-102400T:180G fadump=on
|
||||
grub_users $grub_users
|
||||
grub_arg --unrestricted
|
||||
grub_class fedora
|
@ -1,3 +0,0 @@
|
||||
# GRUB Environment Block
|
||||
# WARNING: Do not edit this file by tools other than grub-editenv!!!
|
||||
##################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
|
@ -1,88 +0,0 @@
|
||||
TEST_CASE ?=
|
||||
BASE_IMAGE ?=
|
||||
|
||||
TEST_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
BUILD_ROOT := $(TEST_ROOT)/build
|
||||
REPO = $(shell realpath $(TEST_ROOT)/../)
|
||||
ARCH ?= $(shell arch)
|
||||
SPEC = kexec-tools.spec
|
||||
|
||||
DIST ?= fedora
|
||||
DIST_ABR ?= f
|
||||
DIST_ABRL ?= fc
|
||||
DIST_UNSET ?= rhel
|
||||
RELEASE ?= 33
|
||||
|
||||
DEFAULT_BASE_IMAGE_VER ?= 1.2
|
||||
DEFAULT_BASE_IMAGE ?= Fedora-Cloud-Base-$(RELEASE)-$(DEFAULT_BASE_IMAGE_VER).$(ARCH).raw.xz
|
||||
DEFAULT_BASE_IMAGE_URL ?= https://dl.fedoraproject.org/pub/fedora/linux/releases/$(RELEASE)/Cloud/$(ARCH)/images/$(DEFAULT_BASE_IMAGE)
|
||||
|
||||
BUILD_ROOT = $(TEST_ROOT)/build
|
||||
RPMDEFINE = --define '_sourcedir $(REPO)'\
|
||||
--define '_specdir $(REPO)'\
|
||||
--define '_builddir $(BUILD_ROOT)'\
|
||||
--define '_srcrpmdir $(BUILD_ROOT)'\
|
||||
--define '_rpmdir $(BUILD_ROOT)'\
|
||||
--define 'dist %{?distprefix}.$(DIST_ABRL)$(RELEASE)'\
|
||||
--define '$(DIST) $(RELEASE)'\
|
||||
--eval '%undefine $(DIST_UNSET)'\
|
||||
--define '$(DIST_ABRL)$(RELEASE) 1'\
|
||||
|
||||
KEXEC_TOOLS_SRC = $(filter-out $(REPO)/tests,$(wildcard $(REPO)/*))
|
||||
KEXEC_TOOLS_TEST_SRC = $(wildcard $(REPO)/tests/scripts/**/*)
|
||||
KEXEC_TOOLS_NVR = $(shell rpm $(RPMDEFINE) -q --specfile $(REPO)/$(SPEC) 2>/dev/null | grep -m 1 . | sed -e 's#.src#.$(ARCH)#')
|
||||
KEXEC_TOOLS_RPM = $(BUILD_ROOT)/$(ARCH)/$(KEXEC_TOOLS_NVR).rpm
|
||||
|
||||
all: $(TEST_ROOT)/output/test-base-image
|
||||
|
||||
# Use either:
|
||||
# fedpkg --release $(DIST_ABR)$(RELEASE) --path ../../ local
|
||||
# or
|
||||
# rpmbuild $(RPMDEFINE) -ba $(REPO)/$(SPEC)
|
||||
# to rebuild the rpm, currently use rpmbuild to have better control over the rpm building process
|
||||
#
|
||||
$(KEXEC_TOOLS_RPM): $(KEXEC_TOOLS_SRC)
|
||||
sh -c "cd .. && fedpkg --release f$(RELEASE) sources"
|
||||
@echo Rebuilding RPM due to modification of sources: $?
|
||||
rpmbuild $(RPMDEFINE) -ba $(REPO)/$(SPEC)
|
||||
|
||||
$(BUILD_ROOT)/base-image:
|
||||
mkdir -p $(BUILD_ROOT)
|
||||
ifeq ($(strip $(BASE_IMAGE)),)
|
||||
wget $(DEFAULT_BASE_IMAGE_URL) -O $(BUILD_ROOT)/$(DEFAULT_BASE_IMAGE)
|
||||
$(TEST_ROOT)/scripts/build-image.sh \
|
||||
$(BUILD_ROOT)/$(DEFAULT_BASE_IMAGE)\
|
||||
$(BUILD_ROOT)/base-image
|
||||
else
|
||||
$(TEST_ROOT)/scripts/build-image.sh \
|
||||
$(BASE_IMAGE)\
|
||||
$(BUILD_ROOT)/base-image
|
||||
endif
|
||||
|
||||
$(BUILD_ROOT)/inst-base-image: $(BUILD_ROOT)/base-image
|
||||
@echo "Building installation base image"
|
||||
echo $(KEXEC_TOOLS_NVR)
|
||||
$(TEST_ROOT)/scripts/build-image.sh \
|
||||
$(BUILD_ROOT)/base-image \
|
||||
$(BUILD_ROOT)/inst-base-image \
|
||||
$(TEST_ROOT)/scripts/build-scripts/base-image.sh
|
||||
|
||||
$(TEST_ROOT)/output/test-base-image: $(BUILD_ROOT)/inst-base-image $(KEXEC_TOOLS_RPM) $(KEXEC_TOOLS_TEST_SRC) $(EXTRA_RPMS)
|
||||
@echo "Building test base image"
|
||||
mkdir -p $(TEST_ROOT)/output
|
||||
$(TEST_ROOT)/scripts/build-image.sh \
|
||||
$(BUILD_ROOT)/inst-base-image \
|
||||
$(TEST_ROOT)/output/test-base-image \
|
||||
$(TEST_ROOT)/scripts/build-scripts/test-base-image.sh \
|
||||
$(KEXEC_TOOLS_RPM) $(EXTRA_RPMS)
|
||||
|
||||
test-run: $(TEST_ROOT)/output/test-base-image
|
||||
ifeq ($(strip $(TEST_CASE)),)
|
||||
$(TEST_ROOT)/scripts/run-test.sh
|
||||
else
|
||||
$(TEST_ROOT)/scripts/run-test.sh --console $(TEST_CASE)
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -rf $(TEST_ROOT)/build
|
||||
rm -rf $(TEST_ROOT)/output
|
65
tests/README
65
tests/README
@ -1,65 +0,0 @@
|
||||
=====================
|
||||
Kexec Kdump Self-test
|
||||
=====================
|
||||
|
||||
|
||||
Introduction
|
||||
============
|
||||
The self-tests here are useful for quick sanity tests for new patches, and also helpful for debugging issues.
|
||||
|
||||
|
||||
How it works
|
||||
============
|
||||
All tests are run within VMs using qemu. By default, VM images are based on Fedora Cloud image, and the image for each test run is a layered qcow2 snapshot on top of the base image.
|
||||
Test images are managed by Makefile, so if there are any code change in the kexec-tools repository, `make` command will detect that and only rebuild the top image layer. This makes the test runs boot fast and each test run is clean.
|
||||
|
||||
|
||||
Basic usage
|
||||
===========
|
||||
Before you start, you can make the self-tests use your own base image by running following command:
|
||||
|
||||
`make clean && make BASE_IMAGE=<path/to/your/image>`
|
||||
|
||||
This is helpful if you have a slow network, else self-test will try to download the cloud image from Fedora's official website using `wget`.
|
||||
|
||||
- Use the following command to run all tests:
|
||||
$ make test-run
|
||||
|
||||
All available tests will be executed.
|
||||
|
||||
Test artifacts are stored in output/<testcase>
|
||||
|
||||
- For easier debugging, you can run only on test with the following command:
|
||||
$ make TEST_CASE=<testcase> test-run
|
||||
|
||||
This way, VM's console is directly connected to stdin/out so debugging will be easier.
|
||||
If there are multiple VMs used in a test case, the VM performing actual kdump/kexec operation will be connected to stdin/out.
|
||||
|
||||
Test Cases
|
||||
==========
|
||||
Each test case is a folder under scripts/testcases/, a test case folder will contain at least one executable shell script, and each script should contain two functions: "on_build" and "on_test".
|
||||
|
||||
"on_build" is called when building the test image, which can instruct the self-test framework to install packages or create files, etc.
|
||||
"on_test" is called when VM finished booting, which can get the boot count by calling "get_test_boot_count" and determine what to do. It should call "test_passed" on success, and call "test_failed" on failure. "test_aborted" is called when unexpected behavior occurs.
|
||||
|
||||
When there are multiple scripts in a single test case folder, they will spawn VMs in lexical order, and the last VM is considered the VM performing the actual test. Other VMs could be hosting test required service. This is useful for the network dump test. However, "test_passed" or "test_failed" or "test_aborted" could be called in any of these VMs, so during network kdump test, the dump target can also terminate the test and mark it passed when a valid vmcore is detected.
|
||||
|
||||
|
||||
Debugging
|
||||
=========
|
||||
|
||||
- When the test VM boots, you can append "no_test" to kernel args in grub, which tells the test services to quit early.
|
||||
|
||||
- You can launch the VMs manually or inspect the image after ran a test.
|
||||
|
||||
Test images are located as:
|
||||
|
||||
output/<testcase>/<vm-name>.img
|
||||
|
||||
Test images' corresponding qemu command are located as:
|
||||
|
||||
output/<testcase>/<vm-name>.qemu_cmd
|
||||
|
||||
To repeat/debug a test manually, you should launch all VMs in output/<testcase> menu in lexical order, and append 'no_test' in the last VM's grub cmdline, then VM will hang on login prompt, login with root/fedora. Test script is located as /kexec-kdump-test/test.sh
|
||||
|
||||
- If you just want to inspect the images file content, you can also use scripts/spawn-image-shell.sh <test-image> to spawn a shell in the image quickly.
|
@ -1,57 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "Usage: $(basename $0) <base-image> <output-image> <build-script> [<build-script-args>]
|
||||
Build a new <output-image> on top of <base-image>, and install
|
||||
contents defined in <build-script>. <args> are directly passed
|
||||
to <build-script>.
|
||||
|
||||
If <base-image> is raw, will copy it and create <output-image>
|
||||
in qcow2 format.
|
||||
|
||||
If <base-image> is qcow2, will create <output-image> as a snapshot
|
||||
on top of <base-image>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASEDIR=$(realpath $(dirname "$0"))
|
||||
. $BASEDIR/image-init-lib.sh
|
||||
|
||||
# Base image to build from
|
||||
BASE_IMAGE=$1 && shift
|
||||
if [[ ! -e $BASE_IMAGE ]]; then
|
||||
perror_exit "Base image '$BASE_IMAGE' not found"
|
||||
else
|
||||
BASE_IMAGE=$(realpath "$BASE_IMAGE")
|
||||
fi
|
||||
|
||||
OUTPUT_IMAGE=$1 && shift
|
||||
if [[ ! -d $(dirname $OUTPUT_IMAGE) ]]; then
|
||||
perror_exit "Path '$(dirname $OUTPUT_IMAGE)' doesn't exists"
|
||||
fi
|
||||
|
||||
INST_SCRIPT=$1 && shift
|
||||
|
||||
create_image_from_base_image $BASE_IMAGE $OUTPUT_IMAGE.building
|
||||
|
||||
mount_image $OUTPUT_IMAGE.building
|
||||
|
||||
img_inst() {
|
||||
inst_in_image $OUTPUT_IMAGE.building $@
|
||||
}
|
||||
|
||||
img_inst_pkg() {
|
||||
inst_pkg_in_image $OUTPUT_IMAGE.building $@
|
||||
}
|
||||
|
||||
img_run_cmd() {
|
||||
run_in_image $OUTPUT_IMAGE.building "$@"
|
||||
}
|
||||
|
||||
img_add_qemu_cmd() {
|
||||
QEMU_CMD+="$@"
|
||||
}
|
||||
|
||||
[ -e "$INST_SCRIPT" ] && source $INST_SCRIPT
|
||||
|
||||
mv $OUTPUT_IMAGE.building $OUTPUT_IMAGE
|
@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
img_inst_pkg grubby\
|
||||
dnsmasq\
|
||||
openssh openssh-server\
|
||||
dracut-network dracut-squash squashfs-tools ethtool snappy kernel-modules
|
||||
|
||||
img_run_cmd "grubby --args systemd.journald.forward_to_console=1 systemd.log_target=console --update-kernel ALL"
|
||||
img_run_cmd "grubby --args selinux=0 --update-kernel ALL"
|
@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Test RPMs to be installed
|
||||
TEST_RPMS=
|
||||
for _rpm in $@; do
|
||||
if [[ ! -e $_rpm ]]; then
|
||||
perror_exit "'$_rpm' not found"
|
||||
else
|
||||
TEST_RPMS="$TEST_RPMS $(realpath "$_rpm")"
|
||||
fi
|
||||
done
|
||||
|
||||
img_run_cmd "mkdir -p /kexec-kdump-test"
|
||||
img_inst $TESTDIR/scripts/kexec-kdump-test/init.sh /kexec-kdump-test/init.sh
|
||||
img_inst $TESTDIR/scripts/kexec-kdump-test/test.sh /kexec-kdump-test/test.sh
|
||||
img_inst $TESTDIR/scripts/kexec-kdump-test/kexec-kdump-test.service /etc/systemd/system/kexec-kdump-test.service
|
||||
img_run_cmd "systemctl enable kexec-kdump-test.service"
|
||||
|
||||
img_inst_pkg $TEST_RPMS
|
||||
# Test script should start kdump manually to save time
|
||||
img_run_cmd "systemctl disable kdump.service"
|
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
. $TESTDIR/scripts/test-lib.sh
|
||||
TEST_SCRIPT=$1
|
||||
|
||||
QEMU_CMD="$DEFAULT_QEMU_CMD \
|
||||
-serial stdio \
|
||||
-serial file:$(get_test_output_file $TEST_SCRIPT) \
|
||||
-monitor none \
|
||||
-hda $OUTPUT_IMAGE"
|
||||
|
||||
img_add_qemu_cmd() {
|
||||
QEMU_CMD+=" $@"
|
||||
}
|
||||
|
||||
source $TEST_SCRIPT
|
||||
|
||||
on_build
|
||||
|
||||
img_inst $TEST_SCRIPT /kexec-kdump-test/test.sh
|
||||
|
||||
echo $QEMU_CMD > $(get_test_qemu_cmd_file $TEST_SCRIPT)
|
@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BASEDIR=$(realpath $(dirname "$0"))
|
||||
. $BASEDIR/image-init-lib.sh
|
||||
|
||||
# Base image to copy from
|
||||
BOOT_IMAGE=$1 && shift
|
||||
if [ ! -e "$BOOT_IMAGE" ]; then
|
||||
perror_exit "Image '$BOOT_IMAGE' not found"
|
||||
else
|
||||
BOOT_IMAGE=$(realpath "$BOOT_IMAGE")
|
||||
fi
|
||||
|
||||
mount_image $BOOT_IMAGE
|
||||
|
||||
IMAGE_MNT=$(get_image_mount_root $BOOT_IMAGE)
|
||||
|
||||
SRC=
|
||||
while [ $# -gt 1 ]; do
|
||||
SRC="$SRC $IMAGE_MNT/$1"
|
||||
shift
|
||||
done
|
||||
DST=$1
|
||||
|
||||
cp -rv $SRC $DST
|
@ -1,275 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
[ -z "$TESTDIR" ] && TESTDIR=$(realpath $(dirname "$0")/../)
|
||||
|
||||
SUDO="sudo"
|
||||
|
||||
declare -A MNTS=()
|
||||
declare -A DEVS=()
|
||||
|
||||
perror() {
|
||||
echo $@>&2
|
||||
}
|
||||
|
||||
perror_exit() {
|
||||
echo $@>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
is_mounted()
|
||||
{
|
||||
findmnt -k -n $1 &>/dev/null
|
||||
}
|
||||
|
||||
clean_up()
|
||||
{
|
||||
for _mnt in ${MNTS[@]}; do
|
||||
is_mounted $_mnt && $SUDO umount -f -R $_mnt
|
||||
done
|
||||
|
||||
for _dev in ${DEVS[@]}; do
|
||||
[ ! -e "$_dev" ] && continue
|
||||
[[ "$_dev" == "/dev/loop"* ]] && $SUDO losetup -d "$_dev"
|
||||
[[ "$_dev" == "/dev/nbd"* ]] && $SUDO qemu-nbd --disconnect "$_dev"
|
||||
done
|
||||
|
||||
[ -d "$TMPDIR" ] && $SUDO rm --one-file-system -rf -- "$TMPDIR";
|
||||
|
||||
sync
|
||||
}
|
||||
|
||||
trap '
|
||||
ret=$?;
|
||||
clean_up
|
||||
exit $ret;
|
||||
' EXIT
|
||||
|
||||
# clean up after ourselves no matter how we die.
|
||||
trap 'exit 1;' SIGINT
|
||||
|
||||
readonly TMPDIR="$(mktemp -d -t kexec-kdump-test.XXXXXX)"
|
||||
[ -d "$TMPDIR" ] || perror_exit "mktemp failed."
|
||||
|
||||
get_image_fmt() {
|
||||
local image=$1 fmt
|
||||
|
||||
[ ! -e "$image" ] && perror "image: $image doesn't exist" && return 1
|
||||
|
||||
fmt=$(qemu-img info $image | sed -n "s/file format:\s*\(.*\)/\1/p")
|
||||
|
||||
[ $? -eq 0 ] && echo $fmt && return 0
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
fmt_is_qcow2() {
|
||||
[ "$1" == "qcow2" ] || [ "$1" == "qcow2 backing qcow2" ]
|
||||
}
|
||||
|
||||
# If it's partitioned, return the mountable partition, else return the dev
|
||||
get_mountable_dev() {
|
||||
local dev=$1 parts
|
||||
|
||||
$SUDO partprobe $dev && sync
|
||||
parts="$(ls -1 ${dev}p*)"
|
||||
if [ -n "$parts" ]; then
|
||||
if [ $(echo "$parts" | wc -l) -gt 1 ]; then
|
||||
perror "It's a image with multiple partitions, using last partition as main partition"
|
||||
fi
|
||||
echo "$parts" | tail -1
|
||||
else
|
||||
echo "$dev"
|
||||
fi
|
||||
}
|
||||
|
||||
# get the separate boot partition
|
||||
# return the 2nd partition as boot partition
|
||||
get_mount_boot() {
|
||||
local dev=$1 _second_part=${dev}p2
|
||||
|
||||
# it's better to check if the 2nd partition has the boot label using lsblk
|
||||
# but somehow this doesn't work starting with Fedora37
|
||||
echo $_second_part
|
||||
}
|
||||
|
||||
|
||||
prepare_loop() {
|
||||
[ -n "$(lsmod | grep "^loop")" ] && return
|
||||
|
||||
$SUDO modprobe loop
|
||||
|
||||
[ ! -e "/dev/loop-control" ] && perror_exit "failed to load loop driver"
|
||||
}
|
||||
|
||||
prepare_nbd() {
|
||||
[ -n "$(lsmod | grep "^nbd")" ] && return
|
||||
|
||||
$SUDO modprobe nbd max_part=4
|
||||
|
||||
[ ! -e "/dev/nbd0" ] && perror_exit "failed to load nbd driver"
|
||||
}
|
||||
|
||||
mount_nbd() {
|
||||
local image=$1 size dev
|
||||
for _dev in /sys/class/block/nbd* ; do
|
||||
size=$(cat $_dev/size)
|
||||
if [ "$size" -eq 0 ] ; then
|
||||
dev=/dev/${_dev##*/}
|
||||
$SUDO qemu-nbd --connect=$dev $image 1>&2
|
||||
[ $? -eq 0 ] && echo $dev && break
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
image_lock()
|
||||
{
|
||||
local image=$1 timeout=5 fd
|
||||
|
||||
eval "exec {fd}>$image.lock"
|
||||
if [ $? -ne 0 ]; then
|
||||
perror_exit "failed acquiring image lock"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
flock -n $fd
|
||||
rc=$?
|
||||
while [ $rc -ne 0 ]; do
|
||||
echo "Another instance is holding the image lock ..."
|
||||
flock -w $timeout $fd
|
||||
rc=$?
|
||||
done
|
||||
}
|
||||
|
||||
# Mount a device, will umount it automatially when shell exits
|
||||
mount_image() {
|
||||
local image=$1 fmt
|
||||
local dev mnt mnt_dev boot root
|
||||
|
||||
# Lock the image just in case user run this script in parrel
|
||||
image_lock $image
|
||||
|
||||
fmt=$(get_image_fmt $image)
|
||||
[ $? -ne 0 ] || [ -z "$fmt" ] && perror_exit "failed to detect image format"
|
||||
|
||||
if [ "$fmt" == "raw" ]; then
|
||||
prepare_loop
|
||||
|
||||
dev="$($SUDO losetup --show -f $image)"
|
||||
[ $? -ne 0 ] || [ -z "$dev" ] && perror_exit "failed to setup loop device"
|
||||
|
||||
elif fmt_is_qcow2 "$fmt"; then
|
||||
prepare_nbd
|
||||
|
||||
dev=$(mount_nbd $image)
|
||||
[ $? -ne 0 ] || [ -z "$dev" ] perror_exit "failed to connect qemu to nbd device '$dev'"
|
||||
else
|
||||
perror_exit "Unrecognized image format '$fmt'"
|
||||
fi
|
||||
DEVS[$image]="$dev"
|
||||
|
||||
mnt="$(mktemp -d -p $TMPDIR -t mount.XXXXXX)"
|
||||
[ $? -ne 0 ] || [ -z "$mnt" ] && perror_exit "failed to create tmp mount dir"
|
||||
MNTS[$image]="$mnt"
|
||||
|
||||
mnt_dev=$(get_mountable_dev "$dev")
|
||||
[ $? -ne 0 ] || [ -z "$mnt_dev" ] && perror_exit "failed to setup loop device"
|
||||
|
||||
$SUDO mount $mnt_dev $mnt
|
||||
[ $? -ne 0 ] && perror_exit "failed to mount device '$mnt_dev'"
|
||||
boot=$(get_mount_boot "$dev")
|
||||
if [[ -n "$boot" ]]; then
|
||||
root=$(get_image_mount_root $image)
|
||||
$SUDO mount $boot $root/boot
|
||||
[ $? -ne 0 ] && perror_exit "failed to mount the bootable partition for device '$mnt_dev'"
|
||||
fi
|
||||
}
|
||||
|
||||
get_image_mount_root() {
|
||||
local image=$1
|
||||
local root=${MNTS[$image]}
|
||||
|
||||
# Starting from Fedora 36, the root node is /root/root of the last partition
|
||||
[ -d "$root/root/root" ] && root=$root/root
|
||||
echo $root
|
||||
|
||||
if [ -z "$root" ]; then
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
shell_in_image() {
|
||||
local root=$(get_image_mount_root $1) && shift
|
||||
|
||||
pushd $root
|
||||
|
||||
$SHELL
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
inst_pkg_in_image() {
|
||||
local root=$(get_image_mount_root $1) && shift
|
||||
|
||||
# LSB not available
|
||||
# release_info=$($SUDO chroot $root /bin/bash -c "lsb_release -a")
|
||||
# release=$(echo "$release_info" | sed -n "s/Release:\s*\(.*\)/\1/p")
|
||||
# distro=$(echo "$release_info" | sed -n "s/Distributor ID:\s*\(.*\)/\1/p")
|
||||
# if [ "$distro" != "Fedora" ]; then
|
||||
# perror_exit "only Fedora image is supported"
|
||||
# fi
|
||||
release=$(cat $root/etc/fedora-release | sed -n "s/.*[Rr]elease\s*\([0-9]*\).*/\1/p")
|
||||
[ $? -ne 0 ] || [ -z "$release" ] && perror_exit "only Fedora image is supported"
|
||||
|
||||
$SUDO dnf --releasever=$release --installroot=$root install -y $@
|
||||
}
|
||||
|
||||
run_in_image() {
|
||||
local root=$(get_image_mount_root $1) && shift
|
||||
|
||||
$SUDO chroot $root /bin/bash -c "$@"
|
||||
}
|
||||
|
||||
inst_in_image() {
|
||||
local image=$1 src=$2 dst=$3
|
||||
local root=$(get_image_mount_root $1)
|
||||
|
||||
$SUDO cp $src $root/$dst
|
||||
}
|
||||
|
||||
# If source image is qcow2, create a snapshot
|
||||
# If source image is raw, convert to raw
|
||||
# If source image is xz, decompress then repeat the above logic
|
||||
#
|
||||
# Won't touch source image
|
||||
create_image_from_base_image() {
|
||||
local image=$1
|
||||
local output=$2
|
||||
local decompressed_image
|
||||
|
||||
local ext="${image##*.}"
|
||||
if [[ "$ext" == 'xz' ]]; then
|
||||
echo "Decompressing base image..."
|
||||
xz -d -k $image
|
||||
decompressed_image=${image%.xz}
|
||||
image=$decompressed_image
|
||||
fi
|
||||
|
||||
local image_fmt=$(get_image_fmt $image)
|
||||
if [ "$image_fmt" != "raw" ]; then
|
||||
if fmt_is_qcow2 "$image_fmt"; then
|
||||
echo "Source image is qcow2, using snapshot..."
|
||||
qemu-img create -f qcow2 -b $image -F qcow2 $output
|
||||
else
|
||||
perror_exit "Unrecognized base image format '$image_mnt'"
|
||||
fi
|
||||
else
|
||||
echo "Source image is raw, converting to qcow2..."
|
||||
qemu-img convert -f raw -O qcow2 $image $output
|
||||
fi
|
||||
|
||||
# Clean up decompress temp image
|
||||
if [ -n "$decompressed_image" ]; then
|
||||
rm $decompressed_image
|
||||
fi
|
||||
}
|
@ -1,122 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
BOOT_ARG="test_boot_count"
|
||||
_YELLOW='\033[1;33m'
|
||||
_GREEN='\033[0;32m'
|
||||
_RED='\033[0;31m'
|
||||
_NC='\033[0m' # No Color
|
||||
|
||||
if [ -n "$(cat /proc/cmdline | grep "\bno_test\b")" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
get_test_boot_count() {
|
||||
local boot_count=$(cat /proc/cmdline | sed -n "s/.*$BOOT_ARG=\([0-9]*\).*/\1/p")
|
||||
|
||||
if [ -z "$boot_count" ]; then
|
||||
boot_count=1
|
||||
fi
|
||||
|
||||
echo $boot_count
|
||||
}
|
||||
|
||||
test_output() {
|
||||
echo $@ > /dev/ttyS1
|
||||
echo $@ > /dev/ttyS0
|
||||
|
||||
sync
|
||||
}
|
||||
|
||||
test_passed() {
|
||||
echo -e "${_GREEN}TEST PASSED${_NC}" > /dev/ttyS1
|
||||
echo -e "${_GREEN}kexec-kdump-test: TEST PASSED${_NC}" > /dev/ttyS0
|
||||
|
||||
echo $@ > /dev/ttyS1
|
||||
echo $@ > /dev/ttyS0
|
||||
|
||||
sync
|
||||
|
||||
shutdown -h 0
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
test_failed() {
|
||||
echo -e "${_RED}TEST FAILED${_NC}" > /dev/ttyS1
|
||||
echo -e "${_RED}kexec-kdump-test: TEST FAILED${_NC}" > /dev/ttyS0
|
||||
|
||||
echo $@ > /dev/ttyS1
|
||||
echo $@ > /dev/ttyS0
|
||||
|
||||
sync
|
||||
|
||||
shutdown -h 0
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
test_abort() {
|
||||
echo -e "${_YELLOW}TEST ABORTED${_NC}" > /dev/ttyS1
|
||||
echo -e "${_YELLOW}kexec-kdump-test: TEST ABORTED${_NC}" > /dev/ttyS0
|
||||
|
||||
echo $@ > /dev/ttyS1
|
||||
echo $@ > /dev/ttyS0
|
||||
|
||||
sync
|
||||
|
||||
shutdown -h 0
|
||||
|
||||
exit 2
|
||||
}
|
||||
|
||||
has_valid_vmcore_dir() {
|
||||
local path=$1
|
||||
local vmcore_dir=$path/$(ls -1 $path | tail -n 1)
|
||||
local vmcore="<invalid>"
|
||||
|
||||
test_output "Found a vmcore dir \"$vmcore_dir\":"
|
||||
# Checking with `crash` is slow and consume a lot of memory/disk,
|
||||
# just do a sanity check by check if log are available.
|
||||
if [ -e $vmcore_dir/vmcore ]; then
|
||||
vmcore=$vmcore_dir/vmcore
|
||||
makedumpfile --dump-dmesg $vmcore $vmcore_dir/vmcore-dmesg.txt.2 || {
|
||||
test_output "Failed to retrive dmesg from vmcore!"
|
||||
return 1
|
||||
}
|
||||
elif [ -e $vmcore_dir/vmcore.flat ]; then
|
||||
vmcore=$vmcore_dir/vmcore.flat
|
||||
makedumpfile -R $vmcore_dir/vmcore < $vmcore || return 1
|
||||
makedumpfile --dump-dmesg $vmcore_dir/vmcore $vmcore_dir/vmcore-dmesg.txt.2 || {
|
||||
test_output "Failed to retrive dmesg from vmcore!"
|
||||
return 1
|
||||
}
|
||||
rm $vmcore_dir/vmcore
|
||||
else
|
||||
test_output "The vmcore dir is empty!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! diff -w $vmcore_dir/vmcore-dmesg.txt.2 $vmcore_dir/vmcore-dmesg.txt; then
|
||||
test_output "Dmesg retrived from vmcore is different from dump version!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
test_output "VMCORE: $vmcore"
|
||||
test_output "KERNEL VERSION: $(rpm -q kernel-core)"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
BOOT_COUNT=$(get_test_boot_count)
|
||||
test_output "Kexec-Kdump-Test Boot #$BOOT_COUNT"
|
||||
|
||||
echo 'fedora' | passwd --stdin root
|
||||
|
||||
test_output "Updating kernel cmdline"
|
||||
grubby --update-kernel ALL --args $BOOT_ARG=$(expr $BOOT_COUNT + 1) && sync
|
||||
|
||||
test_output "Executing test hook"
|
||||
source /kexec-kdump-test/test.sh
|
||||
|
||||
on_test;
|
||||
|
||||
test_output "Test exited, system hang for inspect"
|
@ -1,9 +0,0 @@
|
||||
[Unit]
|
||||
Description=Kexec Kdump Test Service
|
||||
|
||||
[Service]
|
||||
ExecStart=/kexec-kdump-test/init.sh
|
||||
Type=idle
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# A test example that do nothing
|
||||
|
||||
# Executed before VM starts
|
||||
on_build() {
|
||||
:
|
||||
}
|
||||
|
||||
# Executed when VM boots
|
||||
on_test() {
|
||||
:
|
||||
# call get_test_boot_count to get boot cound
|
||||
# call test_passed if test passed
|
||||
# call test_failed if test passed
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Check which virtualization technology to use
|
||||
# We prefer kvm, kqemu, userspace in that order.
|
||||
|
||||
# This script is based on https://github.com/dracutdevs/dracut/blob/master/test/run-qemu
|
||||
|
||||
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
[[ -x /usr/bin/qemu ]] && BIN=/usr/bin/qemu && ARGS="-cpu max"
|
||||
$(lsmod | grep -q '^kqemu ') && BIN=/usr/bin/qemu && ARGS="-kernel-kqemu -cpu host"
|
||||
[[ -c /dev/kvm && -x /usr/bin/kvm ]] && BIN=/usr/bin/kvm && ARGS="-cpu host"
|
||||
[[ -c /dev/kvm && -x /usr/bin/qemu-kvm ]] && BIN=/usr/bin/qemu-kvm && ARGS="-cpu host"
|
||||
[[ -c /dev/kvm && -x /usr/libexec/qemu-kvm ]] && BIN=/usr/libexec/qemu-kvm && ARGS="-cpu host"
|
||||
[[ -x /usr/bin/qemu-system-$(uname -i) ]] && BIN=/usr/bin/qemu-system-$(uname -i) && ARGS="-cpu max"
|
||||
[[ -c /dev/kvm && -x /usr/bin/qemu-system-$(uname -i) ]] && BIN=/usr/bin/qemu-system-$(uname -i) && ARGS="-enable-kvm -cpu host"
|
||||
|
||||
[[ $BIN ]] || {
|
||||
echo "Could not find a working KVM or QEMU to test with!" >&2
|
||||
echo "Please install kvm or qemu." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
exec $BIN $ARGS "$@"
|
@ -1,176 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
_kill_if_valid_pid() {
|
||||
local _pid="$1"
|
||||
if ps -p "$_pid" > /dev/null
|
||||
then
|
||||
kill "$_pid"
|
||||
fi
|
||||
}
|
||||
|
||||
_recursive_kill() {
|
||||
local _pid="$1"
|
||||
local _children _child
|
||||
|
||||
_children=$(pgrep -P "$_pid")
|
||||
if [ -n "$_children" ]; then
|
||||
for _child in $_children
|
||||
do
|
||||
_recursive_kill "$_child"
|
||||
_kill_if_valid_pid "$_child"
|
||||
done
|
||||
fi
|
||||
_kill_if_valid_pid "$_pid"
|
||||
}
|
||||
|
||||
_kill_all_jobs() {
|
||||
local _jobs=$(jobs -r -p)
|
||||
local _job
|
||||
|
||||
if [ -n "$_jobs" ]; then
|
||||
for _job in $_jobs
|
||||
do
|
||||
_recursive_kill "$_job"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
trap '
|
||||
ret=$?;
|
||||
_kill_all_jobs
|
||||
exit $ret;
|
||||
' EXIT
|
||||
|
||||
trap 'exit 1;' SIGINT
|
||||
|
||||
BASEDIR=$(realpath $(dirname "$0"))
|
||||
. $BASEDIR/test-lib.sh
|
||||
TESTCASEDIR="$BASEDIR/testcases"
|
||||
|
||||
console=0
|
||||
testcases=""
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
'')
|
||||
break
|
||||
;;
|
||||
--console )
|
||||
console=1
|
||||
;;
|
||||
-*)
|
||||
echo "Invalid option $1"
|
||||
;;
|
||||
*)
|
||||
testcases+=" $1"
|
||||
;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
|
||||
if [ -z "$testcases" ]; then
|
||||
echo "==== Starting all tests: ===="
|
||||
testcases=$(ls -1 $TESTCASEDIR)
|
||||
else
|
||||
echo "==== Starting specified tests: ===="
|
||||
fi
|
||||
echo ${testcases##*/}
|
||||
echo
|
||||
|
||||
declare -A results
|
||||
ret=0
|
||||
|
||||
for test_case in $testcases; do
|
||||
echo "======== Running Test Case $test_case ========"
|
||||
results[$test_case]="<Test Skipped>"
|
||||
|
||||
testdir=$TESTCASEDIR/$test_case
|
||||
scripts=$(ls -r -1 $testdir | egrep "\.sh$" | tr '\n' ' ')
|
||||
test_outputs=""
|
||||
read main_script aux_script <<< "$scripts"
|
||||
|
||||
if [ -z "$main_script" ]; then
|
||||
echo "ERROR: Empty testcase dir $testdir"
|
||||
continue
|
||||
fi
|
||||
|
||||
for script in $scripts; do
|
||||
echo "---- Building image for: $script ----"
|
||||
echo "-------- Output image is: $(get_test_image $testdir/$script)"
|
||||
echo "-------- Building log is: $(get_test_image $testdir/$script).log"
|
||||
|
||||
mkdir -p $(dirname $(get_test_image $testdir/$script))
|
||||
build_test_image $testdir/$script &> $(get_test_image $testdir/$script).log
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failing building image!"
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
|
||||
for script in $aux_script; do
|
||||
echo "---- Starting VM: $script ----"
|
||||
|
||||
script="$testdir/$script"
|
||||
echo "-------- Qemu cmdline: $(get_test_qemu_cmd_file $script)"
|
||||
echo "-------- Console log: $(get_test_console_file $script)"
|
||||
echo "-------- Test log: $(get_test_output_file $script)"
|
||||
test_outputs+="$(get_test_output_file $script) "
|
||||
|
||||
rm -f $(get_test_console_file $script)
|
||||
rm -f $(get_test_output_file $script)
|
||||
|
||||
$(run_test_sync $script > $(get_test_console_file $script)) &
|
||||
|
||||
sleep 5
|
||||
done
|
||||
|
||||
script="$main_script"
|
||||
echo "---- Starting test VM: $(basename $script) ----"
|
||||
script="$testdir/$script"
|
||||
|
||||
echo "-------- Qemu cmdline: $(get_test_qemu_cmd_file $script)"
|
||||
echo "-------- Console log: $(get_test_console_file $script)"
|
||||
echo "-------- Test log: $(get_test_output_file $script)"
|
||||
test_outputs+="$(get_test_output_file $script) "
|
||||
|
||||
rm -f $(get_test_console_file $script)
|
||||
rm -f $(get_test_output_file $script)
|
||||
|
||||
if [ $console -eq 1 ]; then
|
||||
run_test_sync $script | tee $(get_test_console_file $script)
|
||||
[ -n "$(jobs -p)" ] && wait $(jobs -p)
|
||||
else
|
||||
$(run_test_sync $script > $(get_test_console_file $script)) &
|
||||
watch_test_outputs $test_outputs
|
||||
fi
|
||||
|
||||
res="$(gather_test_result $test_outputs)"
|
||||
|
||||
[ $? -ne 0 ] && ret=$(expr $ret + 1)
|
||||
results[$test_case]="$res"
|
||||
_kill_all_jobs
|
||||
echo -e "-------- Test finished: $test_case $res --------"
|
||||
for script in $scripts; do
|
||||
script="$testdir/$script"
|
||||
output="$(get_test_output_file $script) "
|
||||
image="$(get_test_image $script)"
|
||||
vmcore="$(sed -n 's/^VMCORE: \(\S*\).*/\1/p' $output)"
|
||||
kernel="$(sed -n 's/^KERNEL VERSION: \(\S*\).*/\1/p' $output)"
|
||||
if [ -n "$vmcore" ]; then
|
||||
echo "You can retrive the verify the vmcore file using following command:"
|
||||
echo "./scripts/copy-from-image.sh \\"
|
||||
echo " $image \\"
|
||||
echo " $vmcore ./"
|
||||
echo "Kernel package verion is: $kernel"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo "======== Test results ========"
|
||||
for i in ${!results[@]}; do
|
||||
echo "----------------"
|
||||
echo -e "$i:\t\t${results[$i]}"
|
||||
done
|
||||
|
||||
exit $ret
|
@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BASEDIR=$(realpath $(dirname "$0"))
|
||||
. $BASEDIR/image-init-lib.sh
|
||||
|
||||
# Base image to build from
|
||||
BOOT_IMAGE=$1
|
||||
if [[ ! -e $BOOT_IMAGE ]]; then
|
||||
perror_exit "Image '$BOOT_IMAGE' not found"
|
||||
else
|
||||
BOOT_IMAGE=$(realpath "$BOOT_IMAGE")
|
||||
fi
|
||||
|
||||
mount_image $BOOT_IMAGE
|
||||
|
||||
shell_in_image $BOOT_IMAGE
|
@ -1,176 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
[ -z "$BASEDIR" ] && BASEDIR=$(realpath $(dirname "$0"))
|
||||
[ -z "$TESTDIR" ] && TESTDIR=$(realpath $BASEDIR/../)
|
||||
[ -z "$TEST_BASE_IMAGE" ] && TEST_BASE_IMAGE=$TESTDIR/output/test-base-image
|
||||
|
||||
[[ ! -e $TEST_BASE_IMAGE ]] && echo "Test base image not found." && exit 1
|
||||
|
||||
DEFAULT_QEMU_CMD="-nodefaults \
|
||||
-nographic \
|
||||
-smp 2 \
|
||||
-m 1G \
|
||||
-monitor none"
|
||||
|
||||
_YELLOW='\033[1;33m'
|
||||
_GREEN='\033[0;32m'
|
||||
_RED='\033[0;31m'
|
||||
_NC='\033[0m' # No Color
|
||||
|
||||
get_test_path() {
|
||||
local script=$1
|
||||
local testname=$(basename $(dirname $script))
|
||||
local output=$TESTDIR/output/$testname
|
||||
|
||||
echo $output
|
||||
}
|
||||
|
||||
get_test_entry_name() {
|
||||
echo $(basename ${1%.*})
|
||||
}
|
||||
|
||||
get_test_image() {
|
||||
local script=$1
|
||||
local testout=$(get_test_path $script)
|
||||
local entry=$(get_test_entry_name $script)
|
||||
|
||||
echo $testout/$entry.img
|
||||
}
|
||||
|
||||
get_test_qemu_cmd_file() {
|
||||
local script=$1
|
||||
local testout=$(get_test_path $script)
|
||||
local entry=$(get_test_entry_name $script)
|
||||
|
||||
echo $testout/$entry.qemu_cmd
|
||||
}
|
||||
|
||||
get_test_qemu_cmd() {
|
||||
cat $(get_test_qemu_cmd_file $1)
|
||||
}
|
||||
|
||||
get_test_output_file() {
|
||||
local script=$1
|
||||
local testout=$(get_test_path $script)
|
||||
local entry=$(get_test_entry_name $script)
|
||||
|
||||
echo $testout/$entry.output
|
||||
}
|
||||
|
||||
get_test_console_file() {
|
||||
local script=$1
|
||||
local testout=$(get_test_path $script)
|
||||
local entry=$(get_test_entry_name $script)
|
||||
|
||||
echo $testout/$entry.console
|
||||
}
|
||||
|
||||
get_test_output() {
|
||||
local output=$(get_test_output_file $1)
|
||||
if [ -e "$output" ]; then
|
||||
cat $(get_test_output_file $1)
|
||||
else
|
||||
echo "<No Output>"
|
||||
fi
|
||||
}
|
||||
|
||||
build_test_image() {
|
||||
local script=$1
|
||||
local test_image=$(get_test_image $script)
|
||||
mkdir -p $(dirname $test_image)
|
||||
|
||||
$BASEDIR/build-image.sh \
|
||||
$TEST_BASE_IMAGE \
|
||||
$test_image \
|
||||
$BASEDIR/build-scripts/test-image.sh \
|
||||
$script
|
||||
}
|
||||
|
||||
run_test_sync() {
|
||||
local qemu_cmd=$(get_test_qemu_cmd $1)
|
||||
|
||||
if [ -n "$qemu_cmd" ]; then
|
||||
timeout --foreground 10m $BASEDIR/run-qemu $(get_test_qemu_cmd $1)
|
||||
else
|
||||
echo "error: test qemu command line is not configured" > /dev/stderr
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
_check_test_result() {
|
||||
grep "TEST PASSED" $1 2>/dev/null
|
||||
[ $? -eq 0 ] && return 0
|
||||
|
||||
grep "TEST FAILED" $1 2>/dev/null
|
||||
[ $? -eq 0 ] && return 1
|
||||
|
||||
grep "TEST ABORTED" $1 2>/dev/null
|
||||
[ $? -eq 0 ] && return 2
|
||||
|
||||
return 255
|
||||
}
|
||||
|
||||
# Print test result and return below value:
|
||||
# 0: Test passed
|
||||
# 1: Test failed
|
||||
# 2: Test aborted, test scripts errored out
|
||||
# 3: Test exited unexpectely, VM got killed early, or time out
|
||||
gather_test_result() {
|
||||
local ret=255
|
||||
local res=""
|
||||
|
||||
for i in $@; do
|
||||
res=$(_check_test_result $i)
|
||||
ret=$?
|
||||
|
||||
if [ $ret -ne 255 ]; then
|
||||
echo $res
|
||||
return $ret
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${_RED}TEST RESULT NOT FOUND!${_NC}"
|
||||
return 3
|
||||
}
|
||||
|
||||
# Wait and watch for test result
|
||||
watch_test_outputs() {
|
||||
local ret=255
|
||||
local res=""
|
||||
# If VMs are still running, check for test result, if
|
||||
# test finished, kill remaining VMs
|
||||
while true; do
|
||||
if [ -n "$(jobs -r)" ]; then
|
||||
# VMs still running
|
||||
for i in $@; do
|
||||
res=$(_check_test_result $i)
|
||||
ret=$?
|
||||
|
||||
if [ $ret -ne 255 ]; then
|
||||
# Test finished
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
else
|
||||
# VMs exited
|
||||
ret=255
|
||||
|
||||
for i in $@; do
|
||||
res=$(_check_test_result $i)
|
||||
ret=$?
|
||||
|
||||
if [ $ret -ne 255 ]; then
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $ret -eq 255 ]; then
|
||||
ret=3
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
return $ret
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
on_build() {
|
||||
:
|
||||
}
|
||||
|
||||
on_test() {
|
||||
local boot_count=$(get_test_boot_count)
|
||||
|
||||
if [ $boot_count -eq 1 ]; then
|
||||
cat << EOF > /etc/kdump.conf
|
||||
path /var/crash
|
||||
core_collector makedumpfile -l --message-level 7 -d 31
|
||||
EOF
|
||||
kdumpctl start || test_failed "Failed to start kdump"
|
||||
|
||||
sync
|
||||
|
||||
echo 1 > /proc/sys/kernel/sysrq
|
||||
echo c > /proc/sysrq-trigger
|
||||
|
||||
elif [ $boot_count -eq 2 ]; then
|
||||
|
||||
if has_valid_vmcore_dir /var/crash; then
|
||||
test_passed
|
||||
else
|
||||
test_failed "Vmcore missing"
|
||||
fi
|
||||
|
||||
shutdown -h 0
|
||||
else
|
||||
test_failed "Unexpected reboot"
|
||||
fi
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
on_build() {
|
||||
TEST_DIR_PREFIX=/tmp/lvm_test.XXXXXX
|
||||
# clear TEST_DIRs if any
|
||||
rm -rf ${TEST_DIR_PREFIX%.*}.*
|
||||
TEST_IMG="$(mktemp -d $TEST_DIR_PREFIX)/test.img"
|
||||
|
||||
img_inst_pkg "lvm2"
|
||||
img_inst $TESTDIR/scripts/testcases/lvm2-thinp-kdump/lvm.conf /etc/lvm/
|
||||
dd if=/dev/zero of=$TEST_IMG bs=300M count=1
|
||||
# The test.img will be /dev/sdb
|
||||
img_add_qemu_cmd "-hdb $TEST_IMG"
|
||||
}
|
||||
|
||||
on_test() {
|
||||
VG=vg00
|
||||
LV_THINPOOL=thinpool
|
||||
LV_VOLUME=thinlv
|
||||
VMCORE_PATH=var/crash
|
||||
|
||||
local boot_count=$(get_test_boot_count)
|
||||
|
||||
if [ $boot_count -eq 1 ]; then
|
||||
|
||||
vgcreate $VG /dev/sdb
|
||||
# Create a small thinpool which is definitely not enough for
|
||||
# vmcore, then create a thin volume which is definitely enough
|
||||
# for vmcore, so we can make sure thinpool should be autoextend
|
||||
# during runtime.
|
||||
lvcreate -L 10M -T $VG/$LV_THINPOOL
|
||||
lvcreate -V 300M -T $VG/$LV_THINPOOL -n $LV_VOLUME
|
||||
mkfs.ext4 /dev/$VG/$LV_VOLUME
|
||||
mount /dev/$VG/$LV_VOLUME /mnt
|
||||
mkdir -p /mnt/$VMCORE_PATH
|
||||
|
||||
cat << EOF > /etc/kdump.conf
|
||||
ext4 /dev/$VG/$LV_VOLUME
|
||||
path /$VMCORE_PATH
|
||||
core_collector makedumpfile -l --message-level 7 -d 31
|
||||
EOF
|
||||
kdumpctl start || test_failed "Failed to start kdump"
|
||||
|
||||
sync
|
||||
|
||||
echo 1 > /proc/sys/kernel/sysrq
|
||||
echo c > /proc/sysrq-trigger
|
||||
|
||||
elif [ $boot_count -eq 2 ]; then
|
||||
mount /dev/$VG/$LV_VOLUME /mnt
|
||||
if has_valid_vmcore_dir /mnt/$VMCORE_PATH; then
|
||||
test_passed
|
||||
else
|
||||
test_failed "Vmcore missing"
|
||||
fi
|
||||
|
||||
shutdown -h 0
|
||||
else
|
||||
test_failed "Unexpected reboot"
|
||||
fi
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
activation {
|
||||
thin_pool_autoextend_threshold = 70
|
||||
thin_pool_autoextend_percent = 20
|
||||
monitoring = 1
|
||||
}
|
@ -1 +0,0 @@
|
||||
../nfs-kdump/0-server.sh
|
@ -1,46 +0,0 @@
|
||||
# Executed before VM starts
|
||||
on_build() {
|
||||
img_inst_pkg "nfs-utils"
|
||||
img_add_qemu_cmd "-nic socket,connect=127.0.0.1:8010,mac=52:54:00:12:34:57"
|
||||
}
|
||||
|
||||
on_test() {
|
||||
local boot_count=$(get_test_boot_count)
|
||||
local nfs_server=192.168.77.1
|
||||
local earlykdump_path="/usr/lib/dracut/modules.d/99earlykdump/early-kdump.sh"
|
||||
local tmp_file="/tmp/.tmp-file"
|
||||
|
||||
if [[ ! -f $earlykdump_path ]]; then
|
||||
test_failed "early-kdump.sh not exist!"
|
||||
fi
|
||||
|
||||
if [ $boot_count -eq 1 ]; then
|
||||
cat << EOF > /etc/kdump.conf
|
||||
nfs $nfs_server:/srv/nfs
|
||||
core_collector makedumpfile -l --message-level 7 -d 31
|
||||
final_action poweroff
|
||||
EOF
|
||||
|
||||
while ! ping -c 1 $nfs_server -W 1; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
kdumpctl start \
|
||||
|| test_failed "Failed to start kdump"
|
||||
grubby --update-kernel=ALL --args=rd.earlykdump
|
||||
|
||||
cat << EOF > $tmp_file
|
||||
echo 1 > /proc/sys/kernel/sysrq
|
||||
echo c > /proc/sysrq-trigger
|
||||
EOF
|
||||
sed -i "/early_kdump_load$/r $tmp_file" $earlykdump_path
|
||||
dracut -f --add earlykdump
|
||||
kdumpctl restart \
|
||||
|| test_failed "Failed to start earlykdump"
|
||||
|
||||
sync
|
||||
reboot
|
||||
else
|
||||
test_failed "Unexpected reboot"
|
||||
fi
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Executed before VM starts
|
||||
on_build() {
|
||||
img_inst_pkg "nfs-utils dnsmasq"
|
||||
|
||||
img_run_cmd "mkdir -p /srv/nfs/var/crash"
|
||||
img_run_cmd "echo /srv/nfs 192.168.77.1/24\(rw,async,insecure,no_root_squash\) > /etc/exports"
|
||||
img_run_cmd "systemctl enable nfs-server"
|
||||
|
||||
img_run_cmd "touch /etc/systemd/resolved.conf"
|
||||
img_run_cmd "echo DNSStubListener=no >> /etc/systemd/resolved.conf"
|
||||
|
||||
img_run_cmd "echo interface=eth0 > /etc/dnsmasq.conf"
|
||||
img_run_cmd "echo dhcp-authoritative >> /etc/dnsmasq.conf"
|
||||
img_run_cmd "echo dhcp-range=192.168.77.50,192.168.77.100,255.255.255.0,12h >> /etc/dnsmasq.conf"
|
||||
img_run_cmd "systemctl enable dnsmasq"
|
||||
|
||||
img_run_cmd 'echo [connection] > /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
img_run_cmd 'echo type=ethernet >> /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
img_run_cmd 'echo interface-name=eth0 >> /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
img_run_cmd 'echo [ipv4] >> /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
img_run_cmd 'echo address1=192.168.77.1/24 >> /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
img_run_cmd 'echo method=manual >> /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
img_run_cmd 'chmod 600 /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
|
||||
img_add_qemu_cmd "-nic socket,listen=:8010,mac=52:54:00:12:34:56"
|
||||
}
|
||||
|
||||
# Executed when VM boots
|
||||
on_test() {
|
||||
while true; do
|
||||
if has_valid_vmcore_dir /srv/nfs/var/crash; then
|
||||
# Wait a few seconds so client finish it's work to generate a full log
|
||||
sleep 5
|
||||
|
||||
test_passed
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
# Executed before VM starts
|
||||
on_build() {
|
||||
img_inst_pkg "nfs-utils"
|
||||
img_add_qemu_cmd "-nic socket,connect=127.0.0.1:8010,mac=52:54:00:12:34:57"
|
||||
}
|
||||
|
||||
on_test() {
|
||||
local boot_count=$(get_test_boot_count)
|
||||
local nfs_server=192.168.77.1
|
||||
|
||||
if [ "$boot_count" -eq 1 ]; then
|
||||
cat << EOF > /etc/kdump.conf
|
||||
nfs $nfs_server:/srv/nfs
|
||||
core_collector makedumpfile -l --message-level 7 -d 31
|
||||
EOF
|
||||
|
||||
while ! ping -c 1 $nfs_server -W 1; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
kdumpctl start || test_failed "Failed to start kdump"
|
||||
|
||||
sync
|
||||
|
||||
echo 1 > /proc/sys/kernel/sysrq
|
||||
echo c > /proc/sysrq-trigger
|
||||
else
|
||||
shutdown -h 0
|
||||
fi
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Executed before VM starts
|
||||
on_build() {
|
||||
img_add_qemu_cmd "-nic socket,listen=:8010,mac=52:54:00:12:34:56"
|
||||
|
||||
img_run_cmd "echo root:fedora | chpasswd"
|
||||
img_run_cmd 'sed -i "s/^.*PasswordAuthentication .*\$/PasswordAuthentication yes/" /etc/ssh/sshd_config'
|
||||
img_run_cmd 'sed -i "s/^.*PermitRootLogin .*\$/PermitRootLogin yes/" /etc/ssh/sshd_config'
|
||||
img_run_cmd "systemctl enable sshd"
|
||||
|
||||
img_run_cmd "touch /etc/systemd/resolved.conf"
|
||||
img_run_cmd "echo DNSStubListener=no >> /etc/systemd/resolved.conf"
|
||||
|
||||
img_run_cmd "echo interface=eth0 > /etc/dnsmasq.conf"
|
||||
img_run_cmd "echo dhcp-authoritative >> /etc/dnsmasq.conf"
|
||||
img_run_cmd "echo dhcp-range=192.168.77.50,192.168.77.100,255.255.255.0,12h >> /etc/dnsmasq.conf"
|
||||
img_run_cmd "systemctl enable dnsmasq"
|
||||
|
||||
img_run_cmd 'echo [connection] > /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
img_run_cmd 'echo type=ethernet >> /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
img_run_cmd 'echo interface-name=eth0 >> /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
img_run_cmd 'echo [ipv4] >> /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
img_run_cmd 'echo address1=192.168.77.1/24 >> /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
img_run_cmd 'echo method=manual >> /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
img_run_cmd 'chmod 600 /etc/NetworkManager/system-connections/eth0.nmconnection'
|
||||
}
|
||||
|
||||
# Executed when VM boots
|
||||
on_test() {
|
||||
while true; do
|
||||
if has_valid_vmcore_dir /var/crash; then
|
||||
test_passed
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
# Executed before VM starts
|
||||
on_build() {
|
||||
img_inst_pkg "sshpass"
|
||||
img_add_qemu_cmd "-nic socket,connect=127.0.0.1:8010,mac=52:54:00:12:34:57"
|
||||
}
|
||||
|
||||
on_test() {
|
||||
local boot_count=$(get_test_boot_count)
|
||||
local ssh_server=192.168.77.1
|
||||
|
||||
if [ "$boot_count" -eq 1 ]; then
|
||||
cat << EOF > /etc/kdump.conf
|
||||
ssh root@192.168.77.1
|
||||
core_collector makedumpfile -l --message-level 7 -d 31 -F
|
||||
EOF
|
||||
|
||||
ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa <<< y
|
||||
|
||||
while ! ping -c 1 $ssh_server -W 1; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
while [ -z "$(cat /root/.ssh/known_hosts)" ]; do
|
||||
ssh-keyscan -H 192.168.77.1 > /root/.ssh/known_hosts
|
||||
done
|
||||
|
||||
sshpass -p fedora ssh $ssh_server "mkdir /root/.ssh"
|
||||
cat /root/.ssh/id_rsa.pub | sshpass -p fedora ssh $ssh_server "cat >> /root/.ssh/authorized_keys"
|
||||
|
||||
sshpass -p fedora kdumpctl propagate
|
||||
cat /root/.ssh/kdump_id_rsa.pub | sshpass -p fedora ssh $ssh_server "cat >> /root/.ssh/authorized_keys"
|
||||
|
||||
kdumpctl start || test_failed "Failed to start kdump"
|
||||
|
||||
sync
|
||||
|
||||
echo 1 > /proc/sys/kernel/sysrq
|
||||
echo c > /proc/sysrq-trigger
|
||||
else
|
||||
shutdown -h 0
|
||||
fi
|
||||
}
|
Loading…
Reference in New Issue
Block a user