Thanks for the review, kairui.
On 20/01/20 1:47 PM, Kairui Song wrote:
Hi Hari,
Thanks for the patch.
On Fri, Jan 17, 2020 at 12:20 AM Hari Bathini <hbathini(a)linux.ibm.com> wrote:
>
> With FADump support added on POWERNV paltform, enable the scripts to
> capture /proc/vmcore. Also, if CONFIG_OPAL_CORE is enabled, OPAL core
> is preserved and exported on POWERNV platform. So, offload OPAL core,
> if it is available.
>
> Signed-off-by: Hari Bathini <hbathini(a)linux.ibm.com>
> ---
> dracut-kdump.sh | 29 +++++++++++++++++++++++++++--
> kdump-lib-initramfs.sh | 24 ++++++++++++++++++++++++
> kdumpctl | 3 +++
> 3 files changed, 54 insertions(+), 2 deletions(-)
>
> diff --git a/dracut-kdump.sh b/dracut-kdump.sh
> index 2ae1c7c..e1473b6 100755
> --- a/dracut-kdump.sh
> +++ b/dracut-kdump.sh
> @@ -1,8 +1,8 @@
> #!/bin/sh
>
> # continue here only if we have to save dump.
> -if [ -f /etc/fadump.initramfs ] && [ ! -f
/proc/device-tree/rtas/ibm,kernel-dump ]; then
> - exit 0
> +if [ -f /etc/fadump.initramfs ] && [ ! -f
/proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f
/proc/device-tree/ibm,opal/dump/mpipl-boot ]; then
> + exit 0
> fi
>
> exec &> /dev/console
> @@ -81,6 +81,7 @@ dump_ssh()
> ssh -q $_opt $_host mkdir -p $_dir || return 1
>
> save_vmcore_dmesg_ssh ${DMESG_COLLECTOR} ${_dir} "${_opt}" $_host
> + save_opalcore_ssh ${_dir} "${_opt}" $_host
>
> echo "kdump: saving vmcore"
>
> @@ -114,6 +115,30 @@ save_vmcore_dmesg_ssh() {
> fi
> }
>
> +save_opalcore_ssh() {
> + local _path=$1
> + local _opts="$2"
> + local _location=$3
> +
> + if [ ! -f $OPALCORE ]; then
> + # Check if we on an old kernel that uses a different path
> + if [ -f /sys/firmware/opal/core ]; then
> + OPALCORE="/sys/firmware/opal/core"
> + else
> + return 0
> + fi
> + fi
> +
> + echo "kdump: saving opalcore"
> + scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete
> + if [ $? -ne 0 ]; then
> + echo "kdump: saving opalcore failed"
Better just return here, if it failed, the below "ssh ... mv" command
shouldn't get executed if it already failed here.
Updated.
> + fi
> +
> + ssh $_opts $_location mv $_path/opalcore-incomplete $_path/opalcore
> + echo "kdump: saving opalcore complete"
> +}
> +
> get_host_ip()
> {
> local _host
> diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
> index 8530556..57712ad 100755
> --- a/kdump-lib-initramfs.sh
> +++ b/kdump-lib-initramfs.sh
> @@ -18,6 +18,7 @@ KDUMP_CONF="/etc/kdump.conf"
> KDUMP_PRE=""
> KDUMP_POST=""
> NEWROOT="/sysroot"
> +OPALCORE="/sys/firmware/opal/mpipl/core"
>
> get_kdump_confs()
> {
> @@ -137,6 +138,7 @@ dump_fs()
> mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1
>
> save_vmcore_dmesg_fs ${DMESG_COLLECTOR}
"$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
> + save_opalcore_fs "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
>
> echo "kdump: saving vmcore"
> $CORE_COLLECTOR /proc/vmcore
$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete || return 1
> @@ -173,6 +175,28 @@ save_vmcore_dmesg_fs() {
> fi
> }
>
> +save_opalcore_fs() {
> + local _path=$1
> +
> + if [ ! -f $OPALCORE ]; then
> + # Check if we on an old kernel that uses a different path
> + if [ -f /sys/firmware/opal/core ]; then
> + OPALCORE="/sys/firmware/opal/core"
> + else
> + return 0
> + fi
> + fi
> +
> + echo "kdump: saving opalcore"
> + cp $OPALCORE ${_path}/opalcore
Is dumping an "opalcore" will either create a complete dump or dump
nothing? when dumping a vmcore locally, it will also create a
vmcore-imcomplete first, then rename once finished. Not familiar with
opalcore, maybe this is not needed, if so this code looks fine.
No filtering involved. Regular copy operation. Size is around 100MB..
> + if [ $? -ne 0 ]; then
> + echo "kdump: saving opalcore failed"
> + fi
> +
> + sync
> + echo "kdump: saving opalcore complete"
> +}
> +
> dump_to_rootfs()
> {
>
> diff --git a/kdumpctl b/kdumpctl
> index 2d21a41..b4c6e8e 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -249,6 +249,9 @@ check_config()
> echo "Invalid kdump config value for option
$config_opt."
> return 1;
> }
> + if [ -d "/proc/device-tree/ibm,opal/dump" ]
&& [ "$config_opt" == "raw" ]; then
> + echo "WARNING: Won't capture opalcore when
'raw' dump target is used."
> + fi
> ;;
> net|options|link_delay|disk_timeout|debug_mem_level|blacklist)
> echo "Deprecated kdump config option: $config_opt. Refer
to kdump.conf manpage for alternatives."
>
cc. Pingfan, do you know more about powerpc/opalcore? I don't have
such machine and the patch looks good in general but not totally sure.
Official f/w not available yet. Expected to be available soon.
Testing with beta f/w for now. Posted v2. Please review.
Thanks
Hari