[kexec-tools/f19] kdump: Save vmcore-dmesg.txt before saving vmcore

Baoquan He baoquan at fedoraproject.org
Wed May 22 01:56:09 UTC 2013


commit 9bf131f88b3c6ce2909cbf5ca4dc31c3d27e1933
Author: Baoquan He <bhe at redhat.com>
Date:   Mon May 13 11:13:27 2013 +0800

    kdump: Save vmcore-dmesg.txt before saving vmcore
    
    Save vmcore-dmesg.txt before saving vmcore. For ssh targets, it assumes
    that ssh is enabled. No scp logic as I don't have a local copy of
    kernel log buffers and saving one will consume extra memory. We
    can possibly enhance this logic to save kernel log buffers first locally
    and then scp it (For setups which allow scp but disable ssh access).
    (log is from Vivek Goyal <vgoyal at redhat.com>)
    
    And add 1 section to describe it in kexec-kdump-howto.txt
    
    v3->v4:
         Remove old description of dmesg in kexec-kdump-howto.txt, now
         add a new section to describe it, and note user kernel log
         buffers won't be available if dump target is raw device.
    
    Signed-off-by: Baoquan He <bhe at redhat.com>
    Acked-by: Vivek Goyal <vgoyal at redhat.com>

 dracut-kdump.sh        |   43 +++++++++++++++++++++++++++++++++++++++++++
 dracut-module-setup.sh |    1 +
 kexec-kdump-howto.txt  |    8 ++++++++
 3 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 7b086c7..705afde 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -7,6 +7,7 @@ set -x
 KDUMP_PATH="/var/crash"
 CORE_COLLECTOR=""
 DEFAULT_CORE_COLLECTOR="makedumpfile -c --message-level 1 -d 31"
+DMESG_COLLECTOR="/sbin/vmcore-dmesg"
 DEFAULT_ACTION="reboot -f"
 DATEDIR=`date +%Y.%m.%d-%T`
 HOST_IP='127.0.0.1'
@@ -60,6 +61,9 @@ dump_fs()
         mount -o remount,rw $_mp || return 1
     fi
     mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1
+
+    save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
+
     $CORE_COLLECTOR /proc/vmcore $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore || return 1
     umount $_mp || return 1
     return 0
@@ -90,6 +94,9 @@ dump_to_rootfs()
 
     mount -o remount,rw $NEWROOT/ || return 1
     mkdir -p $NEWROOT/$KDUMP_PATH/$HOST_IP-$DATEDIR
+
+    save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$NEWROOT/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
+
     $CORE_COLLECTOR /proc/vmcore $NEWROOT/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore || return 1
     sync
 }
@@ -102,6 +109,8 @@ dump_ssh()
     cat /var/lib/random-seed > /dev/urandom
     ssh -q $_opt $2 mkdir -p $_dir || return 1
 
+    save_vmcore_dmesg_ssh ${DMESG_COLLECTOR} ${_dir} "${_opt}" $2
+
     if [ "${CORE_COLLECTOR%% *}" = "scp" ]; then
         scp -q $_opt /proc/vmcore "$2:$_dir/vmcore-incomplete" || return 1
         ssh $_opt $2 "mv $_dir/vmcore-incomplete $_dir/vmcore" || return 1
@@ -111,6 +120,40 @@ dump_ssh()
     fi
 }
 
+save_vmcore_dmesg_fs() {
+    local _dmesg_collector=$1
+    local _path=$2
+
+    echo "Saving vmcore-dmesg.txt"
+    $_dmesg_collector /proc/vmcore > ${_path}/vmcore-dmesg-incomplete.txt
+    _exitcode=$?
+    if [ $_exitcode -eq 0 ]; then
+        mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt
+        echo "Saved vmcore-dmesg.txt"
+    else
+        echo "Saving vmcore-dmesg.txt failed"
+    fi
+}
+
+save_vmcore_dmesg_ssh() {
+    local _dmesg_collector=$1
+    local _path=$2
+    local _opts="$3"
+    local _location=$4
+
+    echo "Saving vmcore-dmesg.txt"
+    $_dmesg_collector /proc/vmcore | ssh $_opts $_location "dd of=$_path/vmcore-dmesg-incomplete.txt"
+    _exitcode=$?
+
+    if [ $_exitcode -eq 0 ]; then
+        ssh -q $_opts $_location mv $_path/vmcore-dmesg-incomplete.txt $_path/vmcore-dmesg.txt
+        echo "Saved vmcore-dmesg.txt"
+    else
+        echo "Saving vmcore-dmesg.txt failed"
+    fi
+}
+
+
 is_ssh_dump_target()
 {
     grep -q "^ssh[[:blank:]].*@" $conf_file
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 0f8944c..201fc8b 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -399,6 +399,7 @@ install() {
     inst "/bin/sync" "/bin/sync"
     inst "/bin/cut" "/bin/cut"
     inst "/sbin/makedumpfile" "/sbin/makedumpfile"
+    inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
     inst_hook pre-pivot 9999 "$moddir/kdump.sh"
 
     # Check for all the devices and if any device is iscsi, bring up iscsi
diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt
index 3023017..0ffd136 100644
--- a/kexec-kdump-howto.txt
+++ b/kexec-kdump-howto.txt
@@ -179,6 +179,14 @@ perform postmortem analysis:
 
 and so on...
 
+Saving vmcore-dmesg.txt
+----------------------
+Kernel log bufferes are one of the most important information available
+in vmcore. Now before saving vmcore, kernel log bufferes are extracted
+from /proc/vmcore and saved into a file vmcore-dmesg.txt. After
+vmcore-dmesg.txt, vmcore is saved. Destination disk and directory for
+vmcore-dmesg.txt is same as vmcore. Note that kernel log buffers will
+not be available if dump target is raw device.
 
 Dump Triggering methods:
 


More information about the scm-commits mailing list