Skip to content

Commit 5438235

Browse files
committed
Add Kdump option to disable reboot after save_core
By default, Kdump copies the entire vmcore to the disk and reboots the system afterwards. While this works in most cases, it does not work for systems hosted in RAM where the crash dump will be lost once rebooted. To support this scenario, a new option in the kdump.conf, save_core_to_ram, is added and commented out. Setting this option to 1 will allow a compressed crash dump to be produced by utilizing the core_collector option if specified, otherwise the dmesg log will be extracted from the vmcore. This is especially necessary because there is no disk to save the dump to, and there is not enough space in the pre-allocated crashkernel memory space to save an entire vmcore.
1 parent 63d05a5 commit 5438235

4 files changed

Lines changed: 51 additions & 6 deletions

File tree

SPECS/kexec-tools/kdump.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@
162162
# to send fence_kdump notifications to.
163163
# (this option is mandatory to enable fence_kdump).
164164
#
165+
# save_core_to_ram <0 | 1>
166+
# - By default, the entire vmcore gets copied and the system reboots
167+
# after the crash dump is saved. Enabling this option by specifying
168+
# 1 will instead save a compressed dump and not reboot after the
169+
# dump is saved. The core_collector option, if also specified, is
170+
# used to determine how the crash dump should be compressed. If the
171+
# core_collector option is not set, then only the dmesg log will
172+
# be saved.
173+
#
174+
# This option is particularly useful when the operating system is
175+
# running in RAM and reboots would otherwise remove the crash dump.
176+
#
165177

166178
#raw /dev/vg/lv_kdump
167179
#ext4 /dev/vg/lv_kdump
@@ -183,3 +195,4 @@ core_collector makedumpfile -l --message-level 1 -d 31
183195
#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"
184196
#fence_kdump_args -p 7410 -f auto -c 0 -i 10
185197
#fence_kdump_nodes node1 node2
198+
#save_core_to_ram 0

SPECS/kexec-tools/kdumpctl

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ save_core()
8787
fi
8888
}
8989

90+
save_core_to_ram()
91+
{
92+
coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`"
93+
mkdir -p $coredir
94+
CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut -d\ -f1 --complement`
95+
96+
if [[ -n $CORE_COLLECTOR ]]; then
97+
$CORE_COLLECTOR /proc/vmcore $coredir/vmcore
98+
else
99+
makedumpfile -l --message-level 1 -d 31 /proc/vmcore $coredir/vmcore
100+
fi
101+
}
102+
90103
rebuild_fadump_initrd()
91104
{
92105
local target_initrd_tmp
@@ -243,7 +256,7 @@ check_config()
243256
case "$config_opt" in
244257
\#* | "")
245258
;;
246-
raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|final_action|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes)
259+
raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|final_action|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes|save_core_to_ram)
247260
# remove inline comments after the end of a directive.
248261
[ -z "$config_val" ] && {
249262
echo "Invalid kdump config value for option $config_opt."
@@ -1248,8 +1261,24 @@ main ()
12481261
case "$1" in
12491262
start)
12501263
if [ -s /proc/vmcore ]; then
1251-
save_core
1252-
reboot
1264+
local _save_core_to_ram save_core_to_ram="0"
1265+
_save_core_to_ram=`grep ^save_core_to_ram $KDUMP_CONFIG_FILE 2>/dev/null`
1266+
1267+
if [ $? -eq 0 ]; then
1268+
save_core_to_ram=`echo $_save_core_to_ram | cut -d' ' -f2`
1269+
1270+
if [ "$save_core_to_ram" != "0" ] && [ "$save_core_to_ram" != "1" ]; then
1271+
echo "Error: save_core_to_ram value is invalid"
1272+
exit 1
1273+
fi
1274+
fi
1275+
1276+
if [ "$save_core_to_ram" == "1" ]; then
1277+
save_core_to_ram
1278+
else
1279+
save_core
1280+
reboot
1281+
fi
12531282
else
12541283
start
12551284
fi

SPECS/kexec-tools/kexec-tools.signatures.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
"kdump-lib-initramfs.sh": "ff4b63f99470ee796fd7e4a532dde241c4da02909306926a08a172457775a92a",
2121
"kdump-lib.sh": "3d50507626d4a92b8448c7d6604923f6f460c4cb5c8b18977381a7d5e516dfba",
2222
"kdump-udev-throttler": "125d538a59172f779b40ea32fea1e4eb50d849f25eb2537a48328d4401136679",
23-
"kdump.conf": "c4cd6c4a2f00e7df10d939bc2f35f8b6b8a3edd71245aa3ba0d7fff53d9f42e8",
23+
"kdump.conf": "2e65b6237560286f74530e104ee6556387b5c08ced883b1bb0a443d1e6d3c0cb",
2424
"kdump.conf.5": "bab6c7b171f76e8c6df91bb7db852815caacbc3cd3d4309a1dc58d36950440e4",
2525
"kdump.service": "ed8d22fafa6cfafaddcfd9fec82e3fa7fa42aa0366f69676fafa97e200b0506a",
2626
"kdump.sysconfig": "d03a24659c08aa4ce5a8e54edbe64e149f8c572c76c4e338d84dbdfbeab8fb63",
2727
"kdump.sysconfig.aarch64": "a829f3a0f88d983ccec2782b048f12a2eafca71aac4dd42acac2eaea8f7dd8d9",
2828
"kdump.sysconfig.i386": "1175bcc11be49841d4b8c3f9612e68bb7b2e0e8f00067ffa782fd9dba04f821d",
2929
"kdump.sysconfig.x86_64": "850b3be780165d0721edb8d34b2ba28aafc60b29850ff627daf04190369e359c",
30-
"kdumpctl": "34976fa2ca34a455f393d2ac212a628d73ba4113b44f0e819c3cb5b1195e504b",
30+
"kdumpctl": "bc2cf0374bef39baf2b4ae38c1218bab30ffec8e1e90fa57fce21cdd9d61982c",
3131
"kdumpctl.8": "025a39d212eed0584da7c23c1bb50d6ab797a0fa3c686ac6b80391af875dbaec",
3232
"kexec-kdump-howto.txt": "e783390a9aa582a2b5e7981cd3277081385340b5873a3f0633c789811876eccb",
3333
"kexec-tools-2.0.27.tar.xz": "38d78bcfa33a88928324b57dc81f50c1dfc279eede45e80957ca18f4e84b8187",

SPECS/kexec-tools/kexec-tools.spec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Summary: The kexec/kdump userspace component
77
Name: kexec-tools
88
Version: 2.0.27
9-
Release: 7%{?dist}
9+
Release: 8%{?dist}
1010
License: GPLv2
1111
Vendor: Microsoft Corporation
1212
Distribution: Azure Linux
@@ -330,6 +330,9 @@ done
330330
/usr/share/makedumpfile/
331331

332332
%changelog
333+
* Mon Dec 13 2024 Nicholas Angelastro <nangelastro@microsoft.com> - 2.0.27-8
334+
- Support saving crash dumps on systems hosted in RAM
335+
333336
* Tue Jul 09 2024 Chris Co <chrco@microsoft.com> - 2.0.27-7
334337
- Remove requires on dhcp-client
335338

0 commit comments

Comments
 (0)