Hi, All
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.
WANG Chao (6): mkdumprd: mount dump target under /sysroot in 2nd kernel mkdumprd: append "x-initrd.mount" to the mount options. cleanup: extract functions from kdump.sh to kdump-lib-2.sh Introduce kdump error handling service Introduce kdump capture service disable dracut-emergency.service the whole time
dracut-kdump-capture.service | 23 ++++++ dracut-kdump-emergency.service | 23 ++++++ dracut-kdump-error-handler.sh | 10 +++ dracut-kdump-lib-2.sh | 160 ++++++++++++++++++++++++++++++++++++++++ dracut-kdump.sh | 161 +---------------------------------------- dracut-module-setup.sh | 8 +- kdump-lib.sh | 6 +- kexec-tools.spec | 9 ++- mkdumprd | 25 ++++--- 9 files changed, 253 insertions(+), 172 deletions(-) create mode 100644 dracut-kdump-capture.service create mode 100644 dracut-kdump-emergency.service create mode 100755 dracut-kdump-error-handler.sh create mode 100755 dracut-kdump-lib-2.sh
This patch does the following change in 2nd kernel: - dump target is mounted under /sysroot
With this change, we don't need to track what we've mounted in 2nd kernel. We can just umount recursively every mount in /sysroot by command:
umount -R /sysroot
It's very convenient to do so, because it's hard to track what we've mounted when we're in error handling path. So mount everything under /sysroot is reasonable and practical for us.
Also clean up a bit along with this patch.
Signed-off-by: WANG Chao chaowang@redhat.com --- mkdumprd | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/mkdumprd b/mkdumprd index b49b74f..ba35800 100644 --- a/mkdumprd +++ b/mkdumprd @@ -97,19 +97,19 @@ target_is_root() {
# caller should ensure $1 is valid and mounted in 1st kernel to_mount() { - local _dev=$1 _s _t _o _mntopts _pdev - - _s=$(findmnt -k -f -n -r -o SOURCE $_dev) - _t=$(findmnt -k -f -n -r -o TARGET,FSTYPE $_dev) - _o=$(findmnt -k -f -n -r -o OPTIONS $_dev) - _o=${_o/#ro/rw} #mount fs target as rw in 2nd kernel - # "nofail" mount could be run later than kdump.sh. So we don't pass nofail - # for short term. - #_o="${_o},nofail" #with nofail set, systemd won't block for mount failure - _mntopts="$_t $_o" + local _dev=$1 _source _target _fstype _options _mntopts _pdev + + _source=$(findmnt -k -f -n -r -o SOURCE $_dev) + _target=$(findmnt -k -f -n -r -o TARGET $_dev) + # mount under /sysroot in 2nd kernel, and we umount -R /sysroot before exit + _target="/sysroot$_target" + _fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev) + _options=$(findmnt -k -f -n -r -o OPTIONS $_dev) + _options=${_options/#ro/rw} #mount fs target as rw in 2nd kernel + _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name - if [ -b "$_s" ]; then - _pdev="$(get_persistent_dev $_s)" + if [ -b "$_source" ]; then + _pdev="$(get_persistent_dev $_source)" if [ $? -ne 0 ]; then return 1 fi
On 06/17/14 at 03:07pm, WANG Chao wrote:
This patch does the following change in 2nd kernel:
- dump target is mounted under /sysroot
With this change, we don't need to track what we've mounted in 2nd kernel. We can just umount recursively every mount in /sysroot by command:
umount -R /sysroot
It's very convenient to do so, because it's hard to track what we've mounted when we're in error handling path. So mount everything under /sysroot is reasonable and practical for us.
Also clean up a bit along with this patch.
Signed-off-by: WANG Chao chaowang@redhat.com
mkdumprd | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/mkdumprd b/mkdumprd index b49b74f..ba35800 100644 --- a/mkdumprd +++ b/mkdumprd @@ -97,19 +97,19 @@ target_is_root() {
# caller should ensure $1 is valid and mounted in 1st kernel to_mount() {
- local _dev=$1 _s _t _o _mntopts _pdev
- _s=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _t=$(findmnt -k -f -n -r -o TARGET,FSTYPE $_dev)
- _o=$(findmnt -k -f -n -r -o OPTIONS $_dev)
- _o=${_o/#ro/rw} #mount fs target as rw in 2nd kernel
- # "nofail" mount could be run later than kdump.sh. So we don't pass nofail
- # for short term.
- #_o="${_o},nofail" #with nofail set, systemd won't block for mount failure
- _mntopts="$_t $_o"
- local _dev=$1 _source _target _fstype _options _mntopts _pdev
- _source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- # mount under /sysroot in 2nd kernel, and we umount -R /sysroot before exit
- _target="/sysroot$_target"
- _fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev)
- _options=$(findmnt -k -f -n -r -o OPTIONS $_dev)
- _options=${_options/#ro/rw} #mount fs target as rw in 2nd kernel
- _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name
- if [ -b "$_s" ]; then
_pdev="$(get_persistent_dev $_s)"
- if [ -b "$_source" ]; then
_pdev="$(get_persistent_dev $_source)" if [ $? -ne 0 ]; then return 1 fi
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
Currently in kdump initramfs, mount units specified in /etc/fstab are required by "local-fs.target". When any of these mounts fails, local-fs.target fails.
For kdump initramfs, we need to isolate to emergency service on any of the mount failure, that said, every service should be stopped and onlu emergency service would run. But local-fs.target won't trigger that on its failure. That means in case of mount failure, local-fs.target also enters failure state, but all the service will continue without any interruption.
After digging looking into source code of systemd-fstab-generator. I find "x-initrd.mount" using in initramfs mount, will make the mount units required by "initrd-root-fs.target" rather than it's used to be "local-fs.target".
"initrd-root-fs.target" is suitable to us because if it fails, it will isolate to emergency service. That means in case of any mount failure, the emergeny service will start and everything else will stop. We want this effect because we need to take kdump fail-safe action when there's a mount failure.
From systemd unit point of view, "initrd-root-fs.target" has
OnFailureIsolate=yes, but "local-fs.target" doesn't. From systemd.unit(5):
OnFailureIsolate= Takes a boolean argument. If true, the unit listed in OnFailure= will be enqueued in isolation mode, i.e. all units that are not its dependency will be stopped. If this is set, only a single unit may be listed in OnFailure=. Defaults to false.
NOTE: It's quite hacky to use "x-initrd.mount" in initramfs /etc/fstab. It's more common to specify it on real root /etc/fstab. Because I don't find any other way to do it, We can only hope that systemd will keep this feature.
Signed-off-by: WANG Chao chaowang@redhat.com --- mkdumprd | 1 + 1 file changed, 1 insertion(+)
diff --git a/mkdumprd b/mkdumprd index ba35800..a38d190 100644 --- a/mkdumprd +++ b/mkdumprd @@ -106,6 +106,7 @@ to_mount() { _fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev) _options=$(findmnt -k -f -n -r -o OPTIONS $_dev) _options=${_options/#ro/rw} #mount fs target as rw in 2nd kernel + _options="$_options,x-initrd.mount" _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name if [ -b "$_source" ]; then
On 06/17/14 at 03:07pm, WANG Chao wrote:
Currently in kdump initramfs, mount units specified in /etc/fstab are required by "local-fs.target". When any of these mounts fails, local-fs.target fails.
For kdump initramfs, we need to isolate to emergency service on any of the mount failure, that said, every service should be stopped and onlu emergency service would run. But local-fs.target won't trigger that on its failure. That means in case of mount failure, local-fs.target also enters failure state, but all the service will continue without any interruption.
After digging looking into source code of systemd-fstab-generator. I find "x-initrd.mount" using in initramfs mount, will make the mount units required by "initrd-root-fs.target" rather than it's used to be "local-fs.target".
"initrd-root-fs.target" is suitable to us because if it fails, it will isolate to emergency service. That means in case of any mount failure, the emergeny service will start and everything else will stop. We want this effect because we need to take kdump fail-safe action when there's a mount failure.
From systemd unit point of view, "initrd-root-fs.target" has OnFailureIsolate=yes, but "local-fs.target" doesn't. From systemd.unit(5):
OnFailureIsolate= Takes a boolean argument. If true, the unit listed in OnFailure= will be enqueued in isolation mode, i.e. all units that are not its dependency will be stopped. If this is set, only a single unit may be listed in OnFailure=. Defaults to false.
NOTE: It's quite hacky to use "x-initrd.mount" in initramfs /etc/fstab. It's more common to specify it on real root /etc/fstab. Because I don't find any other way to do it, We can only hope that systemd will keep this feature.
Signed-off-by: WANG Chao chaowang@redhat.com
mkdumprd | 1 + 1 file changed, 1 insertion(+)
diff --git a/mkdumprd b/mkdumprd index ba35800..a38d190 100644 --- a/mkdumprd +++ b/mkdumprd @@ -106,6 +106,7 @@ to_mount() { _fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev) _options=$(findmnt -k -f -n -r -o OPTIONS $_dev) _options=${_options/#ro/rw} #mount fs target as rw in 2nd kernel
- _options="$_options,x-initrd.mount" _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name if [ -b "$_source" ]; then
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
Chao, maybe you can resend the patch series and cc systemd mailing list to get their opinions especially for this one.
On 07/08/14 at 10:38am, Dave Young wrote:
On 06/17/14 at 03:07pm, WANG Chao wrote:
Currently in kdump initramfs, mount units specified in /etc/fstab are required by "local-fs.target". When any of these mounts fails, local-fs.target fails.
For kdump initramfs, we need to isolate to emergency service on any of the mount failure, that said, every service should be stopped and onlu emergency service would run. But local-fs.target won't trigger that on its failure. That means in case of mount failure, local-fs.target also enters failure state, but all the service will continue without any interruption.
After digging looking into source code of systemd-fstab-generator. I find "x-initrd.mount" using in initramfs mount, will make the mount units required by "initrd-root-fs.target" rather than it's used to be "local-fs.target".
"initrd-root-fs.target" is suitable to us because if it fails, it will isolate to emergency service. That means in case of any mount failure, the emergeny service will start and everything else will stop. We want this effect because we need to take kdump fail-safe action when there's a mount failure.
From systemd unit point of view, "initrd-root-fs.target" has OnFailureIsolate=yes, but "local-fs.target" doesn't. From systemd.unit(5):
OnFailureIsolate= Takes a boolean argument. If true, the unit listed in OnFailure= will be enqueued in isolation mode, i.e. all units that are not its dependency will be stopped. If this is set, only a single unit may be listed in OnFailure=. Defaults to false.
NOTE: It's quite hacky to use "x-initrd.mount" in initramfs /etc/fstab. It's more common to specify it on real root /etc/fstab. Because I don't find any other way to do it, We can only hope that systemd will keep this feature.
Signed-off-by: WANG Chao chaowang@redhat.com
mkdumprd | 1 + 1 file changed, 1 insertion(+)
diff --git a/mkdumprd b/mkdumprd index ba35800..a38d190 100644 --- a/mkdumprd +++ b/mkdumprd @@ -106,6 +106,7 @@ to_mount() { _fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev) _options=$(findmnt -k -f -n -r -o OPTIONS $_dev) _options=${_options/#ro/rw} #mount fs target as rw in 2nd kernel
- _options="$_options,x-initrd.mount" _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name if [ -b "$_source" ]; then
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 07/10/14 at 01:00pm, Dave Young wrote:
Chao, maybe you can resend the patch series and cc systemd mailing list to get their opinions especially for this one.
Hi, Harald
We're going to use 'x-initrd.mount' in kdump initramfs. Because by this, the mount unit become "Required" by initrd-root-fs.target and when it fails, initrd-root-fs.target can get us an isolated emergency service.
This feature is introduced by the following commit from you:
commit a87586a Author: Harald Hoyer harald@redhat.com Date: Tue Mar 26 15:33:57 2013 +0100
fstab-generator: drop x-initrd.rootfs mount option
x-initrd.mount now has different meanings, if fstab-generator is called in the initramfs.
initrd:/etc/fstab and x-initrd.mount defines mounts for the initrd-root-fs.target
initrd:/sysroot/etc/fstab and x-initrd.mount defines mounts for the initrd-fs.target
We're just wondering if this feature will stay the persistent in the future, and if this is what we're supposed to use.
We've sent a query to systemd-devel, but there's no core developers' responding. I think we can confirm this from you.
Thanks WANG Chao
On 10.07.2014 07:12, WANG Chao wrote:
On 07/10/14 at 01:00pm, Dave Young wrote:
Chao, maybe you can resend the patch series and cc systemd mailing list to get their opinions especially for this one.
Hi, Harald
We're going to use 'x-initrd.mount' in kdump initramfs. Because by this, the mount unit become "Required" by initrd-root-fs.target and when it fails, initrd-root-fs.target can get us an isolated emergency service.
This feature is introduced by the following commit from you:
commit a87586a Author: Harald Hoyer harald@redhat.com Date: Tue Mar 26 15:33:57 2013 +0100
fstab-generator: drop x-initrd.rootfs mount option x-initrd.mount now has different meanings, if fstab-generator is called in the initramfs. initrd:/etc/fstab and x-initrd.mount defines mounts for the initrd-root-fs.target initrd:/sysroot/etc/fstab and x-initrd.mount defines mounts for the initrd-fs.target
We're just wondering if this feature will stay the persistent in the future, and if this is what we're supposed to use.
yes, this will stay
We've sent a query to systemd-devel, but there's no core developers' responding. I think we can confirm this from you.
Thanks WANG Chao
On 07/10/14 at 01:42pm, Harald Hoyer wrote:
On 10.07.2014 07:12, WANG Chao wrote:
On 07/10/14 at 01:00pm, Dave Young wrote:
Chao, maybe you can resend the patch series and cc systemd mailing list to get their opinions especially for this one.
Hi, Harald
We're going to use 'x-initrd.mount' in kdump initramfs. Because by this, the mount unit become "Required" by initrd-root-fs.target and when it fails, initrd-root-fs.target can get us an isolated emergency service.
This feature is introduced by the following commit from you:
commit a87586a Author: Harald Hoyer harald@redhat.com Date: Tue Mar 26 15:33:57 2013 +0100
fstab-generator: drop x-initrd.rootfs mount option x-initrd.mount now has different meanings, if fstab-generator is called in the initramfs. initrd:/etc/fstab and x-initrd.mount defines mounts for the initrd-root-fs.target initrd:/sysroot/etc/fstab and x-initrd.mount defines mounts for the initrd-fs.target
We're just wondering if this feature will stay the persistent in the future, and if this is what we're supposed to use.
yes, this will stay
Thanks!
On Tue, Jun 17, 2014 at 03:07:58PM +0800, WANG Chao wrote:
Currently in kdump initramfs, mount units specified in /etc/fstab are required by "local-fs.target". When any of these mounts fails, local-fs.target fails.
For kdump initramfs, we need to isolate to emergency service on any of the mount failure,
Hi Chao,
I can't remember that why do we need to isolate to emergency service on any of the mount failures?
What's the default behavior currently if one of the specified mount fails to mount.
It has been long since I looked at these patches. Trying to fault all the context back in.
Thanks Vivek
On 07/10/14 at 11:28am, Vivek Goyal wrote:
On Tue, Jun 17, 2014 at 03:07:58PM +0800, WANG Chao wrote:
Currently in kdump initramfs, mount units specified in /etc/fstab are required by "local-fs.target". When any of these mounts fails, local-fs.target fails.
For kdump initramfs, we need to isolate to emergency service on any of the mount failure,
Hi Chao,
I can't remember that why do we need to isolate to emergency service on any of the mount failures?
If we don't isolate, system will continue to boot and causing emergency service to be shut down at some point later.
What's the default behavior currently if one of the specified mount fails to mount.
W/o x-initrd.mount, mount failure doesn't trigger emergency service. W/ x-initrd.mount, mount failure is critical and emergency will start.
It has been long since I looked at these patches. Trying to fault all the context back in.
Me too. It gets easily to forget because of all the hidden relations among systemd mount/service/target. Hope it won't take you long to sort out.
Thanks WANG Chao
On Mon, Jul 14, 2014 at 03:57:12PM +0800, WANG Chao wrote:
On 07/10/14 at 11:28am, Vivek Goyal wrote:
On Tue, Jun 17, 2014 at 03:07:58PM +0800, WANG Chao wrote:
Currently in kdump initramfs, mount units specified in /etc/fstab are required by "local-fs.target". When any of these mounts fails, local-fs.target fails.
For kdump initramfs, we need to isolate to emergency service on any of the mount failure,
Hi Chao,
I can't remember that why do we need to isolate to emergency service on any of the mount failures?
If we don't isolate, system will continue to boot and causing emergency service to be shut down at some point later.
So let us say that somebody is dumping to nfs. Now /etc/fstab will have two entries. One for nfs and other for root. If root, mount fails, kdump will still succeed and dump to nfs and system will reboot. So we should not have this strict requirement that if any of the mount in /etc/fstab fails we isolate to emergency service.
Though if root fails, systemd might not make any progress.
Anyway, just put in changelogs that why isolating to emergency service is improtant.
Thanks Vivek
On 07/14/14 at 08:27am, Vivek Goyal wrote:
On Mon, Jul 14, 2014 at 03:57:12PM +0800, WANG Chao wrote:
On 07/10/14 at 11:28am, Vivek Goyal wrote:
On Tue, Jun 17, 2014 at 03:07:58PM +0800, WANG Chao wrote:
Currently in kdump initramfs, mount units specified in /etc/fstab are required by "local-fs.target". When any of these mounts fails, local-fs.target fails.
For kdump initramfs, we need to isolate to emergency service on any of the mount failure,
Hi Chao,
I can't remember that why do we need to isolate to emergency service on any of the mount failures?
If we don't isolate, system will continue to boot and causing emergency service to be shut down at some point later.
So let us say that somebody is dumping to nfs. Now /etc/fstab will have two entries. One for nfs and other for root. If root, mount fails, kdump will still succeed and dump to nfs and system will reboot. So we should not have this strict requirement that if any of the mount in /etc/fstab fails we isolate to emergency service.
We will only have a single entry, the nfs mount. We never put root mount into /etc/fstab in any case. Because sysroot.mount unit is generated automatically according to the "root=" arg of /proc/cmdline.
The bottom line is only the mount of the dump target will be put in /etc/fstab. And we only have one dump target for now. Even if we have multiple dump targets down the line, we will append "x-initrd.mount" to each of them.
Though if root fails, systemd might not make any progress.
Anyway, just put in changelogs that why isolating to emergency service is improtant.
Yeah of course.
Thanks WANG Chao
In the later patch, the kdump error handler script can reuse some of the code in kdump.sh. So introduce a new kdump library kdump-lib-2.sh and put the common functions and variables there.
kdump-lib-2.sh is only used in 2nd kernel, and kdump-lib.sh will automatically include it.
Signed-off-by: WANG Chao chaowang@redhat.com --- dracut-kdump-lib-2.sh | 160 +++++++++++++++++++++++++++++++++++++++++++++++++ dracut-kdump.sh | 152 +--------------------------------------------- dracut-module-setup.sh | 1 + kdump-lib.sh | 6 +- kexec-tools.spec | 2 + 5 files changed, 170 insertions(+), 151 deletions(-) create mode 100755 dracut-kdump-lib-2.sh
diff --git a/dracut-kdump-lib-2.sh b/dracut-kdump-lib-2.sh new file mode 100755 index 0000000..cb2fdf7 --- /dev/null +++ b/dracut-kdump-lib-2.sh @@ -0,0 +1,160 @@ +# These variables and functions are useful in 2nd kernel + +KDUMP_PATH="/var/crash" +CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31" +DMESG_COLLECTOR="/sbin/vmcore-dmesg" +DEFAULT_ACTION="reboot -f" +SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +KDUMP_PRE="" +KDUMP_POST="" +DATEDIR=`date +%Y.%m.%d-%T` +HOST_IP='127.0.0.1' +DUMP_INSTRUCTION="" +KDUMP_SCRIPT_DIR="/kdumpscripts" +DD_BLKSIZE=512 +KDUMP_CONF="/etc/kdump.conf" +NEWROOT="/sysroot" + +get_kdump_confs() +{ + local config_opt config_val + local user_specified_cc + + 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) + CORE_COLLECTOR="$config_val" + user_specified_cc=yes + ;; + sshkey) + SSH_KEY_LOCATION=$config_val + ;; + 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="kdump_emergency_shell" + ;; + 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_to_rootfs" + ;; + esac + ;; + esac + done < $KDUMP_CONF + + if is_ssh_dump_target || is_raw_dump_target; then + if [ -z "$user_specified_cc" ]; then + CORE_COLLECTOR="$CORE_COLLECTOR -F" + fi + fi +} + +# 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 + + # 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 +} + +dump_to_rootfs() +{ + + echo "Kdump: trying to bring up rootfs device" + systemctl start dracut-initqueue + echo "Kdump: waiting for rootfs mount, will timeout after 90 seconds" + systemctl start sysroot.mount + + dump_fs $NEWROOT +} + +kdump_emergency_shell() +{ + echo "PS1="kdump:\${PWD}# "" >/etc/profile + /bin/dracut-emergency + rm -f /etc/profile +} + +do_umount() +{ + umount -Rf /sysroot +} + +do_default_action() +{ + echo "Kdump: Error Occured, doing default action" + eval $DEFAULT_ACTION +} + + +do_final_action() +{ + do_umount + reboot -f +} diff --git a/dracut-kdump.sh b/dracut-kdump.sh index cb13d92..1960b7e 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -9,24 +9,6 @@ if [ -f "$initdir/lib/dracut/no-emergency-shell" ]; then 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
do_dump() @@ -43,27 +25,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 +44,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 +93,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 @@ -218,61 +131,7 @@ get_host_ip()
read_kdump_conf() { - if [ ! -f "$conf_file" ]; then - echo "kdump: $conf_file 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 +149,7 @@ read_kdump_conf() add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" ;; esac - done < $conf_file + done < $KDUMP_CONF }
fence_kdump_notify() @@ -303,13 +162,6 @@ fence_kdump_notify() read_kdump_conf fence_kdump_notify
-if [ -z "$CORE_COLLECTOR" ];then - CORE_COLLECTOR=$DEFAULT_CORE_COLLECTOR - if is_ssh_dump_target || is_raw_dump_target; then - CORE_COLLECTOR="$CORE_COLLECTOR -F" - fi -fi - get_host_ip if [ $? -ne 0 ]; then echo "kdump: get_host_ip exited with non-zero status!" diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 87ad072..61f588a 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 "$moddir/kdump-lib-2.sh" "/lib/kdump-lib-2.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.sh b/kdump-lib.sh index a20c6e8..07fa50a 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -3,6 +3,11 @@ # Kdump common variables and functions #
+# In 2nd kernel? +if [ -f /usr/lib/kdump-lib-2.sh ]; then + . /usr/lib/kdump-lib-2.sh +fi + DEFAULT_PATH="/var/crash/" FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" @@ -137,4 +142,3 @@ check_save_path_fs() perror_exit "Dump path $_path does not exist." fi } - diff --git a/kexec-tools.spec b/kexec-tools.spec index 9230ccf..5c8f60d 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -35,6 +35,7 @@ Source23: kdump-anaconda-addon-20140522.tar.gz Source100: dracut-kdump.sh Source101: dracut-module-setup.sh Source102: dracut-monitor_dd_progress +Source103: dracut-kdump-lib-2.sh
Requires(post): systemd-units Requires(preun): systemd-units @@ -198,6 +199,7 @@ mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpba cp %{SOURCE100} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} cp %{SOURCE101} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE102}} +cp %{SOURCE103} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE103}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}}
On 06/17/14 at 03:07pm, WANG Chao wrote:
In the later patch, the kdump error handler script can reuse some of the code in kdump.sh. So introduce a new kdump library kdump-lib-2.sh and put the common functions and variables there.
kdump-lib-2.sh is only used in 2nd kernel, and kdump-lib.sh will automatically include it.
Signed-off-by: WANG Chao chaowang@redhat.com
dracut-kdump-lib-2.sh | 160 +++++++++++++++++++++++++++++++++++++++++++++++++ dracut-kdump.sh | 152 +--------------------------------------------- dracut-module-setup.sh | 1 + kdump-lib.sh | 6 +- kexec-tools.spec | 2 + 5 files changed, 170 insertions(+), 151 deletions(-) create mode 100755 dracut-kdump-lib-2.sh
diff --git a/dracut-kdump-lib-2.sh b/dracut-kdump-lib-2.sh new file mode 100755 index 0000000..cb2fdf7 --- /dev/null +++ b/dracut-kdump-lib-2.sh @@ -0,0 +1,160 @@ +# These variables and functions are useful in 2nd kernel
+KDUMP_PATH="/var/crash" +CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31" +DMESG_COLLECTOR="/sbin/vmcore-dmesg" +DEFAULT_ACTION="reboot -f" +SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +KDUMP_PRE="" +KDUMP_POST="" +DATEDIR=`date +%Y.%m.%d-%T` +HOST_IP='127.0.0.1' +DUMP_INSTRUCTION="" +KDUMP_SCRIPT_DIR="/kdumpscripts" +DD_BLKSIZE=512 +KDUMP_CONF="/etc/kdump.conf" +NEWROOT="/sysroot"
+get_kdump_confs() +{
- local config_opt config_val
- local user_specified_cc
- 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)
CORE_COLLECTOR="$config_val"
user_specified_cc=yes
;;
sshkey)
SSH_KEY_LOCATION=$config_val
;;
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="kdump_emergency_shell"
;;
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_to_rootfs"
;;
esac
;;
esac
- done < $KDUMP_CONF
- if is_ssh_dump_target || is_raw_dump_target; then
if [ -z "$user_specified_cc" ]; then
CORE_COLLECTOR="$CORE_COLLECTOR -F"
fi
- fi
+}
+# 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
- # 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
+}
+dump_to_rootfs() +{
- echo "Kdump: trying to bring up rootfs device"
- systemctl start dracut-initqueue
- echo "Kdump: waiting for rootfs mount, will timeout after 90 seconds"
- systemctl start sysroot.mount
- dump_fs $NEWROOT
+}
+kdump_emergency_shell() +{
- echo "PS1="kdump:\${PWD}# "" >/etc/profile
- /bin/dracut-emergency
- rm -f /etc/profile
+}
+do_umount() +{
- umount -Rf /sysroot
+}
+do_default_action() +{
- echo "Kdump: Error Occured, doing default action"
- eval $DEFAULT_ACTION
+}
+do_final_action() +{
- do_umount
- reboot -f
+} diff --git a/dracut-kdump.sh b/dracut-kdump.sh index cb13d92..1960b7e 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -9,24 +9,6 @@ if [ -f "$initdir/lib/dracut/no-emergency-shell" ]; then 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
do_dump() @@ -43,27 +25,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 +44,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 +93,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 @@ -218,61 +131,7 @@ get_host_ip()
read_kdump_conf() {
- if [ ! -f "$conf_file" ]; then
echo "kdump: $conf_file 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 +149,7 @@ read_kdump_conf() add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" ;; esac
- done < $conf_file
- done < $KDUMP_CONF
}
fence_kdump_notify() @@ -303,13 +162,6 @@ fence_kdump_notify() read_kdump_conf fence_kdump_notify
-if [ -z "$CORE_COLLECTOR" ];then
- CORE_COLLECTOR=$DEFAULT_CORE_COLLECTOR
- if is_ssh_dump_target || is_raw_dump_target; then
CORE_COLLECTOR="$CORE_COLLECTOR -F"
- fi
-fi
get_host_ip if [ $? -ne 0 ]; then echo "kdump: get_host_ip exited with non-zero status!" diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 87ad072..61f588a 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 "$moddir/kdump-lib-2.sh" "/lib/kdump-lib-2.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.sh b/kdump-lib.sh index a20c6e8..07fa50a 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -3,6 +3,11 @@ # Kdump common variables and functions #
+# In 2nd kernel? +if [ -f /usr/lib/kdump-lib-2.sh ]; then
- . /usr/lib/kdump-lib-2.sh
+fi
DEFAULT_PATH="/var/crash/" FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" @@ -137,4 +142,3 @@ check_save_path_fs() perror_exit "Dump path $_path does not exist." fi }
diff --git a/kexec-tools.spec b/kexec-tools.spec index 9230ccf..5c8f60d 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -35,6 +35,7 @@ Source23: kdump-anaconda-addon-20140522.tar.gz Source100: dracut-kdump.sh Source101: dracut-module-setup.sh Source102: dracut-monitor_dd_progress +Source103: dracut-kdump-lib-2.sh
Requires(post): systemd-units Requires(preun): systemd-units @@ -198,6 +199,7 @@ mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpba cp %{SOURCE100} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} cp %{SOURCE101} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE102}} +cp %{SOURCE103} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE103}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} -- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On Tue, Jun 17, 2014 at 03:07:59PM +0800, WANG Chao wrote:
In the later patch, the kdump error handler script can reuse some of the code in kdump.sh. So introduce a new kdump library kdump-lib-2.sh and put the common functions and variables there.
kdump-lib-2.sh is only used in 2nd kernel, and kdump-lib.sh will automatically include it.
I think kdump-lib-2.sh is not very good name. How about kdump-lib-initramfs.sh and specify that it is used only in the context of when running from initramfs.
And this comment is confusing. If kdump-lib-2.sh can be used only in second kernel, and kdump-lib.sh will include it that means it is being used in first kernel too?
Or we are trying to say that kdump-lib-2.sh can be used in both the contexts while kdump-lib.sh can be used only while generating initramfs and not while running from inside initramfs?
If yes, then a better naming might be.
kdump-lib-common.sh ----> A more generic library. This can be used in both contexts.
kdump-lib.sh --> Library which should be included only in code which runs during initramfs generation.
Thanks Vivek
On 07/10/14 at 02:04pm, Vivek Goyal wrote:
On Tue, Jun 17, 2014 at 03:07:59PM +0800, WANG Chao wrote:
In the later patch, the kdump error handler script can reuse some of the code in kdump.sh. So introduce a new kdump library kdump-lib-2.sh and put the common functions and variables there.
kdump-lib-2.sh is only used in 2nd kernel, and kdump-lib.sh will automatically include it.
I think kdump-lib-2.sh is not very good name. How about kdump-lib-initramfs.sh and specify that it is used only in the context of when running from initramfs.
I think kdump-lib-initramfs.sh makes more sense to me. I'll use the name.
And this comment is confusing. If kdump-lib-2.sh can be used only in second kernel, and kdump-lib.sh will include it that means it is being used in first kernel too?
Right. It is confusing even to me when I look back :(
I'll try to make things clear.
Or we are trying to say that kdump-lib-2.sh can be used in both the contexts while kdump-lib.sh can be used only while generating initramfs and not while running from inside initramfs?
If yes, then a better naming might be.
kdump-lib-common.sh ----> A more generic library. This can be used in both contexts.
kdump-lib.sh --> Library which should be included only in code which runs during initramfs generation.
How about the following:
kdump-lib.sh ----> A more generic library. This can be used in both contexts.
kdump-lib-initramfs.sh --> Library which should be included only in code which runs during initramfs generation.
In 1st kernel, only kdump-lib.sh will be included. In 2nd kernel, both kdump-lib.sh and kdump-lib-initramfs.sh will be included.
Does this make sense to you?
Thanks WANG Chao
On Mon, Jul 14, 2014 at 03:45:45PM +0800, WANG Chao wrote:
[..]
How about the following:
kdump-lib.sh ----> A more generic library. This can be used in both contexts.
kdump-lib-initramfs.sh --> Library which should be included only in code which runs during initramfs generation.
In 1st kernel, only kdump-lib.sh will be included. In 2nd kernel, both kdump-lib.sh and kdump-lib-initramfs.sh will be included.
Does this make sense to you?
Yep, above makes sense.
Thanks Vivek
On Tue, Jun 17, 2014 at 03:07:59PM +0800, WANG Chao wrote:
In the later patch, the kdump error handler script can reuse some of the code in kdump.sh. So introduce a new kdump library kdump-lib-2.sh and put the common functions and variables there.
kdump-lib-2.sh is only used in 2nd kernel, and kdump-lib.sh will automatically include it.
Chao, In fact this cleanup of library probably can go in as a separate patch and rest of the patch series can build on top of it.
Thanks Vivek
On 07/11/14 at 10:48am, Vivek Goyal wrote:
On Tue, Jun 17, 2014 at 03:07:59PM +0800, WANG Chao wrote:
In the later patch, the kdump error handler script can reuse some of the code in kdump.sh. So introduce a new kdump library kdump-lib-2.sh and put the common functions and variables there.
kdump-lib-2.sh is only used in 2nd kernel, and kdump-lib.sh will automatically include it.
Chao, In fact this cleanup of library probably can go in as a separate patch and rest of the patch series can build on top of it.
OK. I'll try.
Thanks WANG Chao
Current kdump error handling disables emergency shell and relies on kdump.sh being invoked through dracut-pre-pivot hook. But it might happen that we never call into dracut-pre-pivot hook because some targets before that could not reach due to failure in their dependencies. In those cases error handling code does not run and system hangs.
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.
Signed-off-by: WANG Chao chaowang@redhat.com --- dracut-kdump-emergency.service | 23 +++++++++++++++++++++++ dracut-kdump-error-handler.sh | 10 ++++++++++ dracut-module-setup.sh | 3 +++ kexec-tools.spec | 5 ++++- 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 dracut-kdump-emergency.service create mode 100755 dracut-kdump-error-handler.sh
diff --git a/dracut-kdump-emergency.service b/dracut-kdump-emergency.service new file mode 100644 index 0000000..6c90420 --- /dev/null +++ b/dracut-kdump-emergency.service @@ -0,0 +1,23 @@ +[Unit] +Description=Kdump Error Handler +DefaultDependencies=no +After=systemd-vconsole-setup.service +Wants=systemd-vconsole-setup.service + +[Service] +Environment=HOME=/ +Environment=DRACUT_SYSTEMD=1 +Environment=NEWROOT=/sysroot +WorkingDirectory=/ +ExecStart=/bin/kdump-error-handler.sh +ExecStopPost=-/usr/bin/systemctl --fail --no-block default +Type=oneshot +StandardInput=tty-force +StandardOutput=inherit +StandardError=inherit +KillMode=process +IgnoreSIGPIPE=no + +# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash +# terminates cleanly. +KillSignal=SIGHUP diff --git a/dracut-kdump-error-handler.sh b/dracut-kdump-error-handler.sh new file mode 100755 index 0000000..2c55b04 --- /dev/null +++ b/dracut-kdump-error-handler.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +. /lib/kdump-lib.sh + +set -o pipefail +export PATH=$PATH:$KDUMP_SCRIPT_DIR + +get_kdump_confs +do_default_action +do_final_action diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 61f588a..bd7722c 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -556,6 +556,9 @@ install() { inst_hook pre-pivot 9999 "$moddir/kdump.sh" inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" inst "$moddir/kdump-lib-2.sh" "/lib/kdump-lib-2.sh" + inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh" + # Replace existing emergency service + cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service"
# 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/kexec-tools.spec b/kexec-tools.spec index 5c8f60d..21cfe6e 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -36,6 +36,8 @@ Source100: dracut-kdump.sh Source101: dracut-module-setup.sh Source102: dracut-monitor_dd_progress Source103: dracut-kdump-lib-2.sh +Source104: dracut-kdump-error-handler.sh +Source105: dracut-kdump-emergency.service
Requires(post): systemd-units Requires(preun): systemd-units @@ -200,7 +202,8 @@ cp %{SOURCE100} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpb cp %{SOURCE101} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE102}} cp %{SOURCE103} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE103}} - +cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE104}} +cp %{SOURCE105} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE105}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}}
On 06/17/14 at 03:08pm, WANG Chao wrote:
Current kdump error handling disables emergency shell and relies on kdump.sh being invoked through dracut-pre-pivot hook. But it might happen that we never call into dracut-pre-pivot hook because some targets before that could not reach due to failure in their dependencies. In those cases error handling code does not run and system hangs.
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.
Signed-off-by: WANG Chao chaowang@redhat.com
dracut-kdump-emergency.service | 23 +++++++++++++++++++++++ dracut-kdump-error-handler.sh | 10 ++++++++++ dracut-module-setup.sh | 3 +++ kexec-tools.spec | 5 ++++- 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 dracut-kdump-emergency.service create mode 100755 dracut-kdump-error-handler.sh
diff --git a/dracut-kdump-emergency.service b/dracut-kdump-emergency.service new file mode 100644 index 0000000..6c90420 --- /dev/null +++ b/dracut-kdump-emergency.service @@ -0,0 +1,23 @@ +[Unit] +Description=Kdump Error Handler +DefaultDependencies=no +After=systemd-vconsole-setup.service +Wants=systemd-vconsole-setup.service
+[Service] +Environment=HOME=/ +Environment=DRACUT_SYSTEMD=1 +Environment=NEWROOT=/sysroot +WorkingDirectory=/ +ExecStart=/bin/kdump-error-handler.sh +ExecStopPost=-/usr/bin/systemctl --fail --no-block default +Type=oneshot +StandardInput=tty-force +StandardOutput=inherit +StandardError=inherit +KillMode=process +IgnoreSIGPIPE=no
+# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash +# terminates cleanly. +KillSignal=SIGHUP diff --git a/dracut-kdump-error-handler.sh b/dracut-kdump-error-handler.sh new file mode 100755 index 0000000..2c55b04 --- /dev/null +++ b/dracut-kdump-error-handler.sh @@ -0,0 +1,10 @@ +#!/bin/sh
+. /lib/kdump-lib.sh
+set -o pipefail +export PATH=$PATH:$KDUMP_SCRIPT_DIR
+get_kdump_confs +do_default_action +do_final_action diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 61f588a..bd7722c 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -556,6 +556,9 @@ install() { inst_hook pre-pivot 9999 "$moddir/kdump.sh" inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" inst "$moddir/kdump-lib-2.sh" "/lib/kdump-lib-2.sh"
inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh"
# Replace existing emergency service
cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service"
# 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/kexec-tools.spec b/kexec-tools.spec index 5c8f60d..21cfe6e 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -36,6 +36,8 @@ Source100: dracut-kdump.sh Source101: dracut-module-setup.sh Source102: dracut-monitor_dd_progress Source103: dracut-kdump-lib-2.sh +Source104: dracut-kdump-error-handler.sh +Source105: dracut-kdump-emergency.service
Requires(post): systemd-units Requires(preun): systemd-units @@ -200,7 +202,8 @@ cp %{SOURCE100} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpb cp %{SOURCE101} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE102}} cp %{SOURCE103} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE103}}
+cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE104}} +cp %{SOURCE105} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE105}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}}
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
This patch introduce a new kdump-capture.service which is used to run kdump.sh.
kdump-capture.service has OnFailure=emergency.target and OnFailureIsolate=yes set. When kdump.sh fails, the kdump emergency service will be triggered and enter the error handling path.
In 2nd kernel, the default target for systemd is initrd.target, so we put kdump-capture.service in initrd.target.wants/ and by that, system will start kdump-capture as part of the boot process.
kdump.sh used to run in dracut-pre-pivot hook. Now kdump-capture.service is placed after dracut-pre-pivot.service and other dependencies are all copied from dracut-pre-pivot.service. So the start point of kdump.sh will be almost the same as it used to be.
Signed-off-by: WANG Chao chaowang@redhat.com --- dracut-kdump-capture.service | 23 +++++++++++++++++++++++ dracut-kdump.sh | 5 ++--- dracut-module-setup.sh | 4 +++- kexec-tools.spec | 2 ++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 dracut-kdump-capture.service
diff --git a/dracut-kdump-capture.service b/dracut-kdump-capture.service new file mode 100644 index 0000000..febe2eb --- /dev/null +++ b/dracut-kdump-capture.service @@ -0,0 +1,23 @@ +[Unit] +Description=Kdump Vmcore Save Service +After=initrd.target initrd-parse-etc.service sysroot.mount +After=dracut-initqueue.service dracut-pre-mount.service dracut-mount.service dracut-pre-pivot.service +Before=initrd-cleanup.service +ConditionPathExists=/etc/initrd-release +OnFailure=emergency.target +OnFailureIsolate=yes + +[Service] +Environment=DRACUT_SYSTEMD=1 +Environment=NEWROOT=/sysroot +Type=oneshot +ExecStart=/bin/kdump.sh +StandardInput=null +StandardOutput=syslog +StandardError=syslog+console +KillMode=process +RemainAfterExit=yes + +# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash +# terminates cleanly. +KillSignal=SIGHUP diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 1960b7e..d092e04 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -165,8 +165,7 @@ fence_kdump_notify get_host_ip if [ $? -ne 0 ]; then echo "kdump: get_host_ip exited with non-zero status!" - do_default_action - do_final_action + exit 1 fi
if [ -z "$DUMP_INSTRUCTION" ]; then @@ -188,7 +187,7 @@ if [ $? -ne 0 ]; then fi
if [ $DUMP_RETVAL -ne 0 ]; then - do_default_action + exit 1 fi
do_final_action diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index bd7722c..9e099a9 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -553,9 +553,11 @@ install() { inst "/bin/cut" "/bin/cut" inst "/sbin/makedumpfile" "/sbin/makedumpfile" 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 "$moddir/kdump-lib-2.sh" "/lib/kdump-lib-2.sh" + inst "$moddir/kdump.sh" "/usr/bin/kdump.sh" + inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service" + ln_r "$systemdsystemunitdir/kdump-capture.service" "$systemdsystemunitdir/initrd.target.wants/kdump-capture.service" inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh" # Replace existing emergency service cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service" diff --git a/kexec-tools.spec b/kexec-tools.spec index 21cfe6e..b327f75 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -38,6 +38,7 @@ Source102: dracut-monitor_dd_progress Source103: dracut-kdump-lib-2.sh Source104: dracut-kdump-error-handler.sh Source105: dracut-kdump-emergency.service +Source106: dracut-kdump-capture.service
Requires(post): systemd-units Requires(preun): systemd-units @@ -204,6 +205,7 @@ cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpb cp %{SOURCE103} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE103}} cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE104}} cp %{SOURCE105} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE105}} +cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE106}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}}
On 06/17/14 at 03:08pm, WANG Chao wrote:
This patch introduce a new kdump-capture.service which is used to run kdump.sh.
kdump-capture.service has OnFailure=emergency.target and OnFailureIsolate=yes set. When kdump.sh fails, the kdump emergency service will be triggered and enter the error handling path.
In 2nd kernel, the default target for systemd is initrd.target, so we put kdump-capture.service in initrd.target.wants/ and by that, system will start kdump-capture as part of the boot process.
kdump.sh used to run in dracut-pre-pivot hook. Now kdump-capture.service is placed after dracut-pre-pivot.service and other dependencies are all copied from dracut-pre-pivot.service. So the start point of kdump.sh will be almost the same as it used to be.
Signed-off-by: WANG Chao chaowang@redhat.com
dracut-kdump-capture.service | 23 +++++++++++++++++++++++ dracut-kdump.sh | 5 ++--- dracut-module-setup.sh | 4 +++- kexec-tools.spec | 2 ++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 dracut-kdump-capture.service
diff --git a/dracut-kdump-capture.service b/dracut-kdump-capture.service new file mode 100644 index 0000000..febe2eb --- /dev/null +++ b/dracut-kdump-capture.service @@ -0,0 +1,23 @@ +[Unit] +Description=Kdump Vmcore Save Service +After=initrd.target initrd-parse-etc.service sysroot.mount +After=dracut-initqueue.service dracut-pre-mount.service dracut-mount.service dracut-pre-pivot.service +Before=initrd-cleanup.service +ConditionPathExists=/etc/initrd-release +OnFailure=emergency.target +OnFailureIsolate=yes
+[Service] +Environment=DRACUT_SYSTEMD=1 +Environment=NEWROOT=/sysroot +Type=oneshot +ExecStart=/bin/kdump.sh +StandardInput=null +StandardOutput=syslog +StandardError=syslog+console +KillMode=process +RemainAfterExit=yes
+# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash +# terminates cleanly. +KillSignal=SIGHUP diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 1960b7e..d092e04 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -165,8 +165,7 @@ fence_kdump_notify get_host_ip if [ $? -ne 0 ]; then echo "kdump: get_host_ip exited with non-zero status!"
- do_default_action
- do_final_action
- exit 1
fi
if [ -z "$DUMP_INSTRUCTION" ]; then @@ -188,7 +187,7 @@ if [ $? -ne 0 ]; then fi
if [ $DUMP_RETVAL -ne 0 ]; then
- do_default_action
- exit 1
fi
do_final_action diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index bd7722c..9e099a9 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -553,9 +553,11 @@ install() { inst "/bin/cut" "/bin/cut" inst "/sbin/makedumpfile" "/sbin/makedumpfile" 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 "$moddir/kdump-lib-2.sh" "/lib/kdump-lib-2.sh"
- inst "$moddir/kdump.sh" "/usr/bin/kdump.sh"
- inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service"
- ln_r "$systemdsystemunitdir/kdump-capture.service" "$systemdsystemunitdir/initrd.target.wants/kdump-capture.service" inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh" # Replace existing emergency service cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service"
diff --git a/kexec-tools.spec b/kexec-tools.spec index 21cfe6e..b327f75 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -38,6 +38,7 @@ Source102: dracut-monitor_dd_progress Source103: dracut-kdump-lib-2.sh Source104: dracut-kdump-error-handler.sh Source105: dracut-kdump-emergency.service +Source106: dracut-kdump-capture.service
Requires(post): systemd-units Requires(preun): systemd-units @@ -204,6 +205,7 @@ cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpb cp %{SOURCE103} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE103}} cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE104}} cp %{SOURCE105} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE105}} +cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE106}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}}
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
dracut-emergency.service is conflicting with emergency.service:
"Conflicts=emergency.service emergency.target"
We should always disable dracut-emergency.service. Because if it gets started, our emergency.service will be interrupted and stopped.
And also dracut-emergency.service isn't useful now, since we introduced our own error handler.
Signed-off-by: WANG Chao chaowang@redhat.com --- dracut-kdump.sh | 4 ---- 1 file changed, 4 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index d092e04..eb4ab42 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -4,10 +4,6 @@ exec &> /dev/console . /lib/dracut-lib.sh . /lib/kdump-lib.sh
-if [ -f "$initdir/lib/dracut/no-emergency-shell" ]; then - rm -f -- $initdir/lib/dracut/no-emergency-shell -fi - set -o pipefail export PATH=$PATH:$KDUMP_SCRIPT_DIR
On 06/17/14 at 03:08pm, WANG Chao wrote:
dracut-emergency.service is conflicting with emergency.service:
"Conflicts=emergency.service emergency.target"
We should always disable dracut-emergency.service. Because if it gets started, our emergency.service will be interrupted and stopped.
And also dracut-emergency.service isn't useful now, since we introduced our own error handler.
Signed-off-by: WANG Chao chaowang@redhat.com
dracut-kdump.sh | 4 ---- 1 file changed, 4 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index d092e04..eb4ab42 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -4,10 +4,6 @@ exec &> /dev/console . /lib/dracut-lib.sh . /lib/kdump-lib.sh
-if [ -f "$initdir/lib/dracut/no-emergency-shell" ]; then
- rm -f -- $initdir/lib/dracut/no-emergency-shell
-fi
set -o pipefail export PATH=$PATH:$KDUMP_SCRIPT_DIR
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 06/17/14 at 03:07pm, WANG Chao wrote:
Hi, All
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.
WANG Chao (6): mkdumprd: mount dump target under /sysroot in 2nd kernel mkdumprd: append "x-initrd.mount" to the mount options. cleanup: extract functions from kdump.sh to kdump-lib-2.sh Introduce kdump error handling service Introduce kdump capture service disable dracut-emergency.service the whole time
dracut-kdump-capture.service | 23 ++++++ dracut-kdump-emergency.service | 23 ++++++ dracut-kdump-error-handler.sh | 10 +++ dracut-kdump-lib-2.sh | 160 ++++++++++++++++++++++++++++++++++++++++ dracut-kdump.sh | 161 +---------------------------------------- dracut-module-setup.sh | 8 +- kdump-lib.sh | 6 +- kexec-tools.spec | 9 ++- mkdumprd | 25 ++++--- 9 files changed, 253 insertions(+), 172 deletions(-) create mode 100644 dracut-kdump-capture.service create mode 100644 dracut-kdump-emergency.service create mode 100755 dracut-kdump-error-handler.sh create mode 100755 dracut-kdump-lib-2.sh
I think it will be better to get idea from systemd people, especially for 2/6, 4/6, and 5/6.
Not sure who is the right people to ask for help. I'm adding Harald..
Thanks Dave
On 07/08/14 at 10:37am, Dave Young wrote:
On 06/17/14 at 03:07pm, WANG Chao wrote:
Hi, All
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.
WANG Chao (6): mkdumprd: mount dump target under /sysroot in 2nd kernel mkdumprd: append "x-initrd.mount" to the mount options. cleanup: extract functions from kdump.sh to kdump-lib-2.sh Introduce kdump error handling service Introduce kdump capture service disable dracut-emergency.service the whole time
dracut-kdump-capture.service | 23 ++++++ dracut-kdump-emergency.service | 23 ++++++ dracut-kdump-error-handler.sh | 10 +++ dracut-kdump-lib-2.sh | 160 ++++++++++++++++++++++++++++++++++++++++ dracut-kdump.sh | 161 +---------------------------------------- dracut-module-setup.sh | 8 +- kdump-lib.sh | 6 +- kexec-tools.spec | 9 ++- mkdumprd | 25 ++++--- 9 files changed, 253 insertions(+), 172 deletions(-) create mode 100644 dracut-kdump-capture.service create mode 100644 dracut-kdump-emergency.service create mode 100755 dracut-kdump-error-handler.sh create mode 100755 dracut-kdump-lib-2.sh
I think it will be better to get idea from systemd people, especially for 2/6, 4/6, and 5/6.
Not sure who is the right people to ask for help. I'm adding Harald..
Hi, Harald
The error handler path is a pain for us, appreciate if you can give some idea or comments.
The action_on_fail code in dracut can probably be dropped after this error handler stuff is settle down.
Thanks Dave
On Tue, Jun 17, 2014 at 03:07:56PM +0800, WANG Chao wrote:
Hi, All
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.
Hi Chao,
I think also mention the problem description here. I think you are doing this patch series in response to a problem. And IIRC, problem was that now upon failure kdump script might not be called at all and it might not be able to execute default action.
IIRC, system tries to run emergency shell but we have disabled emergecny shell so it hangs.
So let us first describe the problem and then explain how you are plannig to solve. And how creating a separate emergency service helps.
That way if we are reading it back 6 months down the line, we will get all the context back easily.
Also make sure all that text shows up in your first patch when you commit it in git tree.
Thanks Vivek
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.
WANG Chao (6): mkdumprd: mount dump target under /sysroot in 2nd kernel mkdumprd: append "x-initrd.mount" to the mount options. cleanup: extract functions from kdump.sh to kdump-lib-2.sh Introduce kdump error handling service Introduce kdump capture service disable dracut-emergency.service the whole time
dracut-kdump-capture.service | 23 ++++++ dracut-kdump-emergency.service | 23 ++++++ dracut-kdump-error-handler.sh | 10 +++ dracut-kdump-lib-2.sh | 160 ++++++++++++++++++++++++++++++++++++++++ dracut-kdump.sh | 161 +---------------------------------------- dracut-module-setup.sh | 8 +- kdump-lib.sh | 6 +- kexec-tools.spec | 9 ++- mkdumprd | 25 ++++--- 9 files changed, 253 insertions(+), 172 deletions(-) create mode 100644 dracut-kdump-capture.service create mode 100644 dracut-kdump-emergency.service create mode 100755 dracut-kdump-error-handler.sh create mode 100755 dracut-kdump-lib-2.sh
-- 1.9.3