From c616b97dfb3a8700c9358cbfb65c1969aa7bf1f8 Mon Sep 17 00:00:00 2001 From: "dyoung@redhat.com" Date: Mon, 12 Nov 2012 16:51:03 +0800 Subject: [PATCH] get MEM_RESERVED from sysfs attribute Resolves: bz866357 MEM_RESERVED is for checking if crash memory is reserved or not. Originally it use /proc/iomem for x86, parsing /proc/cmdline for ppc. This cause problems for crashkernel=auto, because it does not fit for the regular expression of [0-9]\+[MmKkGg]@[0-9]\+[MmGgKk] Fix this by use /sys/kernel/kexec_crash_size for all arches. After the fix the code is more clear than before. [v1->v2] vivek: add space between "crash kernel"; remove misleading warning. Tested-by: Chao Wang Signed-off-by: Dave Young Acked-by: Vivek Goyal --- kdumpctl | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/kdumpctl b/kdumpctl index 3e6618b..6c1cf2a 100755 --- a/kdumpctl +++ b/kdumpctl @@ -156,30 +156,14 @@ function need_64bit_headers() # as the currently running kernel. function load_kdump() { - - if [ -z "$KDUMP_COMMANDLINE" ] + MEM_RESERVED=$(cat /sys/kernel/kexec_crash_size) + if [ $MEM_RESERVED -eq 0 ] then - KDUMP_COMMANDLINE=`cat /proc/cmdline` - fi - - ARCH=`uname -m` - if [ "$ARCH" == "ppc64" ] - then - MEM_RESERVED=`grep "crashkernel=[0-9]\+[MmKkGg]@[0-9]\+[MmGgKk]" /proc/cmdline` - if [ -z "$MEM_RESERVED" ] - then - MEM_RESERVED=`grep "crashkernel=[0-9]\+[MmKkGg]" /proc/cmdline` - fi - else - MEM_RESERVED=`grep "Crash kernel" /proc/iomem | grep -v "00000000-00000000"` - fi - - if [ -z "$MEM_RESERVED" ] - then - $LOGGER "No crashkernel parameter specified for running kernel" + $LOGGER "No memory reserved for crash kernel." return 1 fi + ARCH=`uname -m` if [ "$ARCH" == "i686" -o "$ARCH" == "i386" ] then @@ -203,6 +187,11 @@ function load_kdump() fi fi + if [ -z "$KDUMP_COMMANDLINE" ] + then + KDUMP_COMMANDLINE=`cat /proc/cmdline` + fi + KDUMP_COMMANDLINE=`echo $KDUMP_COMMANDLINE | sed -e 's/crashkernel=[^ ]*//'` KDUMP_COMMANDLINE="${KDUMP_COMMANDLINE} ${KDUMP_COMMANDLINE_APPEND}"