Hi, Pratyush
On 07/05/16 at 11:41am, 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
Signed-off-by: Pratyush Anand <panand(a)redhat.com>
---
kdumpctl | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/kdumpctl b/kdumpctl
index c8fc54fc7677..12e7aa005c5d 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -427,6 +427,32 @@ check_dump_fs_modified()
return 1
}
+check_wdt_modified()
+{
+ NOWDT=$(grep ^nowdt $KDUMP_CONFIG_FILE | cut -d' ' -f2)
+ [[ -z $NOWDT ]] || 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
+
+ return 0
+}
+
# returns 0 if system is not modified
# returns 1 if system is modified
# returns 2 if system modification is invalid
@@ -448,6 +474,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
}
--
2.5.5
_______________________________________________
kexec mailing list
kexec(a)lists.fedoraproject.org
https://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
I feel it is too smart, but I can not give a reason to object it :)
Just a little worry about in the future check_rebuild will become
even more complex..
Acked-by: Dave Young <dyoung(a)redhat.com>
Thanks
Dave