From de65197ba0a954dcd76e17b01d3da12cd37c6313 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Fri, 3 Dec 2021 18:13:09 +0800 Subject: [PATCH] kdump/ppc64: rebuild initramfs image after migration upstream: fedora resolves: bz2027568 conflict: The upstream patch was submitted before "Add file supported-kdump-targets.txt to kexec-tools" was added to rhel9. So there are SourceXX conflict in spec file. And similar code merge with patch "add keyutils as a weak dependency for POWER" commit 71b7a2f47c783b33965e8fc469dc44bda08cf458 Author: Hari Bathini Date: Mon Jul 12 15:33:03 2021 +0530 kdump/ppc64: rebuild initramfs image after migration Dump capture initramfs needs rebuild after partition migration (LPM). Use servicelog notification mechanism to invoke kdump rebuild after migration. Signed-off-by: Hari Bathini Reviewed-by: Pingfan Liu Acked-by: Kairui Song Signed-off-by: Tao Liu --- kdump-migrate-action.sh | 8 ++++++++ kdump-restart.sh | 8 ++++++++ kexec-tools.spec | 24 +++++++++++++++++++----- 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100755 kdump-migrate-action.sh create mode 100644 kdump-restart.sh diff --git a/kdump-migrate-action.sh b/kdump-migrate-action.sh new file mode 100755 index 0000000..c516639 --- /dev/null +++ b/kdump-migrate-action.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +systemctl is-active kdump +if [ $? -ne 0 ]; then + exit 0 +fi + +/usr/lib/kdump/kdump-restart.sh diff --git a/kdump-restart.sh b/kdump-restart.sh new file mode 100644 index 0000000..a9ecfc1 --- /dev/null +++ b/kdump-restart.sh @@ -0,0 +1,8 @@ +#!/bin/bash +export PATH="$PATH:/usr/bin:/usr/sbin" + +exec >>/var/log/kdump-migration.log 2>&1 + +echo "kdump: Partition Migration detected. Rebuilding initramfs image to reload." +/usr/bin/kdumpctl rebuild +/usr/bin/kdumpctl reload diff --git a/kexec-tools.spec b/kexec-tools.spec index 35d8d07..038bd9f 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -42,7 +42,9 @@ Source31: kdump-logger.sh Source32: mkfadumprd Source33: 92-crashkernel.install Source34: crashkernel-howto.txt -Source35: supported-kdump-targets.txt +Source35: kdump-migrate-action.sh +Source36: kdump-restart.sh +Source37: supported-kdump-targets.txt ####################################### # These are sources for mkdumpramfs @@ -57,15 +59,16 @@ Source107: dracut-kdump-emergency.target Source108: dracut-early-kdump.sh Source109: dracut-early-kdump-module-setup.sh -%ifarch ppc64 ppc64le -Recommends: keyutils -%endif Source200: dracut-fadump-init-fadump.sh Source201: dracut-fadump-module-setup.sh Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units +%ifarch ppc64 ppc64le +Requires(post): servicelog +Recommends: keyutils +%endif Requires(pre): coreutils sed zlib Requires: dracut >= 050 Requires: dracut-network >= 050 @@ -151,7 +154,7 @@ cp %{SOURCE21} . cp %{SOURCE26} . cp %{SOURCE27} . cp %{SOURCE34} . -cp %{SOURCE35} . +cp %{SOURCE37} . make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 @@ -198,6 +201,10 @@ install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh install -m 755 %{SOURCE31} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-logger.sh +%ifarch ppc64 ppc64le +install -m 755 %{SOURCE35} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-migrate-action.sh +install -m 755 %{SOURCE36} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-restart.sh +%endif %ifnarch s390x install -m 755 %{SOURCE28} $RPM_BUILD_ROOT%{_udevrulesdir}/../kdump-udev-throttler %endif @@ -263,6 +270,13 @@ mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{d %systemd_post kdump.service touch /etc/kdump.conf + +ARCH=`uname -m` +if [ "$ARCH" == "ppc64" ] || [ "$ARCH" == "ppc64le" ] +then + servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin +fi + # This portion of the script is temporary. Its only here # to fix up broken boxes that require special settings # in /etc/sysconfig/kdump. It will be removed when