Package: makedumpfile
Version: 1:1.5.7-5
Followup-For: Bug #776574
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu vivid ubuntu-patch

Dear Louis,

Here is an updated patch that addresses issues highlighted here:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1415562/comments/11

Thanks,
--chris


  * Fix panic_on_oops erratic handling
    Closes: #776582

  [ Hari Bathini <hbath...@linux.vnet.ibm.com> ]
  * Add firmware assisted dump support, add changes to remove warnings.
    Closes: #776574, LP: #1415562


Thanks for considering the patch.


-- System Information:
Debian Release: jessie/sid
  APT prefers trusty-updates
  APT policy: (500, 'trusty-updates'), (500, 'trusty-security'), (500,
'trusty-proposed'), (500, 'trusty'), (100, 'trusty-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.13.0-45-lowlatency (SMP w/12 CPU cores; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

diff -Nru makedumpfile-1.5.7/debian/changelog makedumpfile-1.5.7/debian/changelog
diff -Nru makedumpfile-1.5.7/debian/kdump-config makedumpfile-1.5.7/debian/kdump-config
--- makedumpfile-1.5.7/debian/kdump-config	2014-12-05 05:17:00.000000000 -0600
+++ makedumpfile-1.5.7/debian/kdump-config	2015-02-06 13:22:25.000000000 -0600
@@ -55,8 +55,19 @@
 # Constants
 vmcore_file=/proc/vmcore
 sys_kexec_crash=/sys/kernel/kexec_crash_loaded
+sys_fadump_enabled=/sys/kernel/fadump_enabled
+sys_fadump_registered=/sys/kernel/fadump_registered
 kexec_cmd_file=$KDUMP_COREDIR/kexec_cmd
 
+# DUMP_MODE = kdump/fadump
+# The default dump mode is kdump.
+DUMP_MODE="kdump"
+
+# If /sys/kernel/fadump_enabled is set to `1`, use fadump as dump mechanism
+if [ -e $sys_fadump_enabled ] && [ `cat $sys_fadump_enabled` -eq 1 ]; then
+	DUMP_MODE="fadump"
+fi
+
 # Utility Functions
 #
 function kdump_help()
@@ -65,14 +76,19 @@
 Usage:
 kdump-config {help|test|show|status|load|unload|savecore|propagate}"
   help      - print this page
-  test      - Do a dry-run of the load command.  Show the kernels and
-              parameters that will be used and echo the kexec command.
-              The kexec command will not be executed.
-  show      - Show kdump status, kexec command, and any current parameters.
-  status    - evaluate /sys/kernel/kexec_crash_loaded and print a message
+  test      - Do a dry-run of kdump kernel load command by showing
+              the kernels and parameters that will be used and echo'ing
+              the kexec command. The kexec command will not be executed.
+              If using fadump, check if required sysfs directories exist.
+  show      - Show dump mode, status, any current parameters.
+              Show kexec command for kdump.
+  status    - evaluate /sys/kernel/{kexec_crash_loaded,fadump_registered}
+              depending on dump mode. Print appropriate message
   load      - Locate the kdump kernel, debug kernel, and establish links for
               makedumpfile.  Then load the kdump kernel using kexec
+              If using fadump, register.
   unload    - unload the kdump kernel using kexec
+              If using fadump, unregister.
   savecore  - use previously made links to save /proc/vmcore
   propagate - Send public ssh key to remote host for passwordless connection
 
@@ -81,10 +97,13 @@
 
 function kdump_show()
 {
+	echo "DUMP_MODE:        $DUMP_MODE"
 	echo "USE_KDUMP:        $USE_KDUMP"
 	echo "KDUMP_SYSCTL:     $KDUMP_SYSCTL"
 	echo "KDUMP_COREDIR:    $KDUMP_COREDIR"
-	echo "crashkernel addr: $IOMEM_ADDR"
+	if [ "$DUMP_MODE" == "kdump" ]; then
+		echo "crashkernel addr: $IOMEM_ADDR"
+	fi
 
 	if [ -n "$SSH" ];then
 		echo "SSH:              $SSH"
@@ -100,6 +119,16 @@
 		echo "HOSTTAG:          $HOSTTAG"
 	fi
 
+	if [ "$DUMP_MODE" == "fadump" ]; then
+		if [ -e $sys_fadump_registered ] &&
+			[ `cat $sys_fadump_registered` -eq 1 ] ; then
+			echo "current state:    ready to fadump";
+		else
+			echo "current state:    Not ready to fadump";
+		fi
+		return 0
+	fi
+
 	if [ -e $sys_kexec_crash -a `cat $sys_kexec_crash` -eq 1 ] ; then
 		echo "current state:    ready to kdump";
 	else
@@ -130,6 +159,29 @@
 	echo "  $KEXEC_CMD"
 }
 
+# check_fadump_support:  Other miscellaneous checks go here:
+# 1: if USE_KDUMP is 0, don't set up fadump.
+# 2: -e /sys/kernel/fadump_registered indicates that this kernel
+#    thinks it supports fadump
+#
+# Returns: none. prints warnings or exit
+function check_fadump_support()
+{
+	if [ -z "$USE_KDUMP" -o "$USE_KDUMP" == "0" ] ; then
+		log_failure_msg "$KDUMP_DEFAULTS: USE_KDUMP is not set or zero"
+		[ ! $DRY_RUN ] && exit 1;
+	fi
+	if [ ! -e $sys_fadump_registered ]; then
+		log_failure_msg "fadump is not configured in this kernel."
+		log_failure_msg "Try passing \"fadump=on\" to enable fadump"
+		[ ! $DRY_RUN ] && exit 1;
+	fi
+        if [ -n "$NFS" ] && [ -n "$SSH" ];then
+		log_failure_msg "\$SSH and \$NFS cannot be defined concurrently"
+		[ ! $DRY_RUN ] && exit 1;
+	fi
+}
+
 # check_kdump_support:  Other miscellaneous checks go here:
 # 1: if USE_KDUMP is 0, don't set up kdump.
 # 2: -e /sys/kernel/kexec_crash loaded indicates that this kernel
@@ -241,6 +293,48 @@
 	return 0;
 }
 
