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 <chaowang@redhat.com>
Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
dyoung@redhat.com 2012-11-12 16:51:03 +08:00 committed by Dave Young
parent 4d9bb7face
commit c616b97dfb

View File

@ -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}"