According to udev's man page, PROGRAM is either used to determine device's name or whether the device matches the rule. So we should use RUN insteand. Meanwhile, both RUN / PROGRAM only accepts very short-running foreground tasks, but kdump restart may take a long time if there are any device changes that will lead to image rebuild, which may lead to buggy behavior.
On the other hand, memory / CPU hot plug should never trigger a initramfs rebuild.
To solve this problem, we will use new introduced "kdumpctl reload" instead, and use systemd-run to create a transient service unit for the reload and run it in no-block mode, so udev won't be blocked by anything.
Also reformat the udev rules to a more maintanceable format.
Signed-off-by: Kairui Song kasong@redhat.com --- 98-kexec.rules | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/98-kexec.rules b/98-kexec.rules index e32ee13..62ddd69 100644 --- a/98-kexec.rules +++ b/98-kexec.rules @@ -1,4 +1,12 @@ -SUBSYSTEM=="cpu", ACTION=="add", PROGRAM="/bin/systemctl try-restart kdump.service" -SUBSYSTEM=="cpu", ACTION=="remove", PROGRAM="/bin/systemctl try-restart kdump.service" -SUBSYSTEM=="memory", ACTION=="online", PROGRAM="/bin/systemctl try-restart kdump.service" -SUBSYSTEM=="memory", ACTION=="offline", PROGRAM="/bin/systemctl try-restart kdump.service" +SUBSYSTEM=="cpu", ACTION=="add", GOTO="kdump_reload" +SUBSYSTEM=="cpu", ACTION=="remove", GOTO="kdump_reload" +SUBSYSTEM=="memory", ACTION=="online", GOTO="kdump_reload" +SUBSYSTEM=="memory", ACTION=="offline", GOTO="kdump_reload" + +GOTO="kdump_reload_end" + +LABEL="kdump_reload" + +RUN+="/usr/bin/systemctl is-active kdump.service && /usr/bin/systemd-run --no-block /sbin/kdumpctl reload" + +LABEL="kdump_reload_end"