We add a generic hook named kdump_target_hook() for the
dump target, this is useful for us to do some extra work
for different types of dump targets.
kdump_target_check() is exported as a generic helper that
can be used as some specific purpose.
We will use this mechanism in the following patch.
Signed-off-by: Xunlei Pang <xlpang(a)redhat.com>
---
kdump-lib.sh | 13 ++++++++++
mkdumprd | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 96 insertions(+), 1 deletion(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 0f74b8e..aafa21e 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -418,3 +418,16 @@ is_fadump_capable()
fi
return 1
}
+
+# $1: item
+# Did the item left a tag in the inventory?
+# return: 0 means surely left; 1 means surely not
+kdump_target_check()
+{
+ local item=$1 tag
+
+ tag=$(eval echo '${KDUMP_TARGET_TAG_'${item}'}')
+ [ -n "$tag" ] && return 0
+
+ return 1
+}
diff --git a/mkdumprd b/mkdumprd
index 892e59a..392eb7f 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -11,6 +11,9 @@
. /lib/kdump/kdump-lib.sh
export IN_KDUMP=1
+# See kdump_target_XXX()
+KDUMP_TARGET_CHECKLIST=""
+
conf_file="/etc/kdump.conf"
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2)
@@ -250,6 +253,65 @@ add_mount() {
add_dracut_mount "$_mnt"
}
+# $1: ssh, nfs, or block dev name
+kdump_target_hook()
+{
+ local dev=$1
+
+ # Do not support fadump currently
+ if is_fadump_capable; then
+ return
+ fi
+
+ # Ignore non-block device currently
+ if ! [ -b "$dev" ]; then
+ return
+ fi
+
+ dev=$(get_persistent_dev $dev)
+ kdump_target_checklist "$KDUMP_TARGET_CHECKLIST" $dev
+}
+
+# $1: items to be checked
+# $2: persistent block dev name
+kdump_target_checklist()
+{
+ local items=$1 pdev=$2
+
+ for item in $items; do
+ kdump_target_handle $item $pdev
+ done
+}
+
+# $1: the item to be checked
+# $2: persistent block dev name
+#
+# You can add an item in KDUMP_TARGET_CHECKLIST, handle it here
+# and leave its tag(KDUMP_TARGET_TAG_$item) in the tag inventory
+# as needed.
+kdump_target_handle()
+{
+ local item=$1 pdev=$2
+ local tag
+
+ tag=KDUMP_TARGET_TAG_$item
+ # the item handling begins
+ case "$item" in
+ *)
+ echo "unhandled item in kdump target checklist"
+ return
+ esac
+
+ kdump_target_leave_tag $tag
+}
+
+# Leave the tag in the tag inventory.
+# $1: tag
+kdump_target_leave_tag()
+{
+ eval export $1=1
+}
+
get_block_dump_target()
{
local _target
@@ -291,6 +353,8 @@ handle_default_dump_target()
_fstype=$(get_fs_type_from_target $_target)
add_mount "$_target"
check_size fs $_target
+
+ kdump_target_hook $_target
}
get_default_action_target()
@@ -459,6 +523,12 @@ do
add_mount "$config_val"
check_save_path_fs $_absolute_save_path
check_size fs $config_val
+
+ if [ $config_opt = "nfs" ]; then
+ kdump_target_hook "nfs"
+ else
+ kdump_target_hook $config_val
+ fi
;;
raw)
#checking raw disk writable
@@ -471,6 +541,7 @@ do
fi
add_dracut_arg "--device" "$_praw"
check_size raw $config_val
+ kdump_target_hook $_praw
;;
ssh)
if strstr "$config_val" "@";
@@ -478,7 +549,8 @@ do
check_size ssh $config_val
mkdir_save_path_ssh $config_val
add_dracut_module "ssh-client"
- add_dracut_sshkey "$SSH_KEY_LOCATION"
+ add_dracut_sshkey "$SSH_KEY_LOCATION"
+ kdump_target_hook "ssh"
else
perror_exit "Bad ssh dump target $config_val"
fi
@@ -488,6 +560,16 @@ do
;;
dracut_args)
add_dracut_arg $config_val
+
+ dracut_args_dev=$(get_dracut_args_target "$config_val")
+ if [ -n "$dracut_args_dev" ]; then
+ dracut_args_fstype=$(get_dracut_args_fstype "$config_val")
+ if is_fs_type_nfs $dracut_args_fstype ; then
+ kdump_target_hook "nfs"
+ else
+ kdump_target_hook $dracut_args_dev
+ fi
+ fi
;;
*)
if [ -n $(echo $config_opt | grep "^#.*$") ]
--
1.8.3.1