[PATCH 0/2] Fix issues reported by rpmlint for kexec-tools
by Bhupesh Sharma
Resolves: BZ1433852
https://bugzilla.redhat.com/show_bug.cgi?id=1433852
This patchset fixes a couple of issues reported by rpmlint
when it is run on kexec-tools:
1. Patch 1 fixes several instances of hardcoded-library-path errors.
2. Patch 2 fixes a couple of whitespace errors.
Bhupesh Sharma (2):
kexec-tools.spec: Fix hardcoded-library-path errors
kexec-tools.spec: Fix whitespace errors
kexec-tools.spec | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
--
2.7.4
6 years, 6 months
[PATCH] kdumpctl: bail out earlier in case of no reserved memory
by Xunlei Pang
Some cloud people complained that VM boot speed is slower than
Ubuntu and other distributions, after some debugging, we found
that one of the causes is kdump service starts too slow(7seconds
according to the test result on the test VM), actually there is
no "crashkernel=X" specified. Although kdump service is parallel,
it affects the speed more or less especially on VMs with few cpus,
which is unacceptable. It is even worse when kdump initramfs is
built out in case of no reserved memory at first boot.
Commit afa4a35d3 ("kdumpctrl: kdump feasibility should fail if no
crash memory") can actually solve this issue.
This patch is a supplement of above-mentioned commit, we bail out
start() even earlier in case of no reserved memory.
Also made some cosmatic changes for check_crash_mem_reserved().
1) Before this patch
$ time kdumpctl start
No memory reserved for crash kernel.
Starting kdump: [FAILED]
real 0m0.282s
user 0m0.184s
sys 0m0.146s
2) After this patch
$ time kdumpctl start
No memory reserved for crash kernel
Starting kdump: [FAILED]
real 0m0.010s
user 0m0.008s
sys 0m0.001s
Signed-off-by: Xunlei Pang <xlpang(a)redhat.com>
---
kdumpctl | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 6b5be09..129cb6a 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1074,10 +1074,11 @@ is_secure_boot_enforced()
check_crash_mem_reserved()
{
- MEM_RESERVED=$(cat /sys/kernel/kexec_crash_size)
- if [ $MEM_RESERVED -eq 0 ]
- then
- echo "No memory reserved for crash kernel." >&2
+ local mem_reserved
+
+ mem_reserved=$(cat /sys/kernel/kexec_crash_size)
+ if [ $mem_reserved -eq 0 ]; then
+ echo "No memory reserved for crash kernel"
return 1
fi
@@ -1163,22 +1164,23 @@ check_default_config()
start()
{
- check_config
+ check_dump_feasibility
if [ $? -ne 0 ]; then
echo "Starting kdump: [FAILED]"
return 1
fi
- if sestatus 2>/dev/null | grep -q "SELinux status.*enabled"; then
- selinux_relabel
- fi
- save_raw
+ check_config
if [ $? -ne 0 ]; then
echo "Starting kdump: [FAILED]"
return 1
fi
- check_dump_feasibility
+ if sestatus 2>/dev/null | grep -q "SELinux status.*enabled"; then
+ selinux_relabel
+ fi
+
+ save_raw
if [ $? -ne 0 ]; then
echo "Starting kdump: [FAILED]"
return 1
--
1.8.3.1
6 years, 7 months
[PATCH] kdumpctl: for fence_kdump, the ipaddr of this node should be excluded from list
by Pingfan Liu
Since user can use ipaddr of a node instead of its hostname, so we need
to protect from this case.
Signed-off-by: Pingfan Liu <piliu(a)redhat.com>
---
kdump.conf | 4 ++--
kdumpctl | 7 +++++++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/kdump.conf b/kdump.conf
index 1e24e1b..cfdaec7 100644
--- a/kdump.conf
+++ b/kdump.conf
@@ -137,8 +137,8 @@
#
# fence_kdump_nodes <node(s)>
# - List of cluster node(s), separated by spaces, to send
-# fence_kdump notifications to (this option is mandatory to
-# enable fence_kdump).
+# fence_kdump notifications to. The list should exclude this node itself!
+# (this option is mandatory to enable fence_kdump).
#
#raw /dev/vg/lv_kdump
diff --git a/kdumpctl b/kdumpctl
index d43f46b..638c6b6 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1118,6 +1118,7 @@ check_kdump_feasibility()
check_fence_kdump_config()
{
local hostname=`hostname`
+ local ipaddrs=`hostname -i`
local nodes=$(get_option_value "fence_kdump_nodes")
for node in $nodes; do
@@ -1125,6 +1126,12 @@ check_fence_kdump_config()
echo "Option fence_kdump_nodes cannot contain $hostname"
return 1
fi
+ # node can be ipaddr
+ echo $ipaddrs | grep $node
+ if [ $? -eq 0 ]; then
+ echo "Option fence_kdump_nodes cannot contain $node"
+ return 1
+ fi
done
return 0
--
2.7.4
6 years, 7 months
[PATCH] kdump.sysconfig/x86_64: Add nokaslr to kdump kernel cmdline
by Baoquan He
KASLR is to enhance security on OS kernel. While kdump kernel is
working after normal kernel corrupted. There's no need to do kaslr
in kdump kernel, so add 'nokaslr' to disable kaslr.
Signed-off-by: Baoquan He <bhe(a)redhat.com>
---
kdump.sysconfig.x86_64 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64
index d4e26f5..f269d02 100644
--- a/kdump.sysconfig.x86_64
+++ b/kdump.sysconfig.x86_64
@@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
-KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 rootflags=nofail acpi_no_memhotplug transparent_hugepage=never"
+KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 rootflags=nofail acpi_no_memhotplug transparent_hugepage=never nokaslr"
# Any additional kexec arguments required. In most situations, this should
# be left empty
--
2.5.5
6 years, 7 months
[PATCH 1/2] kdump-lib-initramfs.sh: ignore the failure of echo
by Pingfan Liu
The kdump-capture.service will fail, if the following conds are meet up.
-1. boot up a VM with the following cmd:
qemu-kvm -name 'avocado-vt-vm1' -sandbox off -machine pc -nodefaults -vga cirrus \
-drive id=drive_image1,if=none,snapshot=off,aio=native,cache=none,format=qcow2,file=$guest_img \
-device virtio-blk-pci,id=image1,drive=drive_image1,bootindex=0,bus=pci.0,addr=04 \
-device virtio-net-pci,mac=9a:4d:4e:4f:50:51,id=id3DveCw,vectors=4,netdev=idgW5YRp,bus=pci.0,addr=05 \
-netdev tap,id=idgW5YRp \
-m 2048 \
-smp 4,maxcpus=4,cores=2,threads=1,sockets=2 \
-cpu 'SandyBridge',+kvm_pv_unhalt \
-vnc :0 \
-rtc base=utc,clock=host,driftfix=slew \
-boot order=cdn,once=c,menu=off,strict=off \
-enable-kvm \
-monitor stdio \
-qmp tcp:localhost:4444,server,nowait
-2. in kernel cmdline with the following options: console=tty0 console=ttyS0,
Because the "-nodefaults" option in qemu cmd excludes the emulation of serial port, the ttyS0 will
have no real backend device. We can observe such issue in 1st kernel by:
echo teststring > /dev/console or
echo teststring > /dev/ttyS0,
It gets the error "-bash: echo: write error: Input/output error".
Such conds cause small issue in 1st kernel, but it is a big problem for kdump-capture and emergency
service.
This patch aims to work aroundthe issue in kdump-capture service:
dump_fs() return value will affect the following code in dracut-kdump.sh
DUMP_RETVAL=$? <---
do_kdump_post $DUMP_RETVAL
if [ $? -ne 0 ]; then
echo "kdump: kdump_post script exited with non-zero status!"
fi
Although kdump-capture saves the vmcore successfully, but it exit 1 and
fall on emergency service.
Signed-off-by: Pingfan Liu <piliu(a)redhat.com>
---
kdump-lib-initramfs.sh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 4c0e2e2..2c18c87 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -111,6 +111,8 @@ dump_fs()
sync
echo "kdump: saving vmcore complete"
+ # improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure
+ return 0
}
save_vmcore_dmesg_fs() {
--
2.7.4
6 years, 7 months
[PATCH] Change kdump configuration file layout
by Bhupesh Sharma
This patch addresses Fedora BZ1078311 and introduces a new configuration
file layout structure for the kdump files.
Currently we have two variants of the kdump configuration files:
1. One in /etc/kdump.conf (for which initrd rebuild is required), and
2. Another in /etc/syconfig/kdump (for which initrd rebuild is not required).
In this patch, we create a single directory /etc/kdump/ and put both
the config files in there.
Currently we also don't have a mechanism to deliver new config options
in kdump.conf and kdump:
- During an upgrade we cannot upgrade /etc/kdump.conf or
/etc/sysconfig/kdump as the user might have modifed it locally and
new options will never be visible or take affect.
- So this patch proposes to ship default configs in /lib/kdump.
And this can be selectively overwritten by the user provided
config in /etc/kdump.
- So we now have config files available in
/lib/kdump/kdump.conf and /etc/kdump/kdump.conf (for example). This
allows us to upgrade /lib/kdump/kdump.conf during package upgrade and
ship new default options without breaking user configuration.
- Commands and comments available in
/lib/kdump/kdump.conf and /etc/kdump/kdump.conf are now handled using
the following logic:
1. If a unknown/deprecated command was found in user .conf, ignore it.
2. If a commented command was found in user .conf, preserve it.
3. If a non-commented command was found both in user .conf
and distro .conf, preserve the value specified in user.conf
4. If a new comment or command is found in distro .conf,
preserve it.
While at it, this patch also improves the kdump configuration file
description as its current wording - "this file contains a series of
commands to perform (in order)" is misleading.
As per the new configuration file layout, the man documentation source
for the kdump.conf has also been updated.
Here are some of the sample timings required after this change on Fedora
x86_64 machine:
1. When the kdump initrd is regenerated (when
there a new user kdump or kdump.conf file is generated)
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change(s) in the following file(s):
/etc/kdump/kdump.conf
Rebuilding /boot/initramfs-4.9.17-100.fc24.x86_64kdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
real 0m11.510s
user 0m14.480s
sys 0m2.464s
2. When the kdump initrd is not required to be generated
(as the user kdump and kdump.conf files remain unchanged):
kexec: unloaded kdump kernel
Stopping kdump: [OK]
kexec: loaded kdump kernel
Starting kdump: [OK]
real 0m3.713s
user 0m3.446s
sys 0m0.525s
Signed-off-by: Bhupesh Sharma <bhsharma(a)redhat.com>
---
dracut-module-setup.sh | 10 +-
fadump-howto.txt | 8 +-
kdump-create-config.sh | 365 +++++++++++++++++++++++++++++++++++++++++++++
kdump-lib-initramfs.sh | 2 +-
kdump-lib.sh | 21 +--
kdump.conf | 4 +-
kdump.conf.5 | 43 +++++-
kdumpctl | 38 +++--
kexec-kdump-howto.txt | 18 +--
kexec-tools.spec | 30 ++--
live-image-kdump-howto.txt | 2 +-
mkdumprd | 4 +-
mkdumprd.8 | 4 +-
13 files changed, 481 insertions(+), 68 deletions(-)
create mode 100755 kdump-create-config.sh
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index bdf67cee2fd5..b6ad9fb5da3a 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -1,5 +1,7 @@
#!/bin/bash
+KDUMP_CONFIG_FILE="/etc/kdump/kdump.conf"
+
. $dracutfunctions
. /lib/kdump/kdump-lib.sh
@@ -10,7 +12,7 @@ fi
check() {
[[ $debug ]] && set -x
#kdumpctl sets this explicitly
- if [ -z "$IN_KDUMP" ] || [ ! -f /etc/kdump.conf ]
+ if [ -z "$IN_KDUMP" ] || [ ! -f $KDUMP_CONFIG_FILE ]
then
return 1
fi
@@ -439,7 +441,7 @@ adjust_bind_mount_path()
#install kdump.conf and what user specifies in kdump.conf
kdump_install_conf() {
local _opt _val _pdev
- sed -ne '/^#/!p' /etc/kdump.conf > ${initdir}/tmp/$$-kdump.conf
+ sed -ne '/^#/!p' $KDUMP_CONFIG_FILE > ${initdir}/tmp/$$-kdump.conf
while read _opt _val;
do
@@ -472,12 +474,12 @@ kdump_install_conf() {
dracut_install "${_val%%[[:blank:]]*}"
;;
esac
- done < /etc/kdump.conf
+ done < $KDUMP_CONFIG_FILE
default_dump_target_install_conf
kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf"
- inst "${initdir}/tmp/$$-kdump.conf" "/etc/kdump.conf"
+ inst "${initdir}/tmp/$$-kdump.conf" "$KDUMP_CONFIG_FILE"
rm -f ${initdir}/tmp/$$-kdump.conf
}
diff --git a/fadump-howto.txt b/fadump-howto.txt
index be17da3ce2c9..023eddbf3d4d 100644
--- a/fadump-howto.txt
+++ b/fadump-howto.txt
@@ -54,7 +54,7 @@ after crash. Hence, for fadump, we rebuild the new kdump initrd and replace it
with default initrd. Before replacing existing default initrd we take a backup
of original default initrd for user's reference. The dracut package has been
enhanced to rebuild the default initrd with vmcore capture steps. The initrd
-image is rebuilt as per the configuration in /etc/kdump.conf file.
+image is rebuilt as per the configuration in /etc/kdump/kdump.conf file.
The control flow of fadump works as follows:
01. System panics.
@@ -69,9 +69,9 @@ The control flow of fadump works as follows:
steps to capture vmcore.
(This check will help to bypass the vmcore capture steps during normal boot
process.)
-09. Captures dump according to /etc/kdump.conf
+09. Captures dump according to /etc/kdump/kdump.conf
10. Is dump capture successful (yes goto 12, no goto 11)
-11. Perfom the default action specified in /etc/kdump.conf (Default action
+11. Perfom the default action specified in /etc/kdump/kdump.conf (Default action
is reboot, if unspecified)
12. Reboot
@@ -245,7 +245,7 @@ Dracut is designed to mount rootfs by default. If rootfs mounting fails it
will refuse to go on. So fadump leaves rootfs mounting to dracut currently.
We make the assumtion that proper root= cmdline is being passed to dracut
initramfs for the time being. If you need modify "KDUMP_COMMANDLINE=" in
-/etc/sysconfig/kdump, you will need to make sure that appropriate root=
+/etc/kdump/kdump, you will need to make sure that appropriate root=
options are copied from /proc/cmdline. In general it is best to append
command line options using "KDUMP_COMMANDLINE_APPEND=" instead of replacing
the original command line completely.
diff --git a/kdump-create-config.sh b/kdump-create-config.sh
new file mode 100755
index 000000000000..231391d5ff34
--- /dev/null
+++ b/kdump-create-config.sh
@@ -0,0 +1,365 @@
+#!/bin/sh
+
+# Normally we can have two variants of the kdump.conf and kdump files:
+# 1. The distribution specific one, which is usually located
+# inside /lib/kdump/
+# 2. And the user specific one, which is usually located inside
+# /etc/kdump
+#
+# So, here we need to create the final kdump.conf or kdump file by
+# looking at both the distribution provided .conf and the user's copy
+# of the .conf file and picking up the various directives such that
+# the ones specified in the user's copy always take a precedence on
+# those specified in the distribution provided .config
+
+USER_KDUMP_CONFIG_DIR="/etc/kdump"
+TMP_KDUMP_CONFIG_DIR="/etc/kdump/tmp"
+USER_KDUMP_CONFIG_FILE="/etc/kdump/kdump.conf"
+BACKUP_USER_KDUMP_CONFIG_FILE="/etc/kdump/kdump.conf.usrorig"
+TMP_KDUMP_CONFIG_FILE="/etc/kdump/tmp-kdump.conf"
+DISTRO_KDUMP_CONFIG_FILE="/lib/kdump/kdump.conf"
+
+USER_KDUMP_FILE="/etc/kdump/kdump"
+BACKUP_USER_KDUMP_FILE="/etc/kdump/kdump.usrorig"
+TMP_KDUMP_FILE="/etc/kdump/tmp-kdump"
+DISTRO_KDUMP_FILE="/lib/kdump/kdump"
+
+DEPRECATED_KDUMP_CONFIG_FILE="/etc/kdump.conf"
+DEPRECATED_KDUMP_FILE="/etc/sysconfig/kdump"
+
+use_distribution_config_file()
+{
+ local DISTRO_FILE=$1
+ local USER_FILE=$2
+
+ # Check if $USER_KDUMP_CONFIG_DIR exists, if not create it
+ [ ! -d $USER_KDUMP_CONFIG_DIR ] && mkdir -p $USER_KDUMP_CONFIG_DIR
+
+ # Check if $USER_KDUMP_CONFIG_FILE exists, if not
+ # copy the $DISTRO_KDUMP_CONFIG_FILE over
+ [ ! -f $USER_FILE ] && cp -f $DISTRO_FILE $USER_FILE
+}
+
+use_deprecated_config_file()
+{
+ local DEPRECATED_FILE=$1
+ local USER_FILE=$2
+
+ # Check if $USER_KDUMP_CONFIG_DIR exists, if not create it
+ [ ! -d $USER_KDUMP_CONFIG_DIR ] && mkdir -p $USER_KDUMP_CONFIG_DIR
+
+ # Copy the $DEPRECATED_FILE as $USER_FILE
+ cp -f $DEPRECATED_FILE $USER_FILE
+}
+
+create_backup_of_user_config_file()
+{
+ local USER_FILE=$1
+ local BACKUP_FILE=$2
+
+ cp -f $USER_FILE $BACKUP_FILE
+ echo "$USER_FILE saved as $BACKUP_FILE"
+}
+
+is_user_config_file_present()
+{
+ local USER_FILE=$1
+ local DEPRECATED_FILE=$2
+
+ if [ -f $USER_FILE ]; then
+ return 1
+ else
+ # If deprecated config file is present, copy it as the
+ # user config file since it does not exist originally.
+ if [ -f $DEPRECATED_FILE ]; then
+ use_deprecated_config_file $DEPRECATED_FILE $USER_FILE
+ return 1
+ else
+ return 0
+ fi
+ fi
+}
+
+is_distribution_specific_config_file_present()
+{
+ local DISTRO_FILE=$1
+
+ if [ -f $DISTRO_FILE ]; then
+ return 1
+ fi
+
+ return 0
+}
+
+create_final_config_file_initrd_rebuild_not_reqd()
+{
+ local DISTRO_FILE=$1
+ local USER_FILE=$2
+ local TMP_FILE=$3
+ local BACKUP_FILE=$4
+
+ # Logic below requires the comments and commands in a .conf
+ # file to be seperated via a blank line. If we don't see the
+ # same, bail out with a error
+ if [ $(grep -c "^$" $DISTRO_FILE) -eq 0 ]; then
+ echo "Error! Invalid $DISTRO_FILE format" >&2
+ exit 1
+ fi
+
+ if [ $(grep -c "^$" $USER_FILE) -eq 0 ]; then
+ echo "Error! Invalid $USER_FILE format" >&2
+ exit 1
+ fi
+
+ # Create TMP directory to hold temporary files
+ TMP_KDUMP_CONFIG_DIR=$(mktemp -d)
+
+ # Setup a cleanup in case we trap a signal which is going to
+ # kill this script
+ trap 'rm -rf $TMP_KDUMP_CONFIG_DIR $TMP_FILE' EXIT
+
+ # Remove leftover tmp files (if any)
+ if [ -f $TMP_FILE ]; then
+ rm -f $TMP_FILE
+ fi
+
+ # Now setup the temporary files
+ local USER_CMD_FILE=$TMP_KDUMP_CONFIG_DIR/USER_CMD.$$.tmp
+ local DISTRO_CMD_FILE=$TMP_KDUMP_CONFIG_DIR/DISTRO_CMD.$$.tmp
+ local CMD_TMP_FILE=$TMP_KDUMP_CONFIG_DIR/CMD_TMP.$$.tmp
+
+ # Final .conf file creation rules:
+ # 1. If a unknown/deprecated command was found in user .conf,
+ # ignore it.
+ # 2. If a commented command was found in user .conf, preserve it.
+ # 3. If a non-commented command was found both in user .conf
+ # and distro .conf, preserve the value specified in user.conf
+ # 4. If a new comment or command is found in distro .conf,
+ # preserve it.
+
+ # First copy the comment section (which is seperated by a
+ # blankline from the commands) into the new .conf file
+ sed -e '/./!Q' $DISTRO_FILE > $TMP_FILE 2>&1
+
+ # Add a blank line
+ echo "" >> $TMP_FILE 2>&1
+
+ sed '1,/^$/d' $DISTRO_FILE > $DISTRO_CMD_FILE 2>&1
+ sed '1,/^$/d' $USER_FILE > $USER_CMD_FILE 2>&1
+
+ # Check if the rest of the distro and user conf files are exact
+ # replicas. If yes, do nothing more and copy the rest of the
+ # distro conf file as the new conf file
+ cmp -s $DISTRO_CMD_FILE $USER_CMD_FILE
+ if [ $? -eq 0 ]; then
+ cat $DISTRO_CMD_FILE >> $TMP_FILE
+ else
+ # Copy common comments and commands specified in both
+ # distro and user .conf into the new .conf file
+ awk 'NR==FNR{A[$1];next} $1 in A' $USER_CMD_FILE $DISTRO_CMD_FILE >> $TMP_FILE 2>&1
+
+ # Now, copy new comments and commands specified in
+ # distro .conf into the new .conf file
+ grep -vxFf $USER_CMD_FILE $DISTRO_CMD_FILE >> $TMP_FILE 2>&1
+
+ # If there are any duplicates exisiting, deal with them
+ # (prefer those mentioned in user .conf):
+ grep -vxFf $DISTRO_CMD_FILE $USER_CMD_FILE >> $CMD_TMP_FILE 2>&1
+ sed --in-place "/^#$(awk '{print $1}' $CMD_TMP_FILE)/d" $TMP_FILE 2>&1
+ sed --in-place "/^$(awk '{print $1}' $CMD_TMP_FILE)/d" $TMP_FILE 2>&1
+
+ # Finally, copy whats changed in user .conf
+ grep -vxFf $DISTRO_CMD_FILE $USER_CMD_FILE >> $TMP_FILE 2>&1
+ fi
+
+ # If the newly generated .conf file is the same as the backup
+ # copy, do nothing
+ cmp -s $TMP_FILE $BACKUP_FILE
+ if [ $? -ne 0 ]; then
+ # Now finally move this .conf file as the default .conf
+ # file
+ mv -f $TMP_FILE $USER_FILE
+ fi
+
+ # Remove leftover tmp files (if any)
+ if [ -f $TMP_FILE ]; then
+ rm -f $TMP_FILE
+ fi
+
+ rm -rf $TMP_KDUMP_CONFIG_DIR
+}
+
+create_final_config_file_initrd_rebuild_reqd()
+{
+ local DISTRO_FILE=$1
+ local USER_FILE=$2
+ local TMP_FILE=$3
+ local BACKUP_FILE=$4
+
+ # Create TMP directory to hold temporary files
+ TMP_KDUMP_CONFIG_DIR=$(mktemp -d)
+
+ # Setup a cleanup in case we trap a signal which is going to
+ # kill this script
+ trap 'rm -rf $TMP_KDUMP_CONFIG_DIR $TMP_FILE' EXIT
+
+ # Remove existing tmp files (if any)
+ if [ -f $TMP_FILE ]; then
+ rm -f $TMP_FILE
+ fi
+
+ # Now setup the temporary files
+ local USER_CMD_FILE=$TMP_KDUMP_CONFIG_DIR/USER.$$.tmp
+ local CMD_TMP_FILE=$TMP_KDUMP_CONFIG_DIR/CMD_TMP.$$.tmp
+ local FINAL_TMP_FILE=$TMP_KDUMP_CONFIG_DIR/TMP.$$.tmp
+
+ # Copy the distro .conf file to new .conf file
+ cp -f $DISTRO_FILE $TMP_FILE
+
+ # Now, handle deprecated or modified commands in user.conf.
+ # Remove the deprecated commands and keep the modified commands
+ # in the new .conf file
+ grep -vxFf $DISTRO_FILE $USER_FILE > $USER_CMD_FILE 2>&1
+
+ # There can be some commands which have been redefined or added
+ # in the user .conf and hence do not match the respective distro
+ # .conf.
+ #
+ # Ignore any deprecated command mentioned in the user .conf and
+ # return the value of a command (assuming a command is defined
+ # as:
+ # COMMAND=This is my command [i.e. using the '=' separator]
+ # so that it can be retained in the new .conf
+ #
+ # Finally move this new .conf file as the user .conf file
+ awk -F '=' '{A[$1];print $1}' $USER_CMD_FILE >> $CMD_TMP_FILE 2>&1
+
+ sed -e "s/$(grep "^$(awk -F '=' 'NR==FNR{A[$1];next} $1 in A' $TMP_FILE $CMD_TMP_FILE)" $TMP_FILE)/$(grep "^$(awk -F '=' 'NR==FNR{A[$1];next} $1 in A' $TMP_FILE $CMD_TMP_FILE)" $USER_CMD_FILE)/" $TMP_FILE > $FINAL_TMP_FILE
+
+ # If the newly generated .conf file is the same as the backup
+ # copy, do nothing
+ cmp -s $FINAL_TMP_FILE $BACKUP_FILE
+ if [ $? -ne 0 ]; then
+ # Now finally move this .conf file as the default .conf
+ # file
+ mv -f $FINAL_TMP_FILE $USER_FILE
+ fi
+
+ # Remove leftover tmp files (if any)
+ if [ -f $TMP_FILE ]; then
+ rm -f $TMP_FILE
+ fi
+
+ rm -rf $TMP_KDUMP_CONFIG_DIR
+}
+
+create_final_config_file()
+{
+ local INITRD_REBUILD_REQD=$1
+ local DISTRO_FILE=$2
+ local USER_FILE=$3
+ local TMP_FILE=$4
+ local BACKUP_FILE=$5
+
+ if [ $INITRD_REBUILD_REQD -eq 1 ]; then
+ create_final_config_file_initrd_rebuild_reqd \
+ $DISTRO_FILE $USER_FILE $TMP_FILE $BACKUP_FILE
+ else
+ create_final_config_file_initrd_rebuild_not_reqd \
+ $DISTRO_FILE $USER_FILE $TMP_FILE $BACKUP_FILE
+ fi
+}
+
+handle_config_files()
+{
+ local INITRD_REBUILD_REQD=$1
+ local DISTRO_FILE=$2
+ local USER_FILE=$3
+ local TMP_FILE=$4
+ local BACKUP_FILE=$5
+ local DEPRECATED_FILE=$6
+
+ # Check if the user specified .conf file exists
+ is_user_config_file_present $USER_FILE $DEPRECATED_FILE
+ if [ $? -eq 1 ]; then
+ # Check if the distro specified .conf file exists
+ is_distribution_specific_config_file_present $DISTRO_FILE
+ if [ $? -eq 1 ]; then
+ # Check if the distro and user conf files are
+ # exact replicas. If yes, do nothing and copy
+ # distro conf file as the user conf file
+ cmp -s $DISTRO_FILE $USER_FILE
+ if [ $? -eq 0 ]; then
+ use_distribution_config_file \
+ $DISTRO_FILE $USER_FILE
+ else
+ # Create a backup copy of the user
+ # specified .conf file, so that the
+ # user can track changes (if required)
+ # later-on
+ create_backup_of_user_config_file \
+ $USER_FILE $BACKUP_FILE
+
+ # Traverse the user's copy of kdump.conf
+ # file and the distro specific version
+ # and create a final kdump.conf file
+ # which gives precedence to the user
+ # specific settings
+ create_final_config_file \
+ $INITRD_REBUILD_REQD \
+ $DISTRO_FILE $USER_FILE \
+ $TMP_FILE $BACKUP_FILE
+ fi
+ fi
+ else
+ # Check if the distro specified .conf file exists
+ # and use the same as the default
+ is_distribution_specific_config_file_present $DISTRO_FILE
+ if [ $? -eq 1 ]; then
+ use_distribution_config_file $DISTRO_FILE \
+ $USER_FILE
+ else
+ echo "Error! No valid config file found" >&2
+ exit 1
+ fi
+ fi
+}
+
+remove_deprecated_config_files()
+{
+ local DEPRECATED_CONFIG_FILE=$1
+ local USER_KDUMP_FILE=$2
+
+ # If everything went ok and the conf files are properly
+ # generated, remove the deprecated config files
+ if [[ -f $DEPRECATED_CONFIG_FILE && -f $USER_KDUMP_FILE && -s $USER_KDUMP_FILE ]]; then
+ rm -f $DEPRECATED_CONFIG_FILE
+ fi
+}
+
+handle_config_files_initrd_rebuild_not_required()
+{
+ local INITRD_REBUILD_REQD=0
+ handle_config_files $INITRD_REBUILD_REQD \
+ $DISTRO_KDUMP_CONFIG_FILE $USER_KDUMP_CONFIG_FILE \
+ $TMP_KDUMP_CONFIG_FILE $BACKUP_USER_KDUMP_CONFIG_FILE \
+ $DEPRECATED_KDUMP_CONFIG_FILE
+ remove_deprecated_config_files $DEPRECATED_KDUMP_CONFIG_FILE \
+ $USER_KDUMP_CONFIG_FILE
+}
+
+handle_config_files_initrd_rebuild_required()
+{
+ local INITRD_REBUILD_REQD=1
+ handle_config_files $INITRD_REBUILD_REQD $DISTRO_KDUMP_FILE \
+ $USER_KDUMP_FILE $TMP_KDUMP_FILE \
+ $BACKUP_USER_KDUMP_FILE $DEPRECATED_KDUMP_FILE
+ remove_deprecated_config_files $DEPRECATED_KDUMP_FILE \
+ $USER_KDUMP_FILE
+}
+
+handle_dump_config_files()
+{
+ handle_config_files_initrd_rebuild_not_required
+ handle_config_files_initrd_rebuild_required
+}
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 4c0e2e2837fd..ec36d00e6025 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -14,7 +14,7 @@ SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
KDUMP_SCRIPT_DIR="/kdumpscripts"
DD_BLKSIZE=512
FINAL_ACTION="systemctl reboot -f"
-KDUMP_CONF="/etc/kdump.conf"
+KDUMP_CONF="/etc/kdump/kdump.conf"
KDUMP_PRE=""
KDUMP_POST=""
NEWROOT="/sysroot"
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 8ebad70d8d92..2849110c8063 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -6,6 +6,7 @@
DEFAULT_PATH="/var/crash/"
FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump"
FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send"
+KDUMP_CONFIG_FILE="/etc/kdump/kdump.conf"
perror_exit() {
echo $@ >&2
@@ -18,18 +19,18 @@ perror() {
is_ssh_dump_target()
{
- grep -q "^ssh[[:blank:]].*@" /etc/kdump.conf
+ grep -q "^ssh[[:blank:]].*@" $KDUMP_CONFIG_FILE
}
is_nfs_dump_target()
{
- grep -q "^nfs" /etc/kdump.conf || \
- [[ $(get_dracut_args_fstype "$(grep "^dracut_args .*\-\-mount" /etc/kdump.conf)") = nfs* ]]
+ grep -q "^nfs" $KDUMP_CONFIG_FILE || \
+ [[ $(get_dracut_args_fstype "$(grep "^dracut_args .*\-\-mount" $KDUMP_CONFIG_FILE)") = nfs* ]]
}
is_raw_dump_target()
{
- grep -q "^raw" /etc/kdump.conf
+ grep -q "^raw" $KDUMP_CONFIG_FILE
}
is_fs_type_nfs()
@@ -41,7 +42,7 @@ is_fs_type_nfs()
is_fs_dump_target()
{
- egrep -q "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf
+ egrep -q "^ext[234]|^xfs|^btrfs|^minix" $KDUMP_CONFIG_FILE
}
is_user_configured_dump_target()
@@ -71,7 +72,7 @@ is_generic_fence_kdump()
{
[ -x $FENCE_KDUMP_SEND ] || return 1
- grep -q "^fence_kdump_nodes" /etc/kdump.conf
+ grep -q "^fence_kdump_nodes" $KDUMP_CONFIG_FILE
}
to_dev_name() {
@@ -96,7 +97,7 @@ get_user_configured_dump_disk()
return
fi
- _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf 2>/dev/null |awk '{print $2}')
+ _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" $KDUMP_CONFIG_FILE 2>/dev/null |awk '{print $2}')
[ -n "$_target" ] && echo $_target
return
@@ -194,7 +195,7 @@ get_mntpoint_from_target()
# get_option_value <option_name>
# retrieves value of option defined in kdump.conf
get_option_value() {
- echo $(strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-`)
+ echo $(strip_comments `grep "^$1[[:space:]]\+" $KDUMP_CONFIG_FILE | tail -1 | cut -d\ -f2-`)
}
#This function compose a absolute path with the mount
@@ -369,7 +370,7 @@ is_wdt_mod_omitted() {
local dracut_args
local ret=1
- dracut_args=$(grep "^dracut_args" /etc/kdump.conf)
+ dracut_args=$(grep "^dracut_args" $KDUMP_CONFIG_FILE)
[[ -z $dracut_args ]] && return $ret
eval set -- $dracut_args
@@ -392,7 +393,7 @@ is_wdt_mod_omitted() {
# its correctness).
is_mount_in_dracut_args()
{
- grep -q "^dracut_args .*\-\-mount" /etc/kdump.conf
+ grep -q "^dracut_args .*\-\-mount" $KDUMP_CONFIG_FILE
}
# If $1 contains dracut_args "--mount", return <filesystem type>
diff --git a/kdump.conf b/kdump.conf
index ebf9587a6522..c34a8e39d365 100644
--- a/kdump.conf
+++ b/kdump.conf
@@ -1,5 +1,5 @@
-# This file contains a series of commands to perform (in order) in the kdump
-# kernel after a kernel crash in the crash kernel(1st kernel) has happened.
+# This configuration file contains options which are used by the kdump kernel crash
+# collection service.
#
# Directives in this file are only applicable to the kdump initramfs, and have
# no effect once the root filesystem is mounted and the normal init scripts are
diff --git a/kdump.conf.5 b/kdump.conf.5
index ca427699be53..9e36a63a09d6 100644
--- a/kdump.conf.5
+++ b/kdump.conf.5
@@ -14,7 +14,7 @@ this file and do not want to reboot in order for the changes to take
effect, restart the kdump service to rebuild the initrd.
For most configurations, you can simply review the examples provided
-in the stock /etc/kdump.conf.
+in the stock /lib/kdump/kdump.conf.
.B NOTE:
For filesystem dumps the dump target must be mounted before building
@@ -205,7 +205,7 @@ directly.
.B options <module> <option list>
.RS
-Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump to add module options as
+Use KDUMP_COMMANDLINE_APPEND in /etc/kdump/kdump to add module options as
kernel command line parameters. For example, specify 'loop.max_loop=1' to limit
maximum loop devices to 1.
.RE
@@ -226,7 +226,7 @@ Similar to link_delay, dracut ensures disks are ready before kdump uses them.
Turn on verbose debug output of kdump scripts regarding free/used memory at
various points of execution. This feature has been
moved to dracut now.
-Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump and
+Use KDUMP_COMMANDLINE_APPEND in /etc/kdump/kdump and
append dracut cmdline param rd.memdebug=[0-3] to enable the debug output.
Higher level means more debugging output.
@@ -249,7 +249,7 @@ retaining blacklist option creates more confusing behavior. It has been
deprecated.
.PP
Instead, use rd.driver.blacklist option on second kernel to blacklist
-a certain module. One can edit /etc/sysconfig/kdump.conf and edit
+a certain module. One can edit /etc/kdump/kdump and edit
KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer
to dracut.cmdline man page for more details on module blacklist option.
.RE
@@ -326,8 +326,39 @@ Above will effectively be translated to.
scp /proc/vmcore <user@host>:path/vmcore
.PP
-examples for other options please see
-.I /etc/kdump.conf
+for examples of other options please see
+.I /lib/kdump/kdump.conf
+
+.SH FILES
+.B /lib/kdump/kdump.conf
+.RS
+Distribution kdump configuration file which may be updated during
+package upgrade.
+.RE
+
+.B /etc/kdump.conf
+.RS
+Deprecated user configuration file. New distributions now support
+/etc/kdump/kdump.conf as the default user kdump configuration file.
+.RE
+
+.B /etc/kdump/kdump.conf
+.RS
+User kdump configuration file which takes precedence over the
+distribution kdump configuration file. Any variables specified in
+/etc/kdump/kdump.conf will override the defaults specified in
+/lib/kdump/kdump.conf.
+.RE
+
+.B /etc/kdump/kdump.conf.usrorig
+.RS
+If the user kdump configuration file (/etc/kdump.conf or
+/etc/kdump/kdump.conf) already exists, it is saved as
+/etc/kdump/kdump.conf.usrorig before a new user kdump configuration file
+is generated (by merging contents of the distribution and user
+configuration files), so that the user can refer to the same later
+(if required).
+.RE
.SH SEE ALSO
diff --git a/kdumpctl b/kdumpctl
index 4d68be0c292d..2746f20932d0 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -4,7 +4,8 @@ KEXEC=/sbin/kexec
KDUMP_KERNELVER=""
KDUMP_COMMANDLINE=""
KEXEC_ARGS=""
-KDUMP_CONFIG_FILE="/etc/kdump.conf"
+KDUMP_CONFIG_FILE="/etc/kdump/kdump.conf"
+KDUMP_FILE="/etc/kdump/kdump"
MKDUMPRD="/sbin/mkdumprd -f"
SAVE_PATH=/var/crash
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
@@ -23,14 +24,22 @@ image_time=0
. $dracutbasedir/dracut-functions.sh
. /lib/kdump/kdump-lib.sh
+# We need to create the final kdump .conf file by looking at both
+# the distribution provided .conf and the user's copy of the .conf
+# file
+. /lib/kdump/kdump-create-config.sh
+
standard_kexec_args="-p"
-# Some default values in case /etc/sysconfig/kdump doesn't include
+# Some default values in case /etc/kdump/kdump doesn't include
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug"
-if [ -f /etc/sysconfig/kdump ]; then
- . /etc/sysconfig/kdump
-fi
+source_dump_file()
+{
+ if [ -f $KDUMP_FILE ]; then
+ . $KDUMP_FILE
+ fi
+}
single_instance_lock()
{
@@ -683,7 +692,7 @@ need_64bit_headers()
print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }'`
}
-# Load the kdump kernel specified in /etc/sysconfig/kdump
+# Load the kdump kernel specified in /etc/kdump/kdump
# If none is specified, try to load a kdump kernel with the same version
# as the currently running kernel.
load_kdump()
@@ -932,7 +941,7 @@ save_raw()
get_save_path()
{
- local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}')
+ local _save_path=$(grep "^path" $KDUMP_CONFIG_FILE|awk '{print $2}')
if [ -z "$_save_path" ]; then
_save_path="/var/crash"
fi
@@ -944,7 +953,7 @@ is_dump_target_configured()
{
local _target
- _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw|^ssh|^nfs" /etc/kdump.conf)
+ _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw|^ssh|^nfs" $KDUMP_CONFIG_FILE)
[ -n "$_target" ]
}
@@ -953,7 +962,7 @@ local_fs_dump_target()
{
local _target
- _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf)
+ _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix" $KDUMP_CONFIG_FILE)
if [ $? -eq 0 ]; then
echo $_target|awk '{print $2}'
fi
@@ -1120,6 +1129,12 @@ check_default_config()
start()
{
+ # Gracefully handle all possible combinations od kdump
+ # configuration files and generate the final version of the same
+ # which can be used further
+ handle_dump_config_files
+ source_dump_file
+
check_config
if [ $? -ne 0 ]; then
echo "Starting kdump: [FAILED]"
@@ -1215,11 +1230,6 @@ stop()
return 0
}
-if [ ! -f "$KDUMP_CONFIG_FILE" ]; then
- echo "Error: No kdump config file found!" >&2
- exit 1
-fi
-
main ()
{
# Determine if the dump mode is kdump or fadump
diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt
index f46563f2f527..aca84c246094 100644
--- a/kexec-kdump-howto.txt
+++ b/kexec-kdump-howto.txt
@@ -267,9 +267,9 @@ as allowing for the centralization of vmcore files, should you have several
systems from which you'd like to obtain vmcore files. Of course, note that
these configurations could present problems if your network is unreliable.
-Advanced setups are configured via modifications to /etc/kdump.conf,
+Advanced setups are configured via modifications to /etc/kdump/kdump.conf,
which out of the box, is fairly well documented itself. Any alterations to
-/etc/kdump.conf should be followed by a restart of the kdump service, so
+/etc/kdump/kdump.conf should be followed by a restart of the kdump service, so
the changes can be incorporated in the kdump initrd. Restarting the kdump
service is as simple as '/sbin/systemctl restart kdump.service'.
@@ -278,7 +278,7 @@ Note that kdump.conf is used as a configuration mechanism for capturing dump
files from the initramfs (in the interests of safety), the root file system is
mounted, and the init process is started, only as a last resort if the
initramfs fails to capture the vmcore. As such, configuration made in
-/etc/kdump.conf is only applicable to capture recorded in the initramfs. If
+/etc/kdump/kdump.conf is only applicable to capture recorded in the initramfs. If
for any reason the init process is started on the root file system, only a
simple copying of the vmcore from /proc/vmcore to /var/crash/$DATE/vmcore will
be preformed.
@@ -352,7 +352,7 @@ about the format of "--mount" for details. If there is any "--mount" specified
via "dracut_args", kdump will build it as the mount target without doing any
validation (mounting or checking like mount options, fs size, save path, etc),
so you must test it to ensure all the correctness. You cannot use other targets
-in /etc/kdump.conf if you use "--mount" in "dracut_args". You also cannot specify
+in /etc/kdump/kdump.conf if you use "--mount" in "dracut_args". You also cannot specify
mutliple "--mount" targets via "dracut_args".
One use case of "--mount" in "dracut_args" is you do not want to mount dump target
@@ -430,7 +430,7 @@ command and get an output:
cat /proc/cmdline
BOOT_IMAGE=/xxx/vmlinuz-3.yyy.zzz root=xxxx .....
Then kdump kernel will be /boot/xxx/vmlinuz-3.yyy.zzz.
-However a variable KDUMP_BOOTDIR in /etc/sysconfig/kdump is provided to
+However a variable KDUMP_BOOTDIR in /etc/kdump/kdump is provided to
user if kdump kernel is put in a different directory.
Kdump Post-Capture Executable
@@ -616,12 +616,12 @@ operating and capturing a vmcore image, but a casual observer will see the
system as hung until the dump completes and a true reboot is executed.
There are two possiblilties to work around this issue. One is by adding
---reset-vga to the kexec command line options in /etc/sysconfig/kdump. This
+--reset-vga to the kexec command line options in /etc/kdump/kdump. This
tells kdump to write some reasonable default values to the video card register
file, in the hopes of returning it to a text mode such that boot messages are
visible on the screen. It does not work with all video cards however.
Secondly, it may be worth trying to add vga15fb.ko to the extra_modules list in
-/etc/kdump.conf. This will attempt to use the video card in framebuffer mode,
+/etc/kdump/kdump.conf. This will attempt to use the video card in framebuffer mode,
which can blank the screen prior to the start of a dump capture.
Notes on rootfs mount:
@@ -629,7 +629,7 @@ Dracut is designed to mount rootfs by default. If rootfs mounting fails it
will refuse to go on. So kdump leaves rootfs mounting to dracut currently.
We make the assumtion that proper root= cmdline is being passed to dracut
initramfs for the time being. If you need modify "KDUMP_COMMANDLINE=" in
-/etc/sysconfig/kdump, you will need to make sure that appropriate root=
+/etc/kdump/kdump, you will need to make sure that appropriate root=
options are copied from /proc/cmdline. In general it is best to append
command line options using "KDUMP_COMMANDLINE_APPEND=" instead of replacing
the original command line completely.
@@ -668,7 +668,7 @@ hardware issue (*). The disable_cpu_apicid kernel option is automatically
appended by kdumpctl script and is ignored if the kernel doesn't support it.
You need to specify how many cpus to be used in a capture kernel by specifying
-the number of cpus in nr_cpus kernel option in /etc/sysconfig/kdump. nr_cpus
+the number of cpus in nr_cpus kernel option in /etc/kdump/kdump. nr_cpus
is 1 at default.
You should use necessary and sufficient number of cpus on a capture kernel.
diff --git a/kexec-tools.spec b/kexec-tools.spec
index dcf074ced3fb..6ce4e218a722 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -1,3 +1,5 @@
+%define kdumplibdir %{_prefix}/lib/kdump
+
Name: kexec-tools
Version: 2.0.14
Release: 7%{?dist}
@@ -29,6 +31,7 @@ Source24: kdump-lib-initramfs.sh
Source25: kdump.sysconfig.ppc64le
Source26: kdumpctl.8
Source27: live-image-kdump-howto.txt
+Source28: kdump-create-config.sh
#######################################
# These are sources for mkdumpramfs
@@ -160,7 +163,7 @@ make -C kdump-anaconda-addon/po
%install
make install DESTDIR=$RPM_BUILD_ROOT
-mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
+mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump
mkdir -p -m755 $RPM_BUILD_ROOT%{_localstatedir}/crash
mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man8/
mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man5/
@@ -176,15 +179,16 @@ install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/kdumpctl
SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu}
[ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_arch}
[ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig
-install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump
+install -m 644 $SYSCONFIG $RPM_BUILD_ROOT/%{kdumplibdir}/kdump
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/sbin/mkdumprd
-install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf
+install -m 644 %{SOURCE8} $RPM_BUILD_ROOT/%{kdumplibdir}/kdump.conf
install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8
install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8
install -m 644 %{SOURCE26} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8
install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh
install -m 755 %{SOURCE24} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh
+install -m 755 %{SOURCE28} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-create-config.sh
%ifnarch s390x
# For s390x the ELF header is created in the kdump kernel and therefore kexec
# udev rules are not required
@@ -228,13 +232,16 @@ mkdir -p $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/
mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/
%post
+# .conf file handling
+sh %{kdumplibdir}/kdump-create-config.sh
+
# Initial installation
%systemd_post kdump.service
-touch /etc/kdump.conf
+touch %{kdumplibdir}/kdump.conf
# 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
+# in /etc/kdump/kdump. It will be removed when
# These systems are fixed.
if [ -d /proc/bus/mckinley ]
@@ -242,16 +249,16 @@ then
# This is for HP zx1 machines
# They require machvec=dig on the kernel command line
sed -e's/\(^KDUMP_COMMANDLINE_APPEND.*\)\("$\)/\1 machvec=dig"/' \
- /etc/sysconfig/kdump > /etc/sysconfig/kdump.new
- mv /etc/sysconfig/kdump.new /etc/sysconfig/kdump
+ /etc/kdump/kdump > /etc/kdump/kdump.new
+ mv /etc/kdump/kdump.new /etc/kdump/kdump
elif [ -d /proc/sgi_sn ]
then
# This is for SGI SN boxes
# They require the --noio option to kexec
# since they don't support legacy io
sed -e's/\(^KEXEC_ARGS.*\)\("$\)/\1 --noio"/' \
- /etc/sysconfig/kdump > /etc/sysconfig/kdump.new
- mv /etc/sysconfig/kdump.new /etc/sysconfig/kdump
+ /etc/kdump/kdump > /etc/kdump/kdump.new
+ mv /etc/kdump/kdump.new /etc/kdump/kdump
fi
@@ -274,8 +281,7 @@ fi
%triggerin -- kernel-kdump
-touch %{_sysconfdir}/kdump.conf
-
+touch %{kdumplibdir}/kdump.conf
%triggerpostun -- kernel kernel-xen kernel-debug kernel-PAE kernel-kdump
# List out the initrds here, strip out version nubmers
@@ -303,8 +309,6 @@ done
%ifarch %{ix86} x86_64 ppc64 s390x ppc64le
%{_sysconfdir}/makedumpfile.conf.sample
%endif
-%config(noreplace,missingok) %{_sysconfdir}/sysconfig/kdump
-%config(noreplace,missingok) %{_sysconfdir}/kdump.conf
%ifnarch s390x
%config %{_udevrulesdir}
%endif
diff --git a/live-image-kdump-howto.txt b/live-image-kdump-howto.txt
index e0bc9f1f7e1b..3e80be9e3a86 100644
--- a/live-image-kdump-howto.txt
+++ b/live-image-kdump-howto.txt
@@ -7,7 +7,7 @@ Since there isn't any config file that can be used to configure kernel
parameters for live images before booting them, we have to append 'crashkernel'
argument in boot menu every time we boot a live image.
-2. Change dump target in /etc/kdump.conf
+2. Change dump target in /etc/kdump/kdump.conf
When kdump kernel boots in a live environment, the default target /var/crash is
in RAM so you need to change the dump target to an external disk or a network
diff --git a/mkdumprd b/mkdumprd
index f30d9c27cb1b..9644d7a6bd77 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -11,7 +11,7 @@
. /lib/kdump/kdump-lib.sh
export IN_KDUMP=1
-conf_file="/etc/kdump.conf"
+conf_file="/etc/kdump/kdump.conf"
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2)
[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH
@@ -305,7 +305,7 @@ handle_default_dump_target()
get_default_action_target()
{
local _target
- local _action=$(grep "^default" /etc/kdump.conf 2>/dev/null | awk '{print $2}')
+ local _action=$(grep "^default" $conf_file 2>/dev/null | awk '{print $2}')
if [ -n "$_action" ] && [ "$_action" = "dump_to_rootfs" ]; then
#get rootfs device name
_target=$(findmnt -k -f -n -o SOURCE /)
diff --git a/mkdumprd.8 b/mkdumprd.8
index 7faae57ef128..c708f993819f 100644
--- a/mkdumprd.8
+++ b/mkdumprd.8
@@ -8,11 +8,11 @@ mkdumprd \- creates initial ramdisk images for kdump crash recovery
\fBmkdumprd\fR creates an initial ram file system for use in conjunction with
the booting of a kernel within the kdump framework for crash recovery.
\fBmkdumprds\fR purpose is to create an initial ram filesystem capable of copying
-the crashed systems vmcore image to a location specified in \fI/etc/kdump.conf
+the crashed systems vmcore image to a location specified in \fI/etc/kdump/kdump.conf
\fBmkdumprd\fR interrogates the running system to understand what modules need to
be loaded in the initramfs (based on configuration retrieved from
-\fI/etc/kdump.conf)\fR
+\fI/etc/kdump/kdump.conf)\fR
\fBmkdumprd\fR add a new \fBdracut\fR module 99kdumpbase and use \fBdracut\fR
utility to generate the initramfs.
--
2.7.4
6 years, 7 months
[PATCH v5] kdump: Introduce 'force_no_rebuild' option
by Bhupesh Sharma
This patch introduces the 'force_no_rebuild' option
inside the 'kdump.conf' and its handling inside the 'kdumpctl'
script.
There might be several use cases, where a system admin
decides that he doesn't need to rebuild the kdump initrd
and wants to use an existing version of the same. In such cases,
he can set the 'force_no_rebuild' option inside 'kdump.conf'
to 1, to force the 'kdumpctl' script not to rebuild the kdump
initrd.
Signed-off-by: Bhupesh Sharma <bhsharma(a)redhat.com>
---
kdump.conf | 8 ++++++++
kdump.conf.5 | 10 ++++++++++
kdumpctl | 22 +++++++++++++++++++++-
3 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/kdump.conf b/kdump.conf
index ebf9587a6522..1e24e1bd9d61 100644
--- a/kdump.conf
+++ b/kdump.conf
@@ -115,6 +115,13 @@
# Specify 1 to force rebuilding kdump initrd every time when kdump
# service starts.
#
+# force_no_rebuild <0 | 1>
+# - By default, kdump initrd will be rebuilt when necessary.
+# Specify 1 to bypass rebuilding of kdump initrd.
+#
+# force_no_rebuild and force_rebuild options are mutually
+# exclusive and they should not be set to 1 simultaneously.
+#
# override_resettable <0 | 1>
# - Usually an unresettable block device can't be a dump target.
# Specifying 1 when you want to dump even though the block
@@ -150,6 +157,7 @@ core_collector makedumpfile -l --message-level 1 -d 31
#extra_modules gfs2
#default shell
#force_rebuild 1
+#force_no_rebuild 1
#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"
#fence_kdump_args -p 7410 -f auto -c 0 -i 10
#fence_kdump_nodes node1 node2
diff --git a/kdump.conf.5 b/kdump.conf.5
index ca427699be53..b581964b906e 100644
--- a/kdump.conf.5
+++ b/kdump.conf.5
@@ -166,6 +166,16 @@ By default, kdump initrd will only be rebuilt when necessary.
Specify 1 to force rebuilding kdump initrd every time when kdump service starts.
.RE
+.B force_no_rebuild <0 | 1>
+.RS
+By default, kdump initrd will be rebuilt when necessary.
+Specify 1 to bypass rebuilding of kdump initrd.
+
+.PP
+force_no_rebuild and force_rebuild options are mutually exclusive and
+they should not be set to 1 simultaneously.
+.RE
+
.B override_resettable <0 | 1>
.RS
Usually an unresettable block device can't be a dump target. Specifying 1 means
diff --git a/kdumpctl b/kdumpctl
index 4d68be0c292d..4872adfc6be7 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -354,7 +354,7 @@ check_config()
case "$config_opt" in
\#* | "")
;;
- raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes)
+ raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes)
[ -z "$config_val" ] && {
echo "Invalid kdump config value for option $config_opt."
return 1;
@@ -609,6 +609,7 @@ check_rebuild()
{
local extra_modules
local _force_rebuild force_rebuild="0"
+ local _force_no_rebuild force_no_rebuild="0"
local ret system_modified="0"
check_boot_dir
@@ -625,6 +626,15 @@ check_rebuild()
return 1
fi
+ _force_no_rebuild=`grep ^force_no_rebuild $KDUMP_CONFIG_FILE 2>/dev/null`
+ if [ $? -eq 0 ]; then
+ force_no_rebuild=`echo $_force_no_rebuild | cut -d' ' -f2`
+ if [ "$force_no_rebuild" != "0" ] && [ "$force_no_rebuild" != "1" ];then
+ echo "Error: force_no_rebuild value is invalid"
+ return 1
+ fi
+ fi
+
_force_rebuild=`grep ^force_rebuild $KDUMP_CONFIG_FILE 2>/dev/null`
if [ $? -eq 0 ]; then
force_rebuild=`echo $_force_rebuild | cut -d' ' -f2`
@@ -634,6 +644,16 @@ check_rebuild()
fi
fi
+ if [[ "$force_no_rebuild" == "1" && "$force_rebuild" == "1" ]]; then
+ echo "Error: force_rebuild and force_no_rebuild are enabled simultaneously in kdump.conf"
+ return 1
+ fi
+
+ # Will not rebuild kdump initrd
+ if [ "$force_no_rebuild" == "1" ]; then
+ return 0
+ fi
+
#will rebuild every time if extra_modules are specified
extra_modules=`grep ^extra_modules $KDUMP_CONFIG_FILE`
[ -n "$extra_modules" ] && force_rebuild="1"
--
2.7.4
6 years, 8 months
Improving kdump/kexec documentation
by Bhupesh Sharma
Hi,
Presently it seems that the kdump/kexec documentation is scattered
over several files which is not very intuitive for a user/system admin
installing the kexec-tools rpm on his system.
We have presently the following documentation helpers. I propose to
make the following changes to the overall documentation:
1. kexec-kdump-howto.txt and fadump-howto.txt:
Background:
----------------
Contains very descriptive information about kdump and kexec, but is
normally not the first place where a user/system admin looks for
information when he installs the kexec-tools.
Proposal:
------------
To deprecate these howto and move the information from here to
respective man pages for kdump, kexec, kdumpctl and kdump.conf
This will avoid duplication of similar information and also ensure
that the user/system admin has the right man pages at his disposal.
2. man page for kdump / kdump service:
Background:
----------------
One doesn't exist yet for kdump service. The existing one is a placeholder only.
Proposal:
------------
Add a proper man page for kdump (one lines of the man page for dracut)
which links properly to man pages for kdumpctl and kdump.conf (again
see man page for dracut.conf for details).
Move the relevant kdump information from kexec-kdump-howto.txt and
fadump-howto.txt to here.
3. man page for kexec:
Background:
----------------
Descriptive man page exists.
Proposal:
------------
Move the relevant kexec information from kexec-kdump-howto.txt and
fadump-howto.txt to here.
4. man page for kdumpctl:
Background:
----------------
Descriptive man page exists.
Proposal:
------------
Link this to man page of kdump or kdump services.
Please share your views and add any missing bits.
Regards,
Bhupesh
6 years, 8 months
[PATCH v4] kdump: Introduce 'force_no_rebuild' option
by Bhupesh Sharma
This patch introduces the 'force_no_rebuild' option
inside the 'kdump.conf' and its handling inside the 'kdumpctl'
script.
There might be several use cases, where a system admin
decides that he doesn't need to rebuild the kdump initrd
and wants to use an existing version of the same. In such cases,
he can set the 'force_no_rebuild' option inside 'kdump.conf'
to 1, to force the 'kdumpctl' script not to rebuild the kdump
initrd.
Signed-off-by: Bhupesh Sharma <bhsharma(a)redhat.com>
---
kdump.conf | 8 ++++++++
kdump.conf.5 | 10 ++++++++++
kdumpctl | 22 +++++++++++++++++++++-
3 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/kdump.conf b/kdump.conf
index ebf9587a6522..1e24e1bd9d61 100644
--- a/kdump.conf
+++ b/kdump.conf
@@ -115,6 +115,13 @@
# Specify 1 to force rebuilding kdump initrd every time when kdump
# service starts.
#
+# force_no_rebuild <0 | 1>
+# - By default, kdump initrd will be rebuilt when necessary.
+# Specify 1 to bypass rebuilding of kdump initrd.
+#
+# force_no_rebuild and force_rebuild options are mutually
+# exclusive and they should not be set to 1 simultaneously.
+#
# override_resettable <0 | 1>
# - Usually an unresettable block device can't be a dump target.
# Specifying 1 when you want to dump even though the block
@@ -150,6 +157,7 @@ core_collector makedumpfile -l --message-level 1 -d 31
#extra_modules gfs2
#default shell
#force_rebuild 1
+#force_no_rebuild 1
#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"
#fence_kdump_args -p 7410 -f auto -c 0 -i 10
#fence_kdump_nodes node1 node2
diff --git a/kdump.conf.5 b/kdump.conf.5
index ca427699be53..b581964b906e 100644
--- a/kdump.conf.5
+++ b/kdump.conf.5
@@ -166,6 +166,16 @@ By default, kdump initrd will only be rebuilt when necessary.
Specify 1 to force rebuilding kdump initrd every time when kdump service starts.
.RE
+.B force_no_rebuild <0 | 1>
+.RS
+By default, kdump initrd will be rebuilt when necessary.
+Specify 1 to bypass rebuilding of kdump initrd.
+
+.PP
+force_no_rebuild and force_rebuild options are mutually exclusive and
+they should not be set to 1 simultaneously.
+.RE
+
.B override_resettable <0 | 1>
.RS
Usually an unresettable block device can't be a dump target. Specifying 1 means
diff --git a/kdumpctl b/kdumpctl
index 4d68be0c292d..3b85c0611d84 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -354,7 +354,7 @@ check_config()
case "$config_opt" in
\#* | "")
;;
- raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes)
+ raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes)
[ -z "$config_val" ] && {
echo "Invalid kdump config value for option $config_opt."
return 1;
@@ -609,6 +609,7 @@ check_rebuild()
{
local extra_modules
local _force_rebuild force_rebuild="0"
+ local _force_no_rebuild force_no_rebuild="0"
local ret system_modified="0"
check_boot_dir
@@ -625,6 +626,15 @@ check_rebuild()
return 1
fi
+ _force_no_rebuild=`grep ^force_no_rebuild $KDUMP_CONFIG_FILE 2>/dev/null`
+ if [ $? -eq 0 ]; then
+ force_no_rebuild=`echo $_force_no_rebuild | cut -d' ' -f2`
+ if [ "$force_no_rebuild" != "0" ] && [ "$force_no_rebuild" != "1" ];then
+ echo "Error: force_no_rebuild value is invalid"
+ return 1
+ fi
+ fi
+
_force_rebuild=`grep ^force_rebuild $KDUMP_CONFIG_FILE 2>/dev/null`
if [ $? -eq 0 ]; then
force_rebuild=`echo $_force_rebuild | cut -d' ' -f2`
@@ -634,6 +644,16 @@ check_rebuild()
fi
fi
+ if [[ "$force_no_rebuild" == "1" && "$force_rebuild" == "1" ]]; then
+ echo "Error: force_rebuild and force_no_rebuild are enabled simultaneously in kdump.conf"
+ exit 1
+ fi
+
+ # Will not rebuild kdump initrd
+ if [ "$force_no_rebuild" == "1" ]; then
+ return 0
+ fi
+
#will rebuild every time if extra_modules are specified
extra_modules=`grep ^extra_modules $KDUMP_CONFIG_FILE`
[ -n "$extra_modules" ] && force_rebuild="1"
--
2.7.4
6 years, 8 months
[PATCH] kdumpctl: fix status check when CONFIG_CRASH_DUMP is not enabled in kernel
by Pratyush Anand
When kexec_crash_loaded does not exist, means kdump was not enabled in
kernel we get
$ kdumpctl status
cat: /sys/kernel/kexec_crash_loaded: No such file or directory
/usr/bin/kdumpctl: line 879: [: ==: unary operator expected
Kdump is not operational
After this patch:
$ kdumpctl status
Perhaps CONFIG_CRASH_DUMP is not enabled in kernel
Kdump is not operational
Signed-off-by: Pratyush Anand <panand(a)redhat.com>
---
kdumpctl | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kdumpctl b/kdumpctl
index 4d68be0c292d..9afce8f4f2f2 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -876,6 +876,11 @@ check_current_fadump_status()
check_current_kdump_status()
{
+ if [ ! -f /sys/kernel/kexec_crash_loaded ];then
+ echo "Perhaps CONFIG_CRASH_DUMP is not enabled in kernel"
+ return 1
+ fi
+
rc=`cat /sys/kernel/kexec_crash_loaded`
if [ $rc == 1 ]; then
return 0
--
2.9.3
6 years, 8 months