[kexec-tools/f18] change the dump dir format to be more readable

Dave Young yangrr at fedoraproject.org
Fri Dec 14 09:24:51 UTC 2012


commit 3be6c1228e822fca98a72dac4e51893d164244e4
Author: Baoquan He <bhe at redhat.com>
Date:   Thu Dec 13 13:47:56 2012 +0800

    change the dump dir format to be more readable
    
    Resolves: bz880551
    
    Currently on fedora directory name of kdump is like 14.11.12-03:40:30.
    It's not as readable as RHEL6. The old format of dir is host_ip-date-time.
    This patch changes it back like ole one as below.
    192.168.122.234-2012-10-31-05:17:20
    
    If can't get HOST_IP for a network kudmp, we just fail. Becasue most
    likely any attempt to save dump will also fail.
    
    Signed-off-by: Baoquan He <bhe at redhat.com>
    Acked-by: Dave Young <dyoung at redhat.com>

 dracut-kdump.sh        |   32 +++++++++++++++++++++++++++++++-
 dracut-module-setup.sh |    2 ++
 2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 2ae746e..2a7e956 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -7,7 +7,8 @@ KDUMP_PATH="/var/crash"
 CORE_COLLECTOR=""
 DEFAULT_CORE_COLLECTOR="makedumpfile -c --message-level 1 -d 31"
 DEFAULT_ACTION="dump_rootfs"
-DATEDIR=`date +%d.%m.%y-%T`
+DATEDIR=`date +%Y.%m.%d-%T`
+HOST_IP='127.0.0.1'
 DUMP_INSTRUCTION=""
 SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
 KDUMP_SCRIPT_DIR="/kdumpscripts"
@@ -119,11 +120,31 @@ is_ssh_dump_target()
     grep -q "^ssh[[:blank:]].*@" $conf_file
 }
 
+is_nfs_dump_target()
+{
+    grep -q "^nfs.*:" $conf_file
+}
+
 is_raw_dump_target()
 {
     grep -q "^raw" $conf_file
 }
 
+get_host_ip()
+{
+    if is_nfs_dump_target || is_ssh_dump_target
+    then
+        kdumpnic=$(getarg kdumpnic=)
+        [ -z "$kdumpnic" ] && echo "failed to get kdumpnic!" && return 1
+        HOST_IP=`ip addr show dev $kdumpnic|grep 'inet '`
+        [ $? -ne 0 ] && echo "Wrong kdumpnic: $kdumpnic" && return 1
+        HOST_IP="${HOST_IP##*inet }"
+        HOST_IP="${HOST_IP%%/*}"
+        [ -z "$HOST_IP" ] && echo "Wrong kdumpnic: $kdumpnic" && return 1
+    fi
+    return 0
+}
+
 read_kdump_conf()
 {
     if [ ! -f "$conf_file" ]; then
@@ -198,10 +219,19 @@ if [ -z "$CORE_COLLECTOR" ];then
     fi
 fi
 
+get_host_ip
+if [ $? -ne 0 ]; then
+    echo "get_host_ip exited with non-zero status!"
+    do_default_action
+fi
+
 if [ -z "$DUMP_INSTRUCTION" ]; then
     add_dump_code "dump_rootfs"
 fi
 
+#refresh DATEDIR with crash host ip addr
+DATEDIR="$HOST_IP-$DATEDIR"
+
 do_kdump_pre
 if [ $? -ne 0 ]; then
     echo "kdump_pre script exited with non-zero status!"
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 79b3766..9741c84 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -188,6 +188,8 @@ kdump_install_net() {
     fi
 
     kdump_setup_netdev "${_netdev}"
+    #save netdev used for kdump as cmdline
+    echo "kdumpnic=${_netdev}" > ${initdir}/etc/cmdline.d/kdumpnic.conf
 }
 
 #install kdump.conf and what user specifies in kdump.conf


More information about the scm-commits mailing list