File kdump-udev-skip-restart-if-not-loaded.patch of Package kdump

From: Petr Tesarik <ptesarik@suse.com>
Date: Mon Aug 31 08:46:32 2015 +0200
Subject: Simplify udev reload rules
References: bsc#905690
Patch-mainline: v0.8.16
Git-commit: 7fca28402c85a8d33a26be2351168dee1f49ea0e

Use udev directives to check if the panic kernel is already loaded
and execute /lib/kdump/load.sh if needed. This change unifies the
systemd and legacy code paths, and it also avoids all of the systemd
machinery.

Idea-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Petr Tesarik <ptesarik@suse.com>

diff --git a/70-kdump.rules.in b/70-kdump.rules.in
index ce84338..ee8b8e5 100644
--- a/70-kdump.rules.in
+++ b/70-kdump.rules.in
@@ -11,27 +11,16 @@
 # Novell Bug #389658
 #
 
-TEST=="/usr/bin/systemctl", GOTO="kdump_systemd"
-
+SUBSYSTEM=="memory", ACTION=="add|remove", GOTO="kdump_try_restart"
 @if @ARCH@ ppc ppc64 ppc64le
-SUBSYSTEM=="cpu", ACTION=="online", RUN+="/etc/init.d/boot.kdump try-restart"
-SUBSYSTEM=="cpu", ACTION=="offline", RUN+="/etc/init.d/boot.kdump try-restart"
+SUBSYSTEM=="cpu", ACTION=="online|offline", GOTO="kdump_try_restart"
 @endif
-SUBSYSTEM=="memory", ACTION=="add", RUN+="/etc/init.d/boot.kdump try-restart"
-SUBSYSTEM=="memory", ACTION=="remove", RUN+="/etc/init.d/boot.kdump try-restart"
 
 GOTO="kdump_end"
 
-# Systemd limits service start rate, so if udev events are emitted too
-# often, kdump will enter failed state, unless the counter is reset here.
-LABEL="kdump_systemd"
-
-@if @ARCH@ ppc ppc64 ppc64le
-SUBSYSTEM=="cpu", ACTION=="online", RUN+="/usr/bin/systemctl reset-failed kdump", RUN+="/usr/bin/systemctl try-restart kdump"
-SUBSYSTEM=="cpu", ACTION=="offline", RUN+="/usr/bin/systemctl reset-failed kdump", RUN+="/usr/bin/systemctl try-restart kdump"
-@endif
-SUBSYSTEM=="memory", ACTION=="add", RUN+="/usr/bin/systemctl reset-failed kdump", RUN+="/usr/bin/systemctl try-restart kdump"
-SUBSYSTEM=="memory", ACTION=="remove", RUN+="/usr/bin/systemctl reset-failed kdump", RUN+="/usr/bin/systemctl try-restart kdump"
+# Reload only if panic kernel is already loaded
+LABEL="kdump_try_restart"
+PROGRAM="/bin/cat /sys/kernel/kexec_crash_loaded", RESULT!="0", RUN+="/lib/kdump/load.sh"
 
 LABEL="kdump_end"
 @endif
openSUSE Build Service is sponsored by