Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions dracut-kdump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,8 @@ save_opalcore_fs()
return 0
}

dump_to_rootfs()
try_mount_sysroot()
{

if [ "$(systemctl status dracut-initqueue | sed -n "s/^\s*Active: \(\S*\)\s.*$/\1/p")" = "inactive" ]; then
dinfo "Trying to bring up initqueue for rootfs mount"
systemctl start dracut-initqueue
fi

dinfo "Clean up dead systemd services"
systemctl cancel
dinfo "Waiting for rootfs mount, will timeout after 90 seconds"
systemctl start --no-block sysroot.mount

Expand All @@ -258,6 +250,23 @@ dump_to_rootfs()

if ! is_mounted /sysroot; then
derror "Failed to mount rootfs"
return 1
fi
return 0
}

dump_to_rootfs()
{

if [ "$(systemctl status dracut-initqueue | sed -n "s/^\s*Active: \(\S*\)\s.*$/\1/p")" = "inactive" ]; then
dinfo "Trying to bring up initqueue for rootfs mount"
systemctl start dracut-initqueue
fi

dinfo "Clean up dead systemd services"
systemctl cancel

if ! try_mount_sysroot; then
return
fi

Expand Down Expand Up @@ -312,11 +321,19 @@ do_final_action()

do_dump()
{
if ! try_mount_sysroot; then
return 1
fi
set_vmcore_creation_status 'clear' "/sysroot/$VMCORE_CREATION_STATUS"

eval $DUMP_INSTRUCTION
_ret=$?

if [ $_ret -ne 0 ]; then
set_vmcore_creation_status 'fail' "/sysroot/$VMCORE_CREATION_STATUS"
derror "saving vmcore failed"
else
set_vmcore_creation_status 'success' "/sysroot/$VMCORE_CREATION_STATUS"
fi

return $_ret
Expand Down
4 changes: 4 additions & 0 deletions gen-kdump-sysconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ KDUMP_IMG="vmlinuz"
#What is the images extension. Relocatable kernels don't have one
KDUMP_IMG_EXT=""

# Enable vmcore creation notification by default, disable by setting
# VMCORE_CREATION_NOTIFICATION=""
VMCORE_CREATION_NOTIFICATION="yes"

# 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)
Expand Down
24 changes: 24 additions & 0 deletions kdump-lib-initramfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ KDUMP_CONFIG_FILE="/etc/kdump.conf"
FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump"
FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send"
LVM_CONF="/etc/lvm/lvm.conf"
VMCORE_CREATION_STATUS="/var/crash/vmcore-creation.status"

# Read kdump config in well formated style
kdump_read_conf()
Expand Down Expand Up @@ -171,3 +172,26 @@ kdump_get_ip_route_field()
{
echo "$1" | sed -n -e "s/^.*\<$2\>\s\+\(\S\+\).*$/\1/p"
}

# $1: success/fail/clear
# $2: status_file
set_vmcore_creation_status()
{
_status=$1
_status_file=$2
_dir=${_status_file%%${_status_file##*/}}

[[ -d "$_dir" ]] || mkdir -p "$_dir"

case "$_status" in
success | fail)
echo "$_status $(date +%s)" > "$_status_file"
;;
clear)
rm -f "$_status_file"
;;
*)
return
esac
sync -f "$_dir"
}
29 changes: 29 additions & 0 deletions kdumpctl
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ rebuild_initrd()
else
rebuild_kdump_initrd
fi

set_vmcore_creation_status 'clear' "$VMCORE_CREATION_STATUS"
}

#$1: the files to be checked with IFS=' '
Expand Down Expand Up @@ -1063,6 +1065,7 @@ start()
start_dump || return

dinfo "Starting kdump: [OK]"
check_vmcore_creation_status
return 0
}

Expand Down Expand Up @@ -1668,6 +1671,31 @@ _should_reset_crashkernel() {
[[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]] && systemctl is-enabled kdump &> /dev/null
}

check_vmcore_creation_status()
{
local _record _status _timestamp _status_date

if [[ -z "$VMCORE_CREATION_NOTIFICATION" ]]; then
return
fi

if [[ ! -s $VMCORE_CREATION_STATUS ]]; then
dwarn "Fail: No vmcore creation test performed!"
return
fi

_record=$(cat "$VMCORE_CREATION_STATUS")
_status=$(echo $_record | awk '{print $1}')
_timestamp=$(echo $_record | awk '{print $2}')
_status_date=$(echo "@"$_timestamp | xargs date -d 2> /dev/null)

if [[ "$_status" == "success" ]]; then
dinfo "Success: Last successful vmcore creation on $_status_date"
else
dwarn "Fail: Last unsuccessful vmcore creation on $_status_date"
fi
}

main()
{
# Determine if the dump mode is kdump or fadump
Expand Down Expand Up @@ -1699,6 +1727,7 @@ main()
EXIT_CODE=3
;;
esac
check_vmcore_creation_status
exit $EXIT_CODE
;;
reload)
Expand Down
5 changes: 2 additions & 3 deletions mkdumprd
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,8 @@ fi
# 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)")"
# Always mount rootfs since we will create VMCORE_CREATION_STATUS file
add_mount "$(to_dev_name "$(get_root_fs_device)")"

add_dracut_arg "--no-hostonly-default-device"

Expand Down