+# Register firmware-assisted dump as the dump mechanism
+# Returns: none. prints warnings or exit
+function fadump_register()
+{
+	# set fadump registered sys node to `1` to register fadump
+	if [ "`cat $sys_fadump_registered`" -ne 1 ]; then
+		echo 1 > $sys_fadump_registered
+	fi
+	rc=`cat $sys_fadump_registered`
+	if [ $rc -ne 1 ] ; then
+		log_failure_msg "fadump registering failed"
+		logger -t $NAME "fadump registering failed"
+		[ ! $DRY_RUN ] && exit 1;
+	fi
+
+	log_success_msg "fadump registered successfully"
+	logger -t $NAME "fadump registered successfully"
+
+	# Last step: make sure panic_on_oops is enabled
+        PANIC_ON_OOPS=`/sbin/sysctl kernel.panic_on_oops | cut -d" " -f3`
+        if [ $PANIC_ON_OOPS != "1" ] ; then
+                sysctl -w kernel.panic_on_oops=1 >/dev/null
+        fi
+}
+
+# Returns: none. prints warnings or exit
+function fadump_unregister()
+{
+	# set fadump registered sys node to `0` to un-register fadump
+	if [ "`cat $sys_fadump_registered`" -ne 0 ]; then
+		echo 0 > $sys_fadump_registered
+	fi
+	rc=`cat $sys_fadump_registered`
+	if [ $rc -ne 0 ] ; then
+		log_failure_msg "fadump un-registering failed"
+		logger -t $NAME "fadump un-registering failed"
+		[ ! $DRY_RUN ] && exit 1;
+	fi
+
+	log_success_msg "fadump un-registered successfully"
+	logger -t $NAME "fadump un-registered successfully"
+}
 
 #
 # Load the already determined kdump kernel and kdump initrd using kexec
