Fedora dracut-044-75 release has all the component needed to support initrd rebuild in case of watchdog state change. Therefore sending these patches for inclusion in kexec-tools.
Please note that these patches should only be added in those fedora versions which has dracut version dracut-044-75 or latter. Anyway, we already have dependency specified in spec file as well.
Testing: Most of the rebuild test cases have been mentioned in the commit log of 2/5. Other than that, I have also tested effect of adding either "-o watchdog" or "-a watchdog" or none of them. They have been found to behave as expected. So, when we pass -o watchdog in dracut_args, it does not include kernel watchdog module whether state is active or inactive. In all other cases, it adds kernel module only when state is active. I have also verified that dracut watchdog module is not added when we do not have at least one active watchdog device.
Changes since V5: - fixes watchdog module removal in case more than one device Changes since V4: - When a watchdog was active previously but now watchdog kernel module does not exists then rebuild initrd - When there is not any active watchdog device then do not add "-a watchdog". - Updated howto file accordingly.
Changes since V3: - Now we only look for "-o watchdog" in dracut_args. If it is not passed then we add "-a watchdog" in dracut_args by default. - Notes in howto modified accordingly
Changes since V2: - Removed NOWDT argument. Using dracut_args instead. - Removed man page update. Included notes in howto - Reorganized mkdumprd code for watchdog dracut argument addition
Changes since V1: - Removed patch 4/5 which was updating kdumpctl man page. - Added all necessary information in kdump.conf man page (patch 2/4).
Pratyush Anand (5): mkdumprd: Add dracut watchdog module as default option kdumpctl: force rebuild in case of watchdog state change howto: Notes on watchdog module handling watchdog: do not add watchdog module in rd.driver.pre now spec: Update to add dependency on dracut version >= 044-75
dracut-module-setup.sh | 9 --------- kdump-lib.sh | 24 ++++++++++++++++++++++++ kdumpctl | 40 ++++++++++++++++++++++++++++++++++++++++ kexec-kdump-howto.txt | 14 ++++++++++++++ kexec-tools.spec | 3 ++- mkdumprd | 20 +++++++++++++++++++- 6 files changed, 99 insertions(+), 11 deletions(-)
If dracut watchdog module is enabled then, it includes kernel watchdog module of active watchdog device in initramfs.
kdump.conf has an option to modify dracut_args. So, if an user passes "-a watchdog" in dracut_args then dracut will add kernel watchdog module of active watchdog device in initramfs.
Since, kexec-tools always requires to add kernel watchdog module of active watchdog device in initramfs, therefore even when an user does not pass any watchdog option and there exists at least one active watchdog device then also kexec-tools adds "-a watchdog" in dracut args.
Therefore, if an user does not want to add kernel watchdog module in initramfs then the person must pass "-o watchdog" in dracut_args.
Signed-off-by: Pratyush Anand panand@redhat.com Acked-by: Dave Young dyoung@redhat.com --- kdump-lib.sh | 24 ++++++++++++++++++++++++ mkdumprd | 20 +++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 141a5614f1d5..4567a05edbbe 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -382,3 +382,27 @@ get_ifcfg_filename() {
echo -n "${ifcfg_file}" } + +# returns 0 when omission of watchdog module is desired in dracut_args +# returns 1 otherwise +is_wdt_mod_omitted() { + local dracut_args + local ret=1 + + dracut_args=$(grep "^dracut_args" /etc/kdump.conf) + [[ -z $dracut_args ]] && return $ret + + eval set -- $dracut_args + while :; do + [[ -z $1 ]] && break + case $1 in + -o|--omit) + echo $2 | grep -qw "watchdog" + [[ $? == 0 ]] && ret=0 + break + esac + shift + done + + return $ret +} diff --git a/mkdumprd b/mkdumprd index eb0d5e06fac9..27916131ecfc 100644 --- a/mkdumprd +++ b/mkdumprd @@ -16,8 +16,26 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /)
+is_wdt_addition_needed() { + local active + + is_wdt_mod_omitted + [[ $? -eq 0 ]] && return 1 + [[ -d /sys/class/watchdog/ ]] || return 1 + for dir in /sys/class/watchdog/*; do + [[ -f "$dir/state" ]] || continue + active=$(< "$dir/state") + [[ "$active" = "active" ]] && return 0 + done + return 1 +} + +WDTCFG="" +is_wdt_addition_needed +[[ $? -eq 0 ]] && WDTCFG="-a watchdog" + extra_modules="" -dracut_args=("--hostonly" "-o" "plymouth dash resume ifcfg") +dracut_args=("--hostonly" "-o" "plymouth dash resume ifcfg" $WDTCFG) OVERRIDE_RESETTABLE=0
add_dracut_arg() {
If state of a watchdog device is changed by an user after kdumpctl restart then initramfs must be rebuilt on the basis of new watchdog status.
Testing: ------------------------------------------------------- Initramfs wdt state Prev Current Result ------------------------------------------------------- Not Exist NA X Rebuild Exist Inact Inact No Rebuild Exist Inact Act Force Rebuild Exist Act Inact Force Rebuild Exist Act Act(Same wdt) No Rebuild Exist Act Act(Diff wdt) Force Rebuild Exist Act Module Removed Force Rebuild
Signed-off-by: Pratyush Anand panand@redhat.com Acked-by: Dave Young dyoung@redhat.com --- kdumpctl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/kdumpctl b/kdumpctl index c8fc54fc7677..0436bfc6c73b 100755 --- a/kdumpctl +++ b/kdumpctl @@ -427,6 +427,40 @@ check_dump_fs_modified() return 1 }
+check_wdt_modified() +{ + is_wdt_mod_omitted + [[ $? -eq 0 ]] && return 0 + [[ -d /sys/class/watchdog/ ]] || return 0 + + for dir in /sys/class/watchdog/*; do + [[ -d "$dir" ]] || continue + [[ -f "$dir/state" ]] || continue + wdtdrv=$(< "$dir/device/modalias") + wdtdrv=$(modinfo $wdtdrv | grep filename | awk -F"kernel/" '{print $2}') + active=$(< "$dir/state") + # rebuild when: + # module for this watchdog is not found and watchdog is active + # module for this watchdog is found and watchdog is inactive + lsinitrd $TARGET_INITRD | grep $wdtdrv &> /dev/null + if [ $? -ne 0 ]; then + [[ "$active" = "active" ]] && return 1 + else + [[ "$active" = "inactive" ]] && return 1 + fi + done + + # check if watchdog kernel module unloaded. + loaded_mods=$(lsinitrd $TARGET_INITRD -f etc/cmdline.d/00-watchdog.conf) + [[ -n $loaded_mods ]] && loaded_mods=$(echo $loaded_mods | awk -F"rd.driver.pre=" '{print $2}' | sed "s/,/ /g") + for mod in $loaded_mods ; do + lsmod | grep $mod &> /dev/null + [[ $? != 0 ]] && return 1 + done + + return 0 +} + # returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid @@ -448,6 +482,12 @@ check_system_modified() return $ret fi
+ check_wdt_modified + if [ $? -ne 0 ]; then + echo "Detected change in watchdog state" + return 1 + fi + return 0 }
On 2016/07/21 at 02:12, Pratyush Anand wrote:
If state of a watchdog device is changed by an user after kdumpctl restart then initramfs must be rebuilt on the basis of new watchdog status.
Testing:
Initramfs wdt state Prev Current Result
Not Exist NA X Rebuild Exist Inact Inact No Rebuild Exist Inact Act Force Rebuild Exist Act Inact Force Rebuild Exist Act Act(Same wdt) No Rebuild Exist Act Act(Diff wdt) Force Rebuild Exist Act Module Removed Force Rebuild
Signed-off-by: Pratyush Anand panand@redhat.com Acked-by: Dave Young dyoung@redhat.com
kdumpctl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/kdumpctl b/kdumpctl index c8fc54fc7677..0436bfc6c73b 100755 --- a/kdumpctl +++ b/kdumpctl @@ -427,6 +427,40 @@ check_dump_fs_modified() return 1 }
+check_wdt_modified() +{
- is_wdt_mod_omitted
- [[ $? -eq 0 ]] && return 0
- [[ -d /sys/class/watchdog/ ]] || return 0
- for dir in /sys/class/watchdog/*; do
[[ -d "$dir" ]] || continue
[[ -f "$dir/state" ]] || continue
wdtdrv=$(< "$dir/device/modalias")
wdtdrv=$(modinfo $wdtdrv | grep filename | awk -F"kernel/" '{print $2}')
active=$(< "$dir/state")
# rebuild when:
# module for this watchdog is not found and watchdog is active
# module for this watchdog is found and watchdog is inactive
lsinitrd $TARGET_INITRD | grep $wdtdrv &> /dev/null
if [ $? -ne 0 ]; then
[[ "$active" = "active" ]] && return 1
else
[[ "$active" = "inactive" ]] && return 1
fi
- done
- # check if watchdog kernel module unloaded.
- loaded_mods=$(lsinitrd $TARGET_INITRD -f etc/cmdline.d/00-watchdog.conf)
- [[ -n $loaded_mods ]] && loaded_mods=$(echo $loaded_mods | awk -F"rd.driver.pre=" '{print $2}' | sed "s/,/ /g")
- for mod in $loaded_mods ; do
lsmod | grep $mod &> /dev/null
[[ $? != 0 ]] && return 1
done
I think this can work pretty well: - For modules loaded but state changes cases, we can catch it by the state checking above, - For modules unloaded cases, "lsmod | grep $mod" will surely catch it.
Regards, Xunlei
- return 0
+}
# returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid @@ -448,6 +482,12 @@ check_system_modified() return $ret fi
- check_wdt_modified
- if [ $? -ne 0 ]; then
echo "Detected change in watchdog state"
return 1
- fi
- return 0
}
On 2016/07/21 at 02:12, Pratyush Anand wrote:
If state of a watchdog device is changed by an user after kdumpctl restart then initramfs must be rebuilt on the basis of new watchdog status.
Testing:
Initramfs wdt state Prev Current Result
Not Exist NA X Rebuild Exist Inact Inact No Rebuild Exist Inact Act Force Rebuild Exist Act Inact Force Rebuild Exist Act Act(Same wdt) No Rebuild Exist Act Act(Diff wdt) Force Rebuild Exist Act Module Removed Force Rebuild
Signed-off-by: Pratyush Anand panand@redhat.com Acked-by: Dave Young dyoung@redhat.com
kdumpctl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/kdumpctl b/kdumpctl index c8fc54fc7677..0436bfc6c73b 100755 --- a/kdumpctl +++ b/kdumpctl @@ -427,6 +427,40 @@ check_dump_fs_modified() return 1 }
+check_wdt_modified() +{
- is_wdt_mod_omitted
- [[ $? -eq 0 ]] && return 0
- [[ -d /sys/class/watchdog/ ]] || return 0
- for dir in /sys/class/watchdog/*; do
[[ -d "$dir" ]] || continue
[[ -f "$dir/state" ]] || continue
wdtdrv=$(< "$dir/device/modalias")
wdtdrv=$(modinfo $wdtdrv | grep filename | awk -F"kernel/" '{print $2}')
active=$(< "$dir/state")
# rebuild when:
# module for this watchdog is not found and watchdog is active
# module for this watchdog is found and watchdog is inactive
lsinitrd $TARGET_INITRD | grep $wdtdrv &> /dev/null
if [ $? -ne 0 ]; then
[[ "$active" = "active" ]] && return 1
else
[[ "$active" = "inactive" ]] && return 1
fi
- done
- # check if watchdog kernel module unloaded.
- loaded_mods=$(lsinitrd $TARGET_INITRD -f etc/cmdline.d/00-watchdog.conf)
- [[ -n $loaded_mods ]] && loaded_mods=$(echo $loaded_mods | awk -F"rd.driver.pre=" '{print $2}' | sed "s/,/ /g")
- for mod in $loaded_mods ; do
lsmod | grep $mod &> /dev/null
[[ $? != 0 ]] && return 1
done
[nitpick] mis-indented code.
- return 0
+}
# returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid @@ -448,6 +482,12 @@ check_system_modified() return $ret fi
- check_wdt_modified
- if [ $? -ne 0 ]; then
echo "Detected change in watchdog state"
return 1
- fi
- return 0
}
Update howto with notes on dracut and kernel watchdog module handling.
Signed-off-by: Pratyush Anand panand@redhat.com Acked-by: Dave Young dyoung@redhat.com --- kexec-kdump-howto.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index b4cdc2227f1d..38f831e8acfb 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -616,6 +616,20 @@ options are copied from /proc/cmdline. In general it is best to append command line options using "KDUMP_COMMANDLINE_APPEND=" instead of replacing the original command line completely.
+Notes on watchdog module handling: + +If a watchdog is active in first kernel then, we must have it's module +loaded in crash kernel, so that either watchdog is deactivated or started +being kicked in second kernel. Otherwise, we might face watchdog reboot +when vmcore is being saved. When dracut watchdog module is enabled, it +installs kernel watchdog module of active watchdog device in initrd. +kexec-tools always add "-a watchdog" to the dracut_args if there exists at +least one active watchdog and user has not added specifically "-o watchdog" +in dracut_args of kdump.conf. If a watchdog module (such as hp_wdt) has +not been written in watchdog-core framework then this option will not have +any effect and module will not be added. Please note that only systemd +watchdog daemon is supported as watchdog kick application. + Parallel Dumping Operation ========================== Kexec allows kdump using multiple cpus. So parallel feature can accelerate
Now dracut takes care to add module for active watchdog. Therefore we do not need to pass iTCO_wdt and lpc_ich module in rd.driver.pre specifically here.
Signed-off-by: Pratyush Anand panand@redhat.com Acked-by: Dave Young dyoung@redhat.com --- dracut-module-setup.sh | 9 --------- 1 file changed, 9 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index aa204f871e25..f5c0218b36ed 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -729,12 +729,3 @@ install() { # at some point of time. kdump_check_iscsi_targets } - -installkernel() { - wdt=$(lsmod|cut -f1 -d' '|grep "wdt$") - if [ -n "$wdt" ]; then - [ "$wdt" = "iTCO_wdt" ] && instmods lpc_ich && - echo "rd.driver.pre=lpc_ich,iTCO_wdt " >> ${initdir}/etc/cmdline.d/00-wdt.conf - instmods $wdt - fi -}
Fedora dracut version >= 044-75 must be installed to work with this set of kexec-tools patches. Therefore adding dependency for them.
Signed-off-by: Pratyush Anand panand@redhat.com Acked-by: Dave Young dyoung@redhat.com --- kexec-tools.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kexec-tools.spec b/kexec-tools.spec index 312965039ffc..b171e8c77d19 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -45,7 +45,8 @@ Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units Requires(pre): coreutils sed zlib -Requires: dracut, dracut-network, ethtool +Requires: dracut >= 044-75 +Requires: dracut-network, ethtool BuildRequires: zlib-devel zlib zlib-static elfutils-devel-static glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-units
Oh, Sorry, Kindly treat it as V6.
On 20/07/2016:11:42:19 PM, Pratyush Anand wrote:
Fedora dracut-044-75 release has all the component needed to support initrd rebuild in case of watchdog state change. Therefore sending these patches for inclusion in kexec-tools.
Please note that these patches should only be added in those fedora versions which has dracut version dracut-044-75 or latter. Anyway, we already have dependency specified in spec file as well.
Testing: Most of the rebuild test cases have been mentioned in the commit log of 2/5. Other than that, I have also tested effect of adding either "-o watchdog" or "-a watchdog" or none of them. They have been found to behave as expected. So, when we pass -o watchdog in dracut_args, it does not include kernel watchdog module whether state is active or inactive. In all other cases, it adds kernel module only when state is active. I have also verified that dracut watchdog module is not added when we do not have at least one active watchdog device.
Changes since V5:
- fixes watchdog module removal in case more than one device
Changes since V4:
- When a watchdog was active previously but now watchdog kernel module does not exists then rebuild initrd
- When there is not any active watchdog device then do not add "-a watchdog".
- Updated howto file accordingly.
Changes since V3:
- Now we only look for "-o watchdog" in dracut_args. If it is not passed then we add "-a watchdog" in dracut_args by default.
- Notes in howto modified accordingly
Changes since V2:
- Removed NOWDT argument. Using dracut_args instead.
- Removed man page update. Included notes in howto
- Reorganized mkdumprd code for watchdog dracut argument addition
Changes since V1:
- Removed patch 4/5 which was updating kdumpctl man page.
- Added all necessary information in kdump.conf man page (patch 2/4).
Pratyush Anand (5): mkdumprd: Add dracut watchdog module as default option kdumpctl: force rebuild in case of watchdog state change howto: Notes on watchdog module handling watchdog: do not add watchdog module in rd.driver.pre now spec: Update to add dependency on dracut version >= 044-75
dracut-module-setup.sh | 9 --------- kdump-lib.sh | 24 ++++++++++++++++++++++++ kdumpctl | 40 ++++++++++++++++++++++++++++++++++++++++ kexec-kdump-howto.txt | 14 ++++++++++++++ kexec-tools.spec | 3 ++- mkdumprd | 20 +++++++++++++++++++- 6 files changed, 99 insertions(+), 11 deletions(-)
-- 2.5.5
On 2016/07/21 at 02:15, Pratyush Anand wrote:
Oh, Sorry, Kindly treat it as V6.
Acked-by: Xunlei Pang xlpang@redhat.com
On 20/07/2016:11:42:19 PM, Pratyush Anand wrote:
Fedora dracut-044-75 release has all the component needed to support initrd rebuild in case of watchdog state change. Therefore sending these patches for inclusion in kexec-tools.
Please note that these patches should only be added in those fedora versions which has dracut version dracut-044-75 or latter. Anyway, we already have dependency specified in spec file as well.
Testing: Most of the rebuild test cases have been mentioned in the commit log of 2/5. Other than that, I have also tested effect of adding either "-o watchdog" or "-a watchdog" or none of them. They have been found to behave as expected. So, when we pass -o watchdog in dracut_args, it does not include kernel watchdog module whether state is active or inactive. In all other cases, it adds kernel module only when state is active. I have also verified that dracut watchdog module is not added when we do not have at least one active watchdog device.
Changes since V5:
- fixes watchdog module removal in case more than one device
Changes since V4:
- When a watchdog was active previously but now watchdog kernel module does not exists then rebuild initrd
- When there is not any active watchdog device then do not add "-a watchdog".
- Updated howto file accordingly.
Changes since V3:
- Now we only look for "-o watchdog" in dracut_args. If it is not passed then we add "-a watchdog" in dracut_args by default.
- Notes in howto modified accordingly
Changes since V2:
- Removed NOWDT argument. Using dracut_args instead.
- Removed man page update. Included notes in howto
- Reorganized mkdumprd code for watchdog dracut argument addition
Changes since V1:
- Removed patch 4/5 which was updating kdumpctl man page.
- Added all necessary information in kdump.conf man page (patch 2/4).
Pratyush Anand (5): mkdumprd: Add dracut watchdog module as default option kdumpctl: force rebuild in case of watchdog state change howto: Notes on watchdog module handling watchdog: do not add watchdog module in rd.driver.pre now spec: Update to add dependency on dracut version >= 044-75
dracut-module-setup.sh | 9 --------- kdump-lib.sh | 24 ++++++++++++++++++++++++ kdumpctl | 40 ++++++++++++++++++++++++++++++++++++++++ kexec-kdump-howto.txt | 14 ++++++++++++++ kexec-tools.spec | 3 ++- mkdumprd | 20 +++++++++++++++++++- 6 files changed, 99 insertions(+), 11 deletions(-)
-- 2.5.5
On 07/20/16 at 11:42pm, Pratyush Anand wrote:
Fedora dracut-044-75 release has all the component needed to support initrd rebuild in case of watchdog state change. Therefore sending these patches for inclusion in kexec-tools.
Please note that these patches should only be added in those fedora versions which has dracut version dracut-044-75 or latter. Anyway, we already have dependency specified in spec file as well.
Testing: Most of the rebuild test cases have been mentioned in the commit log of 2/5. Other than that, I have also tested effect of adding either "-o watchdog" or "-a watchdog" or none of them. They have been found to behave as expected. So, when we pass -o watchdog in dracut_args, it does not include kernel watchdog module whether state is active or inactive. In all other cases, it adds kernel module only when state is active. I have also verified that dracut watchdog module is not added when we do not have at least one active watchdog device.
Changes since V5:
- fixes watchdog module removal in case more than one device
Changes since V4:
- When a watchdog was active previously but now watchdog kernel module does not exists then rebuild initrd
- When there is not any active watchdog device then do not add "-a watchdog".
- Updated howto file accordingly.
Changes since V3:
- Now we only look for "-o watchdog" in dracut_args. If it is not passed then we add "-a watchdog" in dracut_args by default.
- Notes in howto modified accordingly
Changes since V2:
- Removed NOWDT argument. Using dracut_args instead.
- Removed man page update. Included notes in howto
- Reorganized mkdumprd code for watchdog dracut argument addition
Changes since V1:
- Removed patch 4/5 which was updating kdumpctl man page.
- Added all necessary information in kdump.conf man page (patch 2/4).
Pratyush Anand (5): mkdumprd: Add dracut watchdog module as default option kdumpctl: force rebuild in case of watchdog state change howto: Notes on watchdog module handling watchdog: do not add watchdog module in rd.driver.pre now spec: Update to add dependency on dracut version >= 044-75
dracut-module-setup.sh | 9 --------- kdump-lib.sh | 24 ++++++++++++++++++++++++ kdumpctl | 40 ++++++++++++++++++++++++++++++++++++++++ kexec-kdump-howto.txt | 14 ++++++++++++++ kexec-tools.spec | 3 ++- mkdumprd | 20 +++++++++++++++++++- 6 files changed, 99 insertions(+), 11 deletions(-)
-- 2.5.5
Applied in rawhide branch, but forgot to add Acked-by :(
Thanks Dave