From 293ff98b1289a14094aa894bf50ab6018cf510f9 Mon Sep 17 00:00:00 2001 From: "Guilherme G. Piccoli" Date: Thu, 19 Jan 2023 10:35:51 -0300 Subject: [PATCH] kdump-load: Improve vmlinux binary path obtaining Currently we just look the command-line for the systemd BOOT_IMAGE entry and try to load the vmlinux as described there. But in the field we noticed we have 2 patterns: either this cmdline entry is complete/correct and maps to the vmlinux binary, OR it shows the name of the file but not the full path (Arch case). So, let's hereby attempt prepending /boot in case the validation for the first case fails - if both ways don't work, we just fail kdump for now. Signed-off-by: Guilherme G. Piccoli --- kdump-load.sh.in | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kdump-load.sh.in b/kdump-load.sh.in index f343bba..350e7da 100644 --- a/kdump-load.sh.in +++ b/kdump-load.sh.in @@ -182,7 +182,18 @@ grub_update kdump KDUMP_CMDLINE=$(sed -re 's/(^| )(crashkernel|hugepages|hugepagesz)=[^ ]*//g;s/"/\\\\"/' /proc/cmdline) KDUMP_CMDLINE="${KDUMP_CMDLINE} panic=-1 oops=panic fsck.mode=force fsck.repair=yes nr_cpus=1 reset_devices" +# To obtain the vmlinux binary path, try first using directly the command-line +# information. If it fails, then attempt prepending /boot into that (faced +# both situations in the field so far). VMLINUX="$(grep -o 'BOOT_IMAGE=[^ ]*' /proc/cmdline)" +VMLINUX="${VMLINUX#*BOOT_IMAGE=}" +if [ ! -s "${VMLINUX}" ]; then + VMLINUX="/boot/${VMLINUX}" + if [ ! -s "${VMLINUX}" ]; then + logger "kdump: couldn't find the kernel image" + exit 1 + fi +fi # In case we don't have a valid initrd, for some reason, try creating # one before loading kdump (or else it will fail). @@ -191,7 +202,7 @@ if [ ! -s "${INITRD_FNAME}" ]; then create_initrd fi -if ! kexec -s -p "${VMLINUX#*BOOT_IMAGE=}" --initrd "${INITRD_FNAME}" --append="${KDUMP_CMDLINE}"; then +if ! kexec -s -p "${VMLINUX}" --initrd "${INITRD_FNAME}" --append="${KDUMP_CMDLINE}"; then logger "kdump: kexec load failed" exit 1 fi