@@ -304,9 +398,11 @@
 	fi
 
 	# Last step: make sure panic_on_oops is enabled
-	if [ -x /sbin/sysctl -a "$KDUMP_SYSCTL" != " " ] ; then
-		sysctl -w $KDUMP_SYSCTL >/dev/null
-	fi
+        PANIC_ON_OOPS=`/sbin/sysctl kernel.panic_on_oops | cut -d" " -f3`
+        if [ $PANIC_ON_OOPS != "1" ] ; then
+                sysctl -w kernel.panic_on_oops=1 >/dev/null
+        fi
+
 }
 
 # Returns: none. prints warnings or exit
@@ -579,30 +675,56 @@
 case "$1" in
   test)
 	DRY_RUN="true"
-	check_kdump_support;
-	locate_kdump_kernel;
-	kdump_load;
-	kdump_test
+	if [ "$DUMP_MODE" == "fadump" ]; then
+		check_fadump_support
+	else
+		check_kdump_support;
+		locate_kdump_kernel;
+		kdump_load;
+		kdump_test
+	fi
 	;;
   show)
 	DRY_RUN="true"
-	check_kdump_support;
+	if [ "$DUMP_MODE" == "fadump" ]; then
+		check_fadump_support;
+	else
+		check_kdump_support;
+	fi
 	kdump_show
 	;;
   load)
-	check_kdump_support;
-	locate_kdump_kernel;
-	kdump_load;
+	if [ "$DUMP_MODE" == "fadump" ]; then
+		check_fadump_support;
+		fadump_register
+	else
+		check_kdump_support;
+		locate_kdump_kernel;
+		kdump_load
+	fi
 	;;
   unload)
-	kdump_unload;
+	if [ "$DUMP_MODE" == "fadump" ]; then
+		fadump_unregister
+	else
+		kdump_unload
+	fi
 	;;
   status)
-	check_kdump_support;
-	if [ `cat $sys_kexec_crash` -eq 1 ] ; then
-		echo "current state   : ready to kdump";
+	if [ "$DUMP_MODE" == "fadump" ]; then
+		check_fadump_support
+		if [ `cat $sys_fadump_registered` -eq 1 ] ; then
+			echo "current state   : ready to fadump";
+		else
+			echo "current state   : Not ready to fadump";
+		fi
 	else
-		echo "current state   : Not ready to kdump";
+		check_kdump_support;
+		if [ `cat $sys_kexec_crash` -eq 1 ] ; then
+			echo "current state   : ready to kdump";
+		else
+			echo "current state   : Not ready to kdump";
+		fi
 	fi
 	exit 0;
 	;;
diff -Nru makedumpfile-1.5.7/debian/.pc/.quilt_patches makedumpfile-1.5.7/debian/.pc/.quilt_patches
--- makedumpfile-1.5.7/debian/.pc/.quilt_patches	1969-12-31 18:00:00.000000000 -0600
+++ makedumpfile-1.5.7/debian/.pc/.quilt_patches	2015-01-29 08:14:21.000000000 -0600
@@ -0,0 +1 @@
+patches
diff -Nru makedumpfile-1.5.7/debian/.pc/.quilt_series makedumpfile-1.5.7/debian/.pc/.quilt_series
--- makedumpfile-1.5.7/debian/.pc/.quilt_series	1969-12-31 18:00:00.000000000 -0600
+++ makedumpfile-1.5.7/debian/.pc/.quilt_series	2015-01-29 08:14:21.000000000 -0600
@@ -0,0 +1 @@
+series
diff -Nru makedumpfile-1.5.7/debian/.pc/.version makedumpfile-1.5.7/debian/.pc/.version
--- makedumpfile-1.5.7/debian/.pc/.version	1969-12-31 18:00:00.000000000 -0600
+++ makedumpfile-1.5.7/debian/.pc/.version	2015-01-29 08:14:21.000000000 -0600
@@ -0,0 +1 @@
+2

Reply via email to