[PATCH] Fix the problem that kdump prints redundant /
by Kairui Song
In second kernel, kdump always prints redundant '/':
kdump: saving to /sysroot//var/crash/127.0.0.1-2020-03-12-21:32:54/
Just trim it.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
kdump-lib-initramfs.sh | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 7b314a7..49b12dc 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -125,7 +125,9 @@ dump_fs()
# Remove -F in makedumpfile case. We don't want a flat format dump here.
[[ $CORE_COLLECTOR = *makedumpfile* ]] && CORE_COLLECTOR=`echo $CORE_COLLECTOR | sed -e "s/-F//g"`
- echo "kdump: saving to $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
+ local _dump_path=$(echo "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" | tr -s /)
+
+ echo "kdump: saving to $_dump_path"
# Only remount to read-write mode if the dump target is mounted read-only.
if [[ "$_op" = "ro"* ]]; then
@@ -133,14 +135,14 @@ dump_fs()
mount -o remount,rw $_dev $_mp || return 1
fi
- mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1
+ mkdir -p $_dump_path || return 1
- save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
- save_opalcore_fs "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
+ save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_dump_path"
+ save_opalcore_fs "$_dump_path"
echo "kdump: saving vmcore"
- $CORE_COLLECTOR /proc/vmcore $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete || return 1
- mv $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore
+ $CORE_COLLECTOR /proc/vmcore $_dump_path/vmcore-incomplete || return 1
+ mv $_dump_path/vmcore-incomplete $_dump_path/vmcore
sync
echo "kdump: saving vmcore complete"
--
2.25.3
3 years, 11 months
[PATCH v2] Partially Revert "Don't mount the dump target unless needed"
by Kairui Song
This partially reverts commit 6dee286467e5a697d25148712a110da1a720ac96.
There are reports that NFSv3 is failing after this commit, and after
more debug, I found NFSv4 may not work properly if
"nfs4_disable_idmapping" is set to 0.
The cause of the failure is that kdump.sh runs after dracut's pre-pivot
and clean up hook, many dracut module will install hooks to kill some
running services, so if the dump target requires a service to be running
but it's killed, mount will fail.
Dracut ensures the configured mount points are ready before pre-pivot.
After pre-pivot, any further mounting operation may not work as expected.
Although there is no report of other type of dump target failure except
NFSv3, it's better to revert this, to avoid other potential risk, and wait
for a proper fix for that systemd/kernel issue.
Else, this may bring more trouble for further development.
But still keep the change in kdump-lib-initramfs.sh for better
robustness.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
mkdumprd | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/mkdumprd b/mkdumprd
index 35f5eed..cedf536 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -77,13 +77,12 @@ to_mount() {
fi
# mount fs target as rw in 2nd kernel
_options=$(echo $_options | sed 's/\(^\|,\)ro\($\|,\)/\1rw\2/g')
- # filter out 'noauto' here, it will be force appended later, avoid duplication
+ # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd
+ # kernel, filter it out here.
_options=$(echo $_options | sed 's/\(^\|,\)noauto\($\|,\)/\1/g')
# drop nofail or nobootwait
_options=$(echo $_options | sed 's/\(^\|,\)nofail\($\|,\)/\1/g')
_options=$(echo $_options | sed 's/\(^\|,\)nobootwait\($\|,\)/\1/g')
- # only mount the dump target when needed.
- _options="$_options,noauto"
_mntopts="$_target $_fstype $_options"
#for non-nfs _dev converting to use udev persistent name
--
2.25.3
3 years, 11 months
[PATCH 4/4] dracut-kdump.sh: Execute the binary and script files in
/etc/kdump/{pre.d,post.d}
by onitsuka.shinic@fujitsu.com
This patch executes the binary and script files in /etc/kdump/{pre.d,post.d}
just like kdump_pre or kdump_post directive written in /etc/kdump.conf.
Signed-off-by: Shinichi Onitsuka <onitsuka.shinic(a)fujitsu.com>
---
dracut-kdump.sh | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 0f54ddc..d2d2b33 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -30,15 +30,49 @@ do_dump()
do_kdump_pre()
{
+ local _ret
+
if [ -n "$KDUMP_PRE" ]; then
"$KDUMP_PRE"
+ _ret=$?
+ if [ $_ret -ne 0 ]; then
+ echo "kdump: $KDUMP_PRE exited with $_ret status"
+ return $_ret
+ fi
fi
+
+ if [ -d /etc/kdump/pre.d ]; then
+ for file in /etc/kdump/pre.d/*; do
+ "$file"
+ _ret=$?
+ if [ $_ret -ne 0 ]; then
+ echo "kdump: $file exited with $_ret status"
+ fi
+ done
+ fi
+ return 0
}
do_kdump_post()
{
+ local _ret
+
+ if [ -d /etc/kdump/post.d ]; then
+ for file in /etc/kdump/post.d/*; do
+ "$file" "$1"
+ _ret=$?
+ if [ $_ret -ne 0 ]; then
+ echo "kdump: $file exited with $_ret status"
+ fi
+ done
+ fi
+
if [ -n "$KDUMP_POST" ]; then
"$KDUMP_POST" "$1"
+ _ret=$?
+ if [ $_ret -ne 0 ]; then
+ echo "kdump: $KDUMP_POST exited with $_ret status"
+ fi
fi
}
--
1.8.3.1
3 years, 11 months
[PATCH 3/4] kdumpctl: Check the update of the binary and script files
in /etc/kdump/{pre.d,post.d}
by onitsuka.shinic@fujitsu.com
This patch checks the update of the binary and script files in
/etc/kdump/{pre.d,post.d} for initramfs of kdump.
When kdumpd service is started or restarted, initramfs of kdump is recreated
by new the binary and script files, if the binary and script files in
/etc/kdump/{pre.d,post.d} are updated.
Signed-off-by: Shinichi Onitsuka <onitsuka.shinic(a)fujitsu.com>
---
kdumpctl | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl
index 2da3846..ef2926d 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -339,9 +339,23 @@ check_files_modified()
EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2`
CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2`
+ if [ -d /etc/kdump/post.d ]; then
+ for file in /etc/kdump/post.d/*; do
+ if [ -x "$file" ]; then
+ POST_FILES="$POST_FILES $file"
+ fi
+ done
+ fi
+ if [ -d /etc/kdump/pre.d ]; then
+ for file in /etc/kdump/pre.d/*; do
+ if [ -x "$file" ]; then
+ PRE_FILES="$PRE_FILES $file"
+ fi
+ done
+ fi
CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut -d\ -f2`
CORE_COLLECTOR=`type -P $CORE_COLLECTOR`
- EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
+ EXTRA_BINS="$EXTRA_BINS $CHECK_FILES $POST_FILES $PRE_FILES"
CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-`
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS $CORE_COLLECTOR"
--
1.8.3.1
3 years, 11 months
[PATCH 2/4] dracut-module-setup.sh: Install files under
/etc/kdump/{pre.d,post.d} into kdump initramfs
by onitsuka.shinic@fujitsu.com
This patch installs the binary and script files under /etc/kdump/{pre.d,post.d}
into new initramfs of kdump.
Signed-off-by: Shinichi Onitsuka <onitsuka.shinic(a)fujitsu.com>
---
dracut-module-setup.sh | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 7a2c7b4..bad60f2 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -521,6 +521,8 @@ kdump_install_conf() {
esac
done <<< "$(read_strip_comments /etc/kdump.conf)"
+ kdump_install_preafter_conf
+
default_dump_target_install_conf
kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf"
@@ -528,6 +530,29 @@ kdump_install_conf() {
rm -f ${initdir}/tmp/$$-kdump.conf
}
+# install etc/kdump/pre.d and /etc/kdump/post.d
+kdump_install_preafter_conf() {
+ if [ -d /etc/kdump/pre.d ]; then
+ for file in /etc/kdump/pre.d/*; do
+ if [ -x "$file" ]; then
+ dracut_install $file
+ else
+ echo "$file is not executable"
+ fi
+ done
+ fi
+
+ if [ -d /etc/kdump/post.d ]; then
+ for file in /etc/kdump/post.d/*; do
+ if [ -x "$file" ]; then
+ dracut_install $file
+ else
+ echo "$file is not executable"
+ fi
+ done
+ fi
+}
+
# Remove user custom configurations sysctl.conf & sysctl.d/*
# and apply some optimization for kdump
overwrite_sysctl_conf() {
--
1.8.3.1
3 years, 11 months
[PATCH 1/4] kdump.conf: Specify /etc/kdump/{pre.d,post.d} interface
by onitsuka.shinic@fujitsu.com
This patch discribe /etc/kdump/{pre.d,post.d} interface.
Signed-off-by: Shinichi Onitsuka <onitsuka.shinic(a)fujitsu.com>
---
kdump.conf | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/kdump.conf b/kdump.conf
index 1f0fc2d..e2e8c54 100644
--- a/kdump.conf
+++ b/kdump.conf
@@ -79,13 +79,23 @@
# or script after the vmcore dump process terminates.
# The exit status of the current dump process is fed to
# the executable binary or script as its first argument.
+# If /etc/kdump/post.d directory is exist, All files in
+# the directory are collectively sorted and executed in
+# lexical order, before binary or script specified
+# kdump_post parameter is executed.
#
# kdump_pre <binary | script>
# - Works like the "kdump_post" directive, but instead of running
# after the dump process, runs immediately before it.
# Exit status of this binary is interpreted as follows:
-# 0 - continue with dump process as usual
-# non 0 - reboot the system
+# 0 - continue with dump process as usual
+# non 0 - reboot the system
+# If /etc/kdump/pre.d directory is exist, All files in
+# the directory are collectively sorted and executed in
+# lexical order, after binary or script specified
+# kdump_pre parameter is executed.
+# Even if the binary or script in /etc/kdump/pre.d directory
+# returns non 0 exit status, the processing is continued.
#
# extra_bins <binaries | shell scripts>
# - This directive allows you to specify additional binaries or
--
1.8.3.1
3 years, 11 months
[PATCH 0/4] /etc/kdump/{pre.d,post.d} interface to set up multiple
binary and script files
by onitsuka.shinic@fujitsu.com
There is restriction on kdump_pre and kdump_post directives now that can be
specified only once in /etc/kdump.conf.
However, there are multiple components that need to use the directives.
This patch implements /etc/kdump/{pre.d,post.d} interface to set up multiple
binary and script files.
For example, users put multiple binary and script files under
/etc/kdump/pre.d directory as below:
# find /etc/kdump/pre.d
/etc/kdump/pre.d/50-foo.sh
/etc/kdump/pre.d/75-hoge.sh
Then, 50-foo.sh and 75-hoge.sh are executed in order before kdump dump process
begins just like kdump_pre directive written in /etc/kdump.conf.
This is composed of the following three patches created based on
commit 4b43ba063ddbcdccf95d761d2a3641f3006d814d.
Signed-off-by: Shinichi Onitsuka <onitsuka.shinic(a)fujitsu.com>
---
Changes since v1:
[1]Change title.
[2]Change behavior of non 0 Exit status that script/binary in kdump/pre.d was returned.
[3]Stop using find/sort commands.
[4]Add checking execution bit.
[5]Add specification of /etc/kdump/{pre.d,post.d} interface
---
Shin-ichi Onitsuka (4):
kdump.conf: Specify /etc/kdump/{pre.d,post.d} interface
dracut-module-setup.sh: Install files under /etc/kdump/{pre.d,post.d}
into kdump initramfs
kdumpctl: Check the update of the binary and script files in
/etc/kdump/{pre.d,post.d}
dracut-kdump.sh: Execute the binary and script files in
/etc/kdump/{pre.d,post.d}
dracut-kdump.sh | 34 ++++++++++++++++++++++++++++++++++
dracut-module-setup.sh | 25 +++++++++++++++++++++++++
kdump.conf | 14 ++++++++++++--
kdumpctl | 16 +++++++++++++++-
4 files changed, 86 insertions(+), 3 deletions(-)
--
1.8.3.1
3 years, 11 months