On Mon, Jul 12, 2021 at 6:03 PM Hari Bathini <hbathini(a)linux.ibm.com> wrote:
>
> Dump capture initramfs needs rebuild after partition migration (LPM).
> Use servicelog notification mechanism to invoke kdump rebuild after
> migration.
>
> Signed-off-by: Hari Bathini <hbathini(a)linux.ibm.com>
> ---
>
> * Rebased on recent changes.
>
>
> kdump-migrate-action.sh | 8 ++++++++
> kdump-restart.sh | 8 ++++++++
> kexec-tools.spec | 16 ++++++++++++++++
> 3 files changed, 32 insertions(+)
> 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 98d39fe..1106d6b 100644
> --- a/kexec-tools.spec
> +++ b/kexec-tools.spec
> @@ -42,6 +42,8 @@ Source31: kdump-logger.sh
> Source32: mkfadumprd
> Source33: 92-crashkernel.install
> Source34: crashkernel-howto.txt
> +Source35: kdump-migrate-action.sh
> +Source36: kdump-restart.sh
>
> #######################################
> # These are sources for mkdumpramfs
> @@ -61,6 +63,9 @@ Source200: dracut-fadump-init-fadump.sh
> Source201: dracut-fadump-module-setup.sh
>
> Requires(post): systemd-units
> +%ifarch ppc64 ppc64le
> +Requires(post): servicelog
> +%endif
> Requires(preun): systemd-units
> Requires(postun): systemd-units
> Requires(pre): coreutils sed zlib
> @@ -199,6 +204,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
> @@ -265,6 +274,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
>
Acked-by: Kairui Song <kasong(a)redhat.com>
--
Best Regards,
Kairui Song