On 07/20/16 at 12:40pm, Pratyush Anand wrote:
On Wed, Jul 20, 2016 at 12:09 PM, Xunlei Pang
<xpang(a)redhat.com> wrote:
> On 2016/07/20 at 11:50, 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(a)redhat.com>
>> Acked-by: Dave Young <dyoung(a)redhat.com>
>> ---
>> kdumpctl | 36 ++++++++++++++++++++++++++++++++++++
>> 1 file changed, 36 insertions(+)
>>
>> diff --git a/kdumpctl b/kdumpctl
>> index c8fc54fc7677..696a07beb12e 100755
>> --- a/kdumpctl
>> +++ b/kdumpctl
>> @@ -427,6 +427,36 @@ 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.
>> + ls /dev/watchdog* &> /dev/null
>> + [[ $? != 0 ]] && [[ -n $(lsinitrd $TARGET_INITRD -f
etc/cmdline.d/00-watchdog.conf) ]] && return 1
>
> For example, there are two watchdogs on my laptop, and only watchdog0 is active,
> if I deactivate and unload watchdog0, then it will miss(as /dev/watchdog1 exists).
Humm..Probably following should be better then:
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 remember systemd only support /dev/watchdog, no?
If so we probably can consider these cases later since we consider systemd.
>
> >
> > But this should be a very corner case.
>
> Still, I would like to fix it.
>
> Thanks for your input.
>
> ~Pratyush