Question: is there any automated way of building rpm package?
by HATAYAMA Daisuke
Hello,
Is there any automated way of building rpm package?
That is, installing files such eppic, kexec-tools-po, makedumpfile and kexec-tools with expected file names necessary for installation, place them proper file path location and then execute rpmbuild command.
I first found out there's no Makefile and INSTALL file, and then I tried preparing them manually in an ad-hoc way, but faced build failure several times and gave up.
--
Thanks.
HATAYAMA, Daisuke
8 years, 6 months
[PATCH v2 1/3] cleanup: extract functions from kdump.sh to kdump-lib-initramfs.sh
by WANG Chao
Extract functions from kdump.sh, and construct kdump-lib-initramfs.sh as
kdump common functions/varaibles library.
kdump-lib-initramfs.sh will include kdump-lib.sh, because it will use
the functions from there. IOW, kdump-lib-initramfs.sh will be a superset
of kdump-lib.sh
So after this cleanup:
- scripts running in 1st kernel only have to include kdump-lib.sh
- scripts running in 2nd kernel only have to include kdump-lib-initramfs.sh
Signed-off-by: WANG Chao <chaowang(a)redhat.com>
---
dracut-kdump.sh | 150 ++----------------------------------------------
dracut-module-setup.sh | 1 +
kdump-lib-initramfs.sh | 151 +++++++++++++++++++++++++++++++++++++++++++++++++
kexec-tools.spec | 2 +
4 files changed, 159 insertions(+), 145 deletions(-)
create mode 100755 kdump-lib-initramfs.sh
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index e6faf9c..a2bfa05 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -7,30 +7,14 @@ fi
exec &> /dev/console
. /lib/dracut-lib.sh
-. /lib/kdump-lib.sh
+. /lib/kdump-lib-initramfs.sh
if [ -f "$initdir/lib/dracut/no-emergency-shell" ]; then
rm -f -- $initdir/lib/dracut/no-emergency-shell
fi
set -o pipefail
-KDUMP_PATH="/var/crash"
-CORE_COLLECTOR=""
-DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31"
-DMESG_COLLECTOR="/sbin/vmcore-dmesg"
-DEFAULT_ACTION="reboot -f"
-DATEDIR=`date +%Y.%m.%d-%T`
-HOST_IP='127.0.0.1'
-DUMP_INSTRUCTION=""
-SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
-KDUMP_SCRIPT_DIR="/kdumpscripts"
-DD_BLKSIZE=512
-FINAL_ACTION="reboot -f"
DUMP_RETVAL=0
-conf_file="/etc/kdump.conf"
-KDUMP_PRE=""
-KDUMP_POST=""
-MOUNTS=""
export PATH=$PATH:$KDUMP_SCRIPT_DIR
@@ -48,27 +32,6 @@ do_dump()
return $_ret
}
-do_umount()
-{
- if [ -n "$MOUNTS" ]; then
- for mount in $MOUNTS; do
- ismounted $mount && umount -R $mount
- done
- fi
-}
-
-do_final_action()
-{
- do_umount
- eval $FINAL_ACTION
-}
-
-do_default_action()
-{
- wait_for_loginit
- eval $DEFAULT_ACTION
-}
-
do_kdump_pre()
{
if [ -n "$KDUMP_PRE" ]; then
@@ -88,39 +51,6 @@ add_dump_code()
DUMP_INSTRUCTION=$1
}
-# dump_fs <mount point| device>
-dump_fs()
-{
- local _dev=$(findmnt -k -f -n -r -o SOURCE $1)
- local _mp=$(findmnt -k -f -n -r -o TARGET $1)
-
- echo "kdump: dump target is $_dev"
-
- if [ -z "$_mp" ]; then
- echo "kdump: error: Dump target $_dev is not mounted."
- return 1
- fi
- MOUNTS="$MOUNTS $_mp"
-
- # 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/"
-
- mount -o remount,rw $_mp || return 1
- mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1
-
- save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
-
- 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
- sync
-
- echo "kdump: saving vmcore complete"
- return 0
-}
-
dump_raw()
{
local _raw=$1
@@ -170,26 +100,6 @@ dump_ssh()
return 0
}
-save_vmcore_dmesg_fs() {
- local _dmesg_collector=$1
- local _path=$2
-
- echo "kdump: saving vmcore-dmesg.txt"
- $_dmesg_collector /proc/vmcore > ${_path}/vmcore-dmesg-incomplete.txt
- _exitcode=$?
- if [ $_exitcode -eq 0 ]; then
- mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt
-
- # Make sure file is on disk. There have been instances where later
- # saving vmcore failed and system rebooted without sync and there
- # was no vmcore-dmesg.txt available.
- sync
- echo "kdump: saving vmcore-dmesg.txt complete"
- else
- echo "kdump: saving vmcore-dmesg.txt failed"
- fi
-}
-
save_vmcore_dmesg_ssh() {
local _dmesg_collector=$1
local _path=$2
@@ -208,7 +118,6 @@ save_vmcore_dmesg_ssh() {
fi
}
-
get_host_ip()
{
local _host
@@ -228,61 +137,12 @@ get_host_ip()
read_kdump_conf()
{
- if [ ! -f "$conf_file" ]; then
- echo "kdump: $conf_file not found"
+ if [ ! -f "$KDUMP_CONF" ]; then
+ echo "kdump: $KDUMP_CONF not found"
return
fi
- # first get the necessary variables
- while read config_opt config_val;
- do
- # remove inline comments after the end of a directive.
- config_val=$(strip_comments $config_val)
- case "$config_opt" in
- path)
- KDUMP_PATH="$config_val"
- ;;
- core_collector)
- [ -n "$config_val" ] && CORE_COLLECTOR="$config_val"
- ;;
- sshkey)
- if [ -f "$config_val" ]; then
- SSH_KEY_LOCATION=$config_val
- fi
- ;;
- kdump_pre)
- KDUMP_PRE="$config_val"
- ;;
- kdump_post)
- KDUMP_POST="$config_val"
- ;;
- fence_kdump_args)
- FENCE_KDUMP_ARGS="$config_val"
- ;;
- fence_kdump_nodes)
- FENCE_KDUMP_NODES="$config_val"
- ;;
- default)
- case $config_val in
- shell)
- DEFAULT_ACTION="_emergency_shell kdump"
- ;;
- reboot)
- DEFAULT_ACTION="do_umount; reboot -f"
- ;;
- halt)
- DEFAULT_ACTION="do_umount; halt -f"
- ;;
- poweroff)
- DEFAULT_ACTION="do_umount; poweroff -f"
- ;;
- dump_to_rootfs)
- DEFAULT_ACTION="dump_fs $NEWROOT"
- ;;
- esac
- ;;
- esac
- done < $conf_file
+ get_kdump_confs
# rescan for add code for dump target
while read config_opt config_val;
@@ -300,7 +160,7 @@ read_kdump_conf()
add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val"
;;
esac
- done < $conf_file
+ done < $KDUMP_CONF
}
fence_kdump_notify()
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 5ab2997..758420b 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -580,6 +580,7 @@ install() {
inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
inst_hook pre-pivot 9999 "$moddir/kdump.sh"
inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
+ inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh"
# Check for all the devices and if any device is iscsi, bring up iscsi
# target. Ideally all this should be pushed into dracut iscsi module
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
new file mode 100755
index 0000000..d16bcf4
--- /dev/null
+++ b/kdump-lib-initramfs.sh
@@ -0,0 +1,151 @@
+# These variables and functions are useful in 2nd kernel
+
+. /lib/dracut-lib.sh
+. /lib/kdump-lib.sh
+
+KDUMP_PATH="/var/crash"
+CORE_COLLECTOR=""
+DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31"
+DMESG_COLLECTOR="/sbin/vmcore-dmesg"
+DEFAULT_ACTION="reboot -f"
+DATEDIR=`date +%Y.%m.%d-%T`
+HOST_IP='127.0.0.1'
+DUMP_INSTRUCTION=""
+SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
+KDUMP_SCRIPT_DIR="/kdumpscripts"
+DD_BLKSIZE=512
+FINAL_ACTION="reboot -f"
+KDUMP_CONF="/etc/kdump.conf"
+KDUMP_PRE=""
+KDUMP_POST=""
+NEWROOT="/sysroot"
+MOUNTS=""
+
+get_kdump_confs()
+{
+ local config_opt config_val
+
+ while read config_opt config_val;
+ do
+ # remove inline comments after the end of a directive.
+ config_val=$(strip_comments $config_val)
+ case "$config_opt" in
+ path)
+ KDUMP_PATH="$config_val"
+ ;;
+ core_collector)
+ [ -n "$config_val" ] && CORE_COLLECTOR="$config_val"
+ ;;
+ sshkey)
+ if [ -f "$config_val" ]; then
+ SSH_KEY_LOCATION=$config_val
+ fi
+ ;;
+ kdump_pre)
+ KDUMP_PRE="$config_val"
+ ;;
+ kdump_post)
+ KDUMP_POST="$config_val"
+ ;;
+ fence_kdump_args)
+ FENCE_KDUMP_ARGS="$config_val"
+ ;;
+ fence_kdump_nodes)
+ FENCE_KDUMP_NODES="$config_val"
+ ;;
+ default)
+ case $config_val in
+ shell)
+ DEFAULT_ACTION="_emergency_shell kdump"
+ ;;
+ reboot)
+ DEFAULT_ACTION="do_umount; reboot -f"
+ ;;
+ halt)
+ DEFAULT_ACTION="do_umount; halt -f"
+ ;;
+ poweroff)
+ DEFAULT_ACTION="do_umount; poweroff -f"
+ ;;
+ dump_to_rootfs)
+ DEFAULT_ACTION="dump_fs $NEWROOT"
+ ;;
+ esac
+ ;;
+ esac
+ done < $KDUMP_CONF
+}
+
+# dump_fs <mount point| device>
+dump_fs()
+{
+
+ local _dev=$(findmnt -k -f -n -r -o SOURCE $1)
+ local _mp=$(findmnt -k -f -n -r -o TARGET $1)
+
+ echo "kdump: dump target is $_dev"
+
+ if [ -z "$_mp" ]; then
+ echo "kdump: error: Dump target $_dev is not mounted."
+ return 1
+ fi
+ MOUNTS="$MOUNTS $_mp"
+
+ # 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/"
+
+ mount -o remount,rw $_mp || return 1
+ mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1
+
+ save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
+
+ 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
+ sync
+
+ echo "kdump: saving vmcore complete"
+}
+
+save_vmcore_dmesg_fs() {
+ local _dmesg_collector=$1
+ local _path=$2
+
+ echo "kdump: saving vmcore-dmesg.txt"
+ $_dmesg_collector /proc/vmcore > ${_path}/vmcore-dmesg-incomplete.txt
+ _exitcode=$?
+ if [ $_exitcode -eq 0 ]; then
+ mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt
+
+ # Make sure file is on disk. There have been instances where later
+ # saving vmcore failed and system rebooted without sync and there
+ # was no vmcore-dmesg.txt available.
+ sync
+ echo "kdump: saving vmcore-dmesg.txt complete"
+ else
+ echo "kdump: saving vmcore-dmesg.txt failed"
+ fi
+}
+
+do_umount()
+{
+ if [ -n "$MOUNTS" ]; then
+ for mount in $MOUNTS; do
+ ismounted $mount && umount -R $mount
+ done
+ fi
+}
+
+do_default_action()
+{
+ wait_for_loginit
+ eval $DEFAULT_ACTION
+}
+
+do_final_action()
+{
+ do_umount
+ eval $FINAL_ACTION
+}
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 6581277..b55a7f1 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -27,6 +27,7 @@ Source20: kdump-lib.sh
Source21: kdump-in-cluster-environment.txt
Source22: kdump-dep-generator.sh
Source23: kdump-anaconda-addon-001-4-g03898ef.tar.gz
+Source24: kdump-lib-initramfs.sh
#######################################
# These are sources for mkdumpramfs
@@ -178,6 +179,7 @@ install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8
install -m 755 %{SOURCE11} $RPM_BUILD_ROOT%{_datadir}/kdump/firstboot_kdump.py
install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.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
%ifnarch s390x
# For s390x the ELF header is created in the kdump kernel and therefore kexec
# udev rules are not required
--
1.9.3
9 years, 4 months
[PATCH v6 0/2] Kdump error handling service
by WANG Chao
Hi, All
Now upon failure kdump script might not be called at all and it might
not be able to execute default action. It results in a hang.
Because we disable emergency shell and rely on kdump.sh being invoked
through dracut-pre-pivot hook. But it might happen that we never call
into dracut-pre-pivot hook because certain systemd targets could not
reach due to failure in their dependencies. In those cases error
handling code does not run and system hangs.
To solve this problem, we need to separate the error handling code from
dracut-pre-pivot hook, and every time when a failure shows up, the
separated code can be called by the emergency service.
By default systemd provides an emergency service which will drop us into
shell every time upon a critical failure. It's very convenient for us to
re-use the framework of systemd emergency, because we don't have to
touch the other parts of systemd. We can use our own script instead of
the default one.
This new scheme will overwrite emergency shell and replace with kdump
error handling code. And this code will do the error handling as needed.
Now, we will not rely on dracut-pre-pivot hook running always. Instead
whenever error happens and it is serious enough that emergency shell
needed to run, now kdump error handler will run.
This patchset introduce a new kdump emergency service. It will override the
existing emergency.service. When fatal error occurs, this emergency service
will be triggered and systemd will isolate to emergency path.
This kdump emergency service can will read kdump.conf and act according to the
configired "default action" (reboot/poweroff/halt/shell/dump_to_rootfs).
Along with this patchset, kdump-capture.service is introduced as a service unit
to run kdump.sh. When kdump-capture.service fails, systemd will isolate to
kdump emergency service. I copied all the dependencies from
dracut-pre-pivot.service to kdump-capture.service so that kdump.sh will be
called at the correct time window.
v2:
Address several comments from Vivek:
- split [patch 1] into 1/6 and 2/6
- remove several unnecessary lines in service unit.
- modify the description of kdump-capture.service
- introduce another kdump lib kdump-lib-2.sh used in 2nd kernel.
V3:
Address several comments from Vivek:
- update description of [PATCH 1/5] and [PATCH 5/5]
- separate the patch of cleanup to kdump-lib-initramfs.sh
V4:
Address several comments from Vivek and Dave:
- meld the original [PATCH 3/5] into [PATCH 1/5]
- add GPL license for kdump-error-handler.service and kdump-capture.service
- separate the "x-initrd.mount" and "mount under /sysroot" patch to another
patchset
V5:
- Rebase on top of the fadump patchset.
- Enable dracut-emergency again, but override it with kdump error handler.
V6:
- reboot if entering error handler in error handling path
- add comments in dracut-kdump-emergency.service
- update changelog
WANG Chao (2):
Introduce kdump error handling service
Introduce kdump capture service
dracut-kdump-capture.service | 30 ++++++++++++++++++++++++++++++
dracut-kdump-emergency.service | 34 ++++++++++++++++++++++++++++++++++
dracut-kdump-error-handler.sh | 18 ++++++++++++++++++
dracut-kdump.sh | 9 ++-------
dracut-module-setup.sh | 10 ++++++++--
kdump-lib-initramfs.sh | 34 ++++++++++++++++++++++++++++++----
kexec-tools.spec | 7 ++++++-
7 files changed, 128 insertions(+), 14 deletions(-)
create mode 100644 dracut-kdump-capture.service
create mode 100644 dracut-kdump-emergency.service
create mode 100755 dracut-kdump-error-handler.sh
--
1.9.3
9 years, 4 months
[Patch v4] Add static route into cmdline if target address is not local
by Baoquan He
If one target address is not local and its route is different than
default gateway, the specific route to this target address need be
added. E.g, target is 192.168.200.222.
sh> ip route show
default via 192.168.122.1 dev eth0 proto static metric 1024
192.168.200.0/24 via 192.168.100.222 dev ens10 proto static metric 1
In this patch, get the route to the specific target address and store
it as cmdline, here is /etc/cmdline.d/45-route-static.conf. And the
route options are separated by underscore like below. Then the sotred
route can be parsed when kdump kernel boot up.
192.168.200.0/24:192.168.100.222:ens10
---
dracut-module-setup.sh | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 5ab2997..fefbe4b 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -79,6 +79,11 @@ kdump_static_ip() {
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
fi
+
+ /sbin/ip route show | grep -v default | grep "^[[:digit:]].*via.* $_netdev " |\
+ while read line; do
+ echo $line | awk '{printf("rd.route=%s:%s:%s\n", $1, $3, $5)}'
+ done >> ${initdir}/etc/cmdline.d/45route-static.conf
}
kdump_get_mac_addr() {
--
1.9.0
9 years, 4 months
[PATCH v5 0/2] Kdump error handling service
by WANG Chao
Hi, All
Now upon failure kdump script might not be called at all and it might
not be able to execute default action. It results in a hang.
Because we disable emergency shell and rely on kdump.sh being invoked
through dracut-pre-pivot hook. But it might happen that we never call
into dracut-pre-pivot hook because certain systemd targets could not
reach due to failure in their dependencies. In those cases error
handling code does not run and system hangs.
To solve this problem, we need to separate the error handling code from
dracut-pre-pivot hook, and every time when a failure shows up, the
separated code can be called by the emergency service.
By default systemd provides an emergency service which will drop us into
shell every time upon a critical failure. It's very convenient for us to
re-use the framework of systemd emergency, because we don't have to
touch the other parts of systemd. We can use our own script instead of
the default one.
This new scheme will overwrite emergency shell and replace with kdump
error handling code. And this code will do the error handling as needed.
Now, we will not rely on dracut-pre-pivot hook running always. Instead
whenever error happens and it is serious enough that emergency shell
needed to run, now kdump error handler will run.
This patchset introduce a new kdump emergency service. It will override the
existing emergency.service. When fatal error occurs, this emergency service
will be triggered and systemd will isolate to emergency path.
This kdump emergency service can will read kdump.conf and act according to the
configired "default action" (reboot/poweroff/halt/shell/dump_to_rootfs).
Along with this patchset, kdump-capture.service is introduced as a service unit
to run kdump.sh. When kdump-capture.service fails, systemd will isolate to
kdump emergency service. I copied all the dependencies from
dracut-pre-pivot.service to kdump-capture.service so that kdump.sh will be
called at the correct time window.
v2:
Address several comments from Vivek:
- split [patch 1] into 1/6 and 2/6
- remove several unnecessary lines in service unit.
- modify the description of kdump-capture.service
- introduce another kdump lib kdump-lib-2.sh used in 2nd kernel.
V3:
Address several comments from Vivek:
- update description of [PATCH 1/5] and [PATCH 5/5]
- separate the patch of cleanup to kdump-lib-initramfs.sh
V4:
Address several comments from Vivek and Dave:
- meld the original [PATCH 3/5] into [PATCH 1/5]
- add GPL license for kdump-error-handler.service and kdump-capture.service
- separate the "x-initrd.mount" and "mount under /sysroot" patch to another
patchset
V5:
- Rebase on top of the fadump patchset.
- Enable dracut-emergency again, but override it with kdump error handler.
WANG Chao (2):
Introduce kdump error handling service
Introduce kdump capture service
dracut-kdump-capture.service | 30 ++++++++++++++++++++++++++++++
dracut-kdump-emergency.service | 30 ++++++++++++++++++++++++++++++
dracut-kdump-error-handler.sh | 10 ++++++++++
dracut-kdump.sh | 9 ++-------
dracut-module-setup.sh | 10 ++++++++--
kdump-lib-initramfs.sh | 34 ++++++++++++++++++++++++++++++----
kexec-tools.spec | 7 ++++++-
7 files changed, 116 insertions(+), 14 deletions(-)
create mode 100644 dracut-kdump-capture.service
create mode 100644 dracut-kdump-emergency.service
create mode 100755 dracut-kdump-error-handler.sh
--
1.9.3
9 years, 4 months
[PATCH v7] Enhance kdump to support ipv6
by Arthur Zou
Resolves: bz821620
Description:
Currently kdump doesn't support ipv6 nfs/ssh dump. Ipv6 is the latest version
of the Internet Protocal. so it is a significant feture for kdump to enhance
to support ipv6.
Solutions:
Since dracut has supported ipv6 now, it is easy to change the kdump code to
support ipv6. Just need pass the right _ip_opts to the second kernle. What is
the main difference in userspace bettwen ipv4 and ipv6 is the ip address format.
For ipv6 nfs dump:
if ipv6 address type is link scope, /etc/kdump.conf should be edited like
"nfs [fe80::5054:ff:fe48:ca80%eth0]:/mnt"
else /etc/kdump.conf should be edited like "nfs [2001:db8:0:f101::2]:/mnt"
For ipv6 ssh dump
if ipv6 address type is link scope, /etc/kdump.conf should be edited like
"ssh root@fe80::5054:ff:fe48:ca80%eth0"
else /etc/kdump.conf should be edited like "ssh root@2001:db8:0:f101::2"
What this patch do is:
a): Add a function is_ipv6_target to tell what version of Internet Protocal
(ipv4/ipv6) kdump will use to dump to remote target.
b): Modify kdump_install_net to handle ipv6 configuration in /etc/kdump.conf
correctly. Get the ipv6 address from /etc/kdump.conf is more complicated
than ipv4 because the difference configuration format mentioned above.
c): Based on the ip address type, using corresponding ip address as HOST_IP
in second kernel.
It was tested for IPV6 and IPV4 address in beaker machine and passed.
Note:
1): Currntly only f19 support remount a nfs target in ipv6. detail in https:
//bugzilla.redhat.com/show_bug.cgi?id=1099761. If using in f20, you can
comment out "mount -o remount,rw $_mp || return 1" in kdump.sh line 105.
2): If Using static ipv6 address and configuring nfs/ssh with hostname of
remote target, MUST add a ipv6 DNS in ifcfg-devname.
How to create a ipv6 enviromnet.
1): Reserving two beaker machine with family fedora19.
2): Choosing a beaker machine as a nfs/ssh server and delete it's ipv4 address
by "ip address del ipv4-address dev nicname"
3): Configuring the /etc/kdump.conf like mentioned above.
Signed-off-by: Arthur Zou <zzou(a)redhat.com>
---
dracut-kdump.sh | 8 ++++--
dracut-module-setup.sh | 67 ++++++++++++++++++++++++++++++++++++--------------
kdump-lib.sh | 33 +++++++++++++++++++++++++
3 files changed, 88 insertions(+), 20 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index cb13d92..9e838eb 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -206,9 +206,13 @@ get_host_ip()
then
kdumpnic=$(getarg kdumpnic=)
[ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1
- _host=`ip addr show dev $kdumpnic|grep 'inet '`
+ if is_ipv6_target; then
+ _host=`ip addr show dev $kdumpnic|grep 'inet6'`
+ else
+ _host=`ip addr show dev $kdumpnic|grep 'inet '`
+ fi
[ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1
- _host="${_host##*inet }"
+ _host=`echo $_host | cut -d' ' -f2`
_host="${_host%%/*}"
[ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1
HOST_IP=$_host
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 87ad072..93e8ca2 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -70,14 +70,24 @@ kdump_setup_dns() {
#$2: srcaddr
#if it use static ip echo it, or echo null
kdump_static_ip() {
- local _netmask _gateway
+ local _netmask _gateway _ipaddr
local _netdev="$1" _srcaddr="$2"
- local _ipaddr=$(ip addr show dev $_netdev permanent | \
+
+ if is_ipv6_target; then
+ _ipaddr=$(ip addr show dev $_netdev permanent | \
+ awk "/ $_srcaddr\/.* /{print \$2}")
+ if [ -n "$_ipaddr" ]; then
+ _gateway=$(ip -6 route list dev $_netdev | awk '/^default /{print $3}')
+ echo -n "[${_srcaddr}]::[${_gateway}]:64::"
+ fi
+ else
+ _ipaddr=$(ip addr show dev $_netdev permanent | \
awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
- if [ -n "$_ipaddr" ]; then
- _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
- _gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
- echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
+ if [ -n "$_ipaddr" ]; then
+ _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
+ _gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
+ echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
+ fi
fi
}
@@ -231,24 +241,43 @@ kdump_install_net() {
local _server _netdev _srcaddr
local config_val="$1"
- _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
+ _server=`get_remote_host $config_val`
- _need_dns=`echo $_server|grep "[a-zA-Z]"`
- [ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
+ if is_ipv6_target; then
+ _need_dns=`echo $_server|grep "[:]"`
+ [ -z "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
+ else
+ _need_dns=`echo $_server|grep "[a-zA-Z]"`
+ [ -n "$_need_dns" ] && _server=`getent hosts $_server| head -n 1 | cut -d' ' -f1`
+ fi
_netdev=`/sbin/ip route get to $_server 2>&1`
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
- #the field in the ip output changes if we go to another subnet
- if [ -n "`echo $_netdev | grep via`" ]
- then
- # we are going to a different subnet
- _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
- _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
+ if is_ipv6_target; then
+ #the field in the ip output changes if we go to another subnet
+ if [ -n "`echo $_netdev | grep via`" ]
+ then
+ # we are going to a different subnet
+ _srcaddr=`echo $_netdev|awk '{print $9}'|head -n 1`
+ _netdev=`echo $_netdev|awk '{print $7;}'|head -n 1`
+ else
+ # we are on the same subnet
+ _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
+ _netdev=`echo $_netdev|awk '{print $5}'|head -n 1`
+ fi
else
- # we are on the same subnet
- _srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
- _netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
+ #the field in the ip output changes if we go to another subnet
+ if [ -n "`echo $_netdev | grep via`" ]
+ then
+ # we are going to a different subnet
+ _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
+ _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
+ else
+ # we are on the same subnet
+ _srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
+ _netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
+ fi
fi
kdump_setup_netdev "${_netdev}" "${_srcaddr}"
@@ -551,6 +580,8 @@ install() {
inst "/bin/date" "/bin/date"
inst "/bin/sync" "/bin/sync"
inst "/bin/cut" "/bin/cut"
+ inst "/bin/getent" "/bin/getent"
+ inst "/bin/head" "/bin/head"
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
inst_hook pre-pivot 9999 "$moddir/kdump.sh"
diff --git a/kdump-lib.sh b/kdump-lib.sh
index a20c6e8..3ed09b4 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -138,3 +138,36 @@ check_save_path_fs()
fi
}
+# get ip address or hostname from nfs/ssh config value
+get_remote_host()
+{
+ local _config_val=$1
+
+ # in ipv6, the _config_val format is [xxxx:xxxx::xxxx%eth0]:/mnt/nfs or
+ # username@xxxx:xxxx::xxxx%eth0. what we need is just xxxx:xxxx::xxxx
+ _config_val=${_config_val#*@}
+ _config_val=${_config_val%:/*}
+ _config_val=${_config_val#[}
+ _config_val=${_config_val%]}
+ _config_val=${_config_val%\%*}
+ echo $_config_val
+}
+
+# check the remote server ip address tpye
+is_ipv6_target()
+{
+ local _server _server_tmp
+
+ if is_ssh_dump_target; then
+ _server=`get_option_value ssh`
+ elif is_nfs_dump_target; then
+ _server=`get_option_value nfs`
+ fi
+
+ [ -z "$_server" ] && return 1
+ _server=`get_remote_host $_server`
+ _server_tmp=$_server
+ _server=`getent hosts $_server | head -n 1 | cut -d' ' -f1`
+ _server=${_server:-$_server_tmp}
+ echo $_server | grep -q ":"
+}
--
1.8.4.2
9 years, 4 months
[PATCH 1/3] cleanup: extract functions from kdump.sh to kdump-lib-initramfs.sh
by WANG Chao
Extract functions from kdump.sh, and construct kdump-lib-initramfs.sh as
kdump common functions/varaibles library.
kdump-lib-initramfs.sh will include kdump-lib.sh, because it will use
the functions from there. IOW, kdump-lib-initramfs.sh will be a superset
of kdump-lib.sh
So after this cleanup:
- scripts running in 1st kernel only have to include kdump-lib.sh
- scripts running in 2nd kernel only have to include kdump-lib-initramfs.sh
Signed-off-by: WANG Chao <chaowang(a)redhat.com>
---
dracut-kdump.sh | 145 ++----------------------------------------------
dracut-module-setup.sh | 1 +
kdump-lib-initramfs.sh | 146 +++++++++++++++++++++++++++++++++++++++++++++++++
kexec-tools.spec | 2 +
4 files changed, 154 insertions(+), 140 deletions(-)
create mode 100755 kdump-lib-initramfs.sh
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index cb13d92..08f4322 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -2,30 +2,14 @@
exec &> /dev/console
. /lib/dracut-lib.sh
-. /lib/kdump-lib.sh
+. /lib/kdump-lib-initramfs.sh
if [ -f "$initdir/lib/dracut/no-emergency-shell" ]; then
rm -f -- $initdir/lib/dracut/no-emergency-shell
fi
set -o pipefail
-KDUMP_PATH="/var/crash"
-CORE_COLLECTOR=""
-DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31"
-DMESG_COLLECTOR="/sbin/vmcore-dmesg"
-DEFAULT_ACTION="reboot -f"
-DATEDIR=`date +%Y.%m.%d-%T`
-HOST_IP='127.0.0.1'
-DUMP_INSTRUCTION=""
-SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
-KDUMP_SCRIPT_DIR="/kdumpscripts"
-DD_BLKSIZE=512
-FINAL_ACTION="reboot -f"
DUMP_RETVAL=0
-conf_file="/etc/kdump.conf"
-KDUMP_PRE=""
-KDUMP_POST=""
-MOUNTS=""
export PATH=$PATH:$KDUMP_SCRIPT_DIR
@@ -43,27 +27,6 @@ do_dump()
return $_ret
}
-do_umount()
-{
- if [ -n "$MOUNTS" ]; then
- for mount in $MOUNTS; do
- ismounted $mount && umount -R $mount
- done
- fi
-}
-
-do_final_action()
-{
- do_umount
- eval $FINAL_ACTION
-}
-
-do_default_action()
-{
- wait_for_loginit
- eval $DEFAULT_ACTION
-}
-
do_kdump_pre()
{
if [ -n "$KDUMP_PRE" ]; then
@@ -83,39 +46,6 @@ add_dump_code()
DUMP_INSTRUCTION=$1
}
-# dump_fs <mount point| device>
-dump_fs()
-{
- local _dev=$(findmnt -k -f -n -r -o SOURCE $1)
- local _mp=$(findmnt -k -f -n -r -o TARGET $1)
-
- echo "kdump: dump target is $_dev"
-
- if [ -z "$_mp" ]; then
- echo "kdump: error: Dump target $_dev is not mounted."
- return 1
- fi
- MOUNTS="$MOUNTS $_mp"
-
- # 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/"
-
- mount -o remount,rw $_mp || return 1
- mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1
-
- save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
-
- 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
- sync
-
- echo "kdump: saving vmcore complete"
- return 0
-}
-
dump_raw()
{
local _raw=$1
@@ -165,21 +95,6 @@ dump_ssh()
return 0
}
-save_vmcore_dmesg_fs() {
- local _dmesg_collector=$1
- local _path=$2
-
- echo "kdump: saving vmcore-dmesg.txt"
- $_dmesg_collector /proc/vmcore > ${_path}/vmcore-dmesg-incomplete.txt
- _exitcode=$?
- if [ $_exitcode -eq 0 ]; then
- mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt
- echo "kdump: saving vmcore-dmesg.txt complete"
- else
- echo "kdump: saving vmcore-dmesg.txt failed"
- fi
-}
-
save_vmcore_dmesg_ssh() {
local _dmesg_collector=$1
local _path=$2
@@ -198,7 +113,6 @@ save_vmcore_dmesg_ssh() {
fi
}
-
get_host_ip()
{
local _host
@@ -218,61 +132,12 @@ get_host_ip()
read_kdump_conf()
{
- if [ ! -f "$conf_file" ]; then
- echo "kdump: $conf_file not found"
+ if [ ! -f "$KDUMP_CONF" ]; then
+ echo "kdump: $KDUMP_CONF not found"
return
fi
- # first get the necessary variables
- while read config_opt config_val;
- do
- # remove inline comments after the end of a directive.
- config_val=$(strip_comments $config_val)
- case "$config_opt" in
- path)
- KDUMP_PATH="$config_val"
- ;;
- core_collector)
- [ -n "$config_val" ] && CORE_COLLECTOR="$config_val"
- ;;
- sshkey)
- if [ -f "$config_val" ]; then
- SSH_KEY_LOCATION=$config_val
- fi
- ;;
- kdump_pre)
- KDUMP_PRE="$config_val"
- ;;
- kdump_post)
- KDUMP_POST="$config_val"
- ;;
- fence_kdump_args)
- FENCE_KDUMP_ARGS="$config_val"
- ;;
- fence_kdump_nodes)
- FENCE_KDUMP_NODES="$config_val"
- ;;
- default)
- case $config_val in
- shell)
- DEFAULT_ACTION="_emergency_shell kdump"
- ;;
- reboot)
- DEFAULT_ACTION="do_umount; reboot -f"
- ;;
- halt)
- DEFAULT_ACTION="do_umount; halt -f"
- ;;
- poweroff)
- DEFAULT_ACTION="do_umount; poweroff -f"
- ;;
- dump_to_rootfs)
- DEFAULT_ACTION="dump_fs $NEWROOT"
- ;;
- esac
- ;;
- esac
- done < $conf_file
+ get_kdump_confs
# rescan for add code for dump target
while read config_opt config_val;
@@ -290,7 +155,7 @@ read_kdump_conf()
add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val"
;;
esac
- done < $conf_file
+ done < $KDUMP_CONF
}
fence_kdump_notify()
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 87ad072..84bf975 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -555,6 +555,7 @@ install() {
inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
inst_hook pre-pivot 9999 "$moddir/kdump.sh"
inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
+ inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh"
# Check for all the devices and if any device is iscsi, bring up iscsi
# target. Ideally all this should be pushed into dracut iscsi module
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
new file mode 100755
index 0000000..e2807c7
--- /dev/null
+++ b/kdump-lib-initramfs.sh
@@ -0,0 +1,146 @@
+# These variables and functions are useful in 2nd kernel
+
+. /lib/dracut-lib.sh
+. /lib/kdump-lib.sh
+
+KDUMP_PATH="/var/crash"
+CORE_COLLECTOR=""
+DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31"
+DMESG_COLLECTOR="/sbin/vmcore-dmesg"
+DEFAULT_ACTION="reboot -f"
+DATEDIR=`date +%Y.%m.%d-%T`
+HOST_IP='127.0.0.1'
+DUMP_INSTRUCTION=""
+SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
+KDUMP_SCRIPT_DIR="/kdumpscripts"
+DD_BLKSIZE=512
+FINAL_ACTION="reboot -f"
+KDUMP_CONF="/etc/kdump.conf"
+KDUMP_PRE=""
+KDUMP_POST=""
+NEWROOT="/sysroot"
+MOUNTS=""
+
+get_kdump_confs()
+{
+ local config_opt config_val
+
+ while read config_opt config_val;
+ do
+ # remove inline comments after the end of a directive.
+ config_val=$(strip_comments $config_val)
+ case "$config_opt" in
+ path)
+ KDUMP_PATH="$config_val"
+ ;;
+ core_collector)
+ [ -n "$config_val" ] && CORE_COLLECTOR="$config_val"
+ ;;
+ sshkey)
+ if [ -f "$config_val" ]; then
+ SSH_KEY_LOCATION=$config_val
+ fi
+ ;;
+ kdump_pre)
+ KDUMP_PRE="$config_val"
+ ;;
+ kdump_post)
+ KDUMP_POST="$config_val"
+ ;;
+ fence_kdump_args)
+ FENCE_KDUMP_ARGS="$config_val"
+ ;;
+ fence_kdump_nodes)
+ FENCE_KDUMP_NODES="$config_val"
+ ;;
+ default)
+ case $config_val in
+ shell)
+ DEFAULT_ACTION="_emergency_shell kdump"
+ ;;
+ reboot)
+ DEFAULT_ACTION="do_umount; reboot -f"
+ ;;
+ halt)
+ DEFAULT_ACTION="do_umount; halt -f"
+ ;;
+ poweroff)
+ DEFAULT_ACTION="do_umount; poweroff -f"
+ ;;
+ dump_to_rootfs)
+ DEFAULT_ACTION="dump_fs $NEWROOT"
+ ;;
+ esac
+ ;;
+ esac
+ done < $KDUMP_CONF
+}
+
+# dump_fs <mount point| device>
+dump_fs()
+{
+
+ local _dev=$(findmnt -k -f -n -r -o SOURCE $1)
+ local _mp=$(findmnt -k -f -n -r -o TARGET $1)
+
+ echo "kdump: dump target is $_dev"
+
+ if [ -z "$_mp" ]; then
+ echo "kdump: error: Dump target $_dev is not mounted."
+ return 1
+ fi
+ MOUNTS="$MOUNTS $_mp"
+
+ # 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/"
+
+ mount -o remount,rw $_mp || return 1
+ mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1
+
+ save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
+
+ 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
+ sync
+
+ echo "kdump: saving vmcore complete"
+}
+
+save_vmcore_dmesg_fs() {
+ local _dmesg_collector=$1
+ local _path=$2
+
+ echo "kdump: saving vmcore-dmesg.txt"
+ $_dmesg_collector /proc/vmcore > ${_path}/vmcore-dmesg-incomplete.txt
+ _exitcode=$?
+ if [ $_exitcode -eq 0 ]; then
+ mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt
+ echo "kdump: saving vmcore-dmesg.txt complete"
+ else
+ echo "kdump: saving vmcore-dmesg.txt failed"
+ fi
+}
+
+do_umount()
+{
+ if [ -n "$MOUNTS" ]; then
+ for mount in $MOUNTS; do
+ ismounted $mount && umount -R $mount
+ done
+ fi
+}
+
+do_default_action()
+{
+ wait_for_loginit
+ eval $DEFAULT_ACTION
+}
+
+do_final_action()
+{
+ do_umount
+ eval $FINAL_ACTION
+}
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 25dae2b..a613b43 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -27,6 +27,7 @@ Source20: kdump-lib.sh
Source21: kdump-in-cluster-environment.txt
Source22: kdump-dep-generator.sh
Source23: kdump-anaconda-addon-20140721.tar.gz
+Source24: kdump-lib-initramfs.sh
#######################################
# These are sources for mkdumpramfs
@@ -178,6 +179,7 @@ install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8
install -m 755 %{SOURCE11} $RPM_BUILD_ROOT%{_datadir}/kdump/firstboot_kdump.py
install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.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
%ifnarch s390x
# For s390x the ELF header is created in the kdump kernel and therefore kexec
# udev rules are not required
--
1.9.3
9 years, 4 months
[PATCH v4 0/2] Kdump error handling service
by WANG Chao
Hi, All
Now upon failure kdump script might not be called at all and it might
not be able to execute default action. It results in a hang.
Because we disable emergency shell and rely on kdump.sh being invoked
through dracut-pre-pivot hook. But it might happen that we never call
into dracut-pre-pivot hook because certain systemd targets could not
reach due to failure in their dependencies. In those cases error
handling code does not run and system hangs.
To solve this problem, we need to separate the error handling code from
dracut-pre-pivot hook, and every time when a failure shows up, the
separated code can be called by the emergency service.
By default systemd provides an emergency service which will drop us into
shell every time upon a critical failure. It's very convenient for us to
re-use the framework of systemd emergency, because we don't have to
touch the other parts of systemd. We can use our own script instead of
the default one.
This new scheme will overwrite emergency shell and replace with kdump
error handling code. And this code will do the error handling as needed.
Now, we will not rely on dracut-pre-pivot hook running always. Instead
whenever error happens and it is serious enough that emergency shell
needed to run, now kdump error handler will run.
This patchset introduce a new kdump emergency service. It will override the
existing emergency.service. When fatal error occurs, this emergency service
will be triggered and systemd will isolate to emergency path.
This kdump emergency service can will read kdump.conf and act according to the
configired "default action" (reboot/poweroff/halt/shell/dump_to_rootfs).
Along with this patchset, kdump-capture.service is introduced as a service unit
to run kdump.sh. When kdump-capture.service fails, systemd will isolate to
kdump emergency service. I copied all the dependencies from
dracut-pre-pivot.service to kdump-capture.service so that kdump.sh will be
called at the correct time window.
v2:
Address several comments from Vivek:
- split [patch 1] into 1/6 and 2/6
- remove several unnecessary lines in service unit.
- modify the description of kdump-capture.service
- introduce another kdump lib kdump-lib-2.sh used in 2nd kernel.
V3:
Address several comments from Vivek:
- update description of [PATCH 1/5] and [PATCH 5/5]
- separate the patch of cleanup to kdump-lib-initramfs.sh
V4:
Address several comments from Vivek and Dave:
- meld the original [PATCH 3/5] into [PATCH 1/5]
- add GPL license for kdump-error-handler.service and kdump-capture.service
- separate the "x-initrd.mount" and "mount under /sysroot" patch to another
patchset
WANG Chao (2):
Introduce kdump error handling service
Introduce kdump capture service
dracut-kdump-capture.service | 30 ++++++++++++++++++++++++++++++
dracut-kdump-emergency.service | 30 ++++++++++++++++++++++++++++++
dracut-kdump-error-handler.sh | 10 ++++++++++
dracut-kdump.sh | 9 ++-------
dracut-module-setup.sh | 7 ++++++-
kdump-lib-initramfs.sh | 34 ++++++++++++++++++++++++++++++----
kexec-tools.spec | 7 ++++++-
7 files changed, 114 insertions(+), 13 deletions(-)
create mode 100644 dracut-kdump-capture.service
create mode 100644 dracut-kdump-emergency.service
create mode 100755 dracut-kdump-error-handler.sh
--
1.9.3
9 years, 4 months
[PATCH v7 0/6] kdump: Modify kdump init script to support firmware-assisted dump
by Hari Bathini
This patch set implements firmware-assisted dump support for kdump
svice. Firmware-assisted dump support depends on existing kdump
infrastructure (kdump scripts) present in userland to save dump
to the disk. Though existing kdump script will work seemlessly, it
still needs to modified to make it aware of presense of firmware-
assisted dump feature during service start and stop. These changes
are tested successfully on a power box with fedora19.
Changes from v6 to v7:
1. Using node added to device tree by firmware to identify if boot
is after crash instead of using "/proc/vmcore". This makes for
better error handling.
2. Declared newly introduced variables.
3. Added setup_target_initrd routine to improve readability.
Changes from v5 to v6:
1. Using common global variable TARGET_INITRD for both kdump and
fadump modes
2. Reworked on determine_dump_mode routine
3. Using a temporary image for rebuilding
---
Hari Bathini (6):
kdump: Modify status routine to check for firmware-assisted dump
kdump: Modify kdump script to start the firmware assisted dump.
kdump: Modify kdump script to stop firmware assisted dump
kdump: Rebuild default initrd for firmware assisted dump
kdump: Check whether or not to invoke capturing vmcore
kdump: Add firmware-assisted dump howto document
dracut-kdump.sh | 5 +
fadump-howto.txt | 250 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
kdumpctl | 217 +++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 454 insertions(+), 18 deletions(-)
create mode 100644 fadump-howto.txt
--
- Hari
9 years, 4 months
[PATCH] dracut-kdump.sh: Issue a sync after saving vmcore-dmesg.txt
by Vivek Goyal
Recently somebody reported an issue where vmcore-dmesg.txt was saved
successfully but later saving vmcore failed to due to lack of space on disk.
System rebooted but after reboot there was nothing on disk. Not even
vmcore-dmesg.txt.
Issue a sync after saving vmcore-dmesg.txt to solve this issue.
I think this is happening because we are doing "reboot -f" instead of going
through systemd reboot path. Anyway, doing a sync now should take care of
this.
Signed-off-by: Vivek Goyal <vgoyal(a)redhat.com>
---
dracut-kdump.sh | 5 +++++
1 file changed, 5 insertions(+)
Index: kexec-tools-fedora/dracut-kdump.sh
===================================================================
--- kexec-tools-fedora.orig/dracut-kdump.sh 2014-06-03 08:41:19.024008596 -0400
+++ kexec-tools-fedora/dracut-kdump.sh 2014-07-24 13:43:13.042387127 -0400
@@ -174,6 +174,11 @@ save_vmcore_dmesg_fs() {
_exitcode=$?
if [ $_exitcode -eq 0 ]; then
mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt
+
+ # Make sure file is on disk. There have been instances where later
+ # saving vmcore failed and system rebooted without sync and there
+ # was no vmcore-dmesg.txt available.
+ sync
echo "kdump: saving vmcore-dmesg.txt complete"
else
echo "kdump: saving vmcore-dmesg.txt failed"
9 years, 4 months