Skip to content

Commit b4452ed

Browse files
sujinmkangqiluo-msft
authored andcommitted
Add disabling HW watchdog during boot for fast-reboot and warm-reboot (sonic-net#4927)
* Add disabling HW watchdog during boot for fast-reboot and warm-reboot case * typo
1 parent 2731571 commit b4452ed

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

files/build_templates/sonic_debian_extension.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ sudo LANG=C cp $IMAGE_CONFIGS/warmboot-finalizer/finalize-warmboot.sh $FILESYSTE
237237
sudo LANG=C cp $IMAGE_CONFIGS/warmboot-finalizer/warmboot-finalizer.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
238238
echo "warmboot-finalizer.service" | sudo tee -a $GENERATED_SERVICE_FILE
239239

240+
# Copy watchdog-control files
241+
sudo LANG=C cp $IMAGE_CONFIGS/watchdog-control/watchdog-control.sh $FILESYSTEM_ROOT/usr/local/bin/watchdog-control.sh
242+
sudo LANG=C cp $IMAGE_CONFIGS/watchdog-control/watchdog-control.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
243+
echo "watchdog-control.service" | sudo tee -a $GENERATED_SERVICE_FILE
244+
240245
# Copy rsyslog configuration files and templates
241246
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
242247
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.sh $FILESYSTEM_ROOT/usr/bin/
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=watchdog control service
3+
After=swss.service
4+
5+
[Service]
6+
Type=simple
7+
ExecStart=/usr/local/bin/watchdog-control.sh
8+
9+
[Install]
10+
WantedBy=multi-user.target
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#! /bin/bash
2+
3+
VERBOSE=no
4+
WATCHDOG_UTIL="/usr/bin/watchdogutil"
5+
6+
function debug()
7+
{
8+
/usr/bin/logger "$0 : $1"
9+
if [[ x"${VERBOSE}" == x"yes" ]]; then
10+
echo "$(date) $0: $1"
11+
fi
12+
}
13+
14+
15+
function getBootType()
16+
{
17+
# same code snippet in files/scripts/syncd.sh
18+
case "$(cat /proc/cmdline)" in
19+
*SONIC_BOOT_TYPE=warm*)
20+
TYPE='warm'
21+
;;
22+
*SONIC_BOOT_TYPE=fastfast*)
23+
TYPE='fastfast'
24+
;;
25+
*SONIC_BOOT_TYPE=fast*|*fast-reboot*)
26+
TYPE='fast'
27+
;;
28+
*)
29+
TYPE='cold'
30+
esac
31+
echo "${TYPE}"
32+
}
33+
34+
function disable_watchdog()
35+
{
36+
# Obtain boot type from kernel arguments
37+
BOOT_TYPE=`getBootType`
38+
if [[ -x ${WATCHDOG_UTIL} ]]; then
39+
debug "Disabling Watchdog during bootup after $BOOT_TYPE"
40+
${WATCHDOG_UTIL} disarm
41+
fi
42+
}
43+
44+
disable_watchdog

src/sonic-utilities

0 commit comments

Comments
 (0)