raw core_collector fix

1. only append '-F' for default core_collector internally
2. error out if user does not add '-F' for makedumpfile

v1->v2: refresh because of new core collector verify function
v2->v3: optimize the code, remove local variable for default core_collector

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
Dave Young 2012-06-14 09:57:07 +08:00
parent 2697669fa9
commit b30eb78ab2
2 changed files with 20 additions and 7 deletions

View File

@ -93,7 +93,6 @@ dump_raw()
monitor_dd_progress $_src_size_mb & monitor_dd_progress $_src_size_mb &
CORE_COLLECTOR=`echo $CORE_COLLECTOR | sed -e's/\(^makedumpfile\)\(.*$\)/\1 -F \2/'`
$CORE_COLLECTOR /proc/vmcore | dd of=$1 bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1 $CORE_COLLECTOR /proc/vmcore | dd of=$1 bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1
return 0 return 0
} }
@ -138,6 +137,11 @@ is_ssh_dump_target()
grep -q "^net.*@" $conf_file grep -q "^net.*@" $conf_file
} }
is_raw_dump_target()
{
grep -q "^raw" $conf_file
}
read_kdump_conf() read_kdump_conf()
{ {
if [ ! -f "$conf_file" ]; then if [ ! -f "$conf_file" ]; then
@ -205,7 +209,9 @@ read_kdump_conf
if [ -z "$CORE_COLLECTOR" ];then if [ -z "$CORE_COLLECTOR" ];then
CORE_COLLECTOR=$DEFAULT_CORE_COLLECTOR CORE_COLLECTOR=$DEFAULT_CORE_COLLECTOR
is_ssh_dump_target && CORE_COLLECTOR="$CORE_COLLECTOR -F" if is_ssh_dump_target || is_raw_dump_target; then
CORE_COLLECTOR="$CORE_COLLECTOR -F"
fi
fi fi
if [ -z "$DUMP_INSTRUCTION" ]; then if [ -z "$DUMP_INSTRUCTION" ]; then

View File

@ -96,16 +96,23 @@ is_ssh_dump_target()
grep -q "^net.*@" $conf_file grep -q "^net.*@" $conf_file
} }
is_raw_dump_target()
{
grep -q "^raw" $conf_file
}
# $1: core_collector config value # $1: core_collector config value
verify_core_collector() { verify_core_collector() {
if grep -q "^raw" $conf_file && [ "${1%% *}" != "makedumpfile" ]; then if grep -q "^raw" $conf_file && [ "${1%% *}" != "makedumpfile" ]; then
echo "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually." echo "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
fi fi
if is_ssh_dump_target && [ "${1%% *}" = "makedumpfile" ]; then if is_ssh_dump_target || is_raw_dump_target; then
! strstr "$1" "-F" && { if [ "${1%% *}" = "makedumpfile" ]; then
echo "The specified dump target needs makedumpfile \"-F\" option." ! strstr "$1" "-F" && {
exit 1 echo "The specified dump target needs makedumpfile \"-F\" option."
} exit 1
}
fi
fi fi
} }