From b4452edb8a26237a1100f85d9d6b5bcc64ea3f67 Mon Sep 17 00:00:00 2001 From: Sujin Kang Date: Thu, 9 Jul 2020 16:14:06 -0700 Subject: [PATCH] Add disabling HW watchdog during boot for fast-reboot and warm-reboot (#4927) * Add disabling HW watchdog during boot for fast-reboot and warm-reboot case * typo --- .../build_templates/sonic_debian_extension.j2 | 5 +++ .../watchdog-control/watchdog-control.service | 10 +++++ .../watchdog-control/watchdog-control.sh | 44 +++++++++++++++++++ src/sonic-utilities | 2 +- 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 files/image_config/watchdog-control/watchdog-control.service create mode 100755 files/image_config/watchdog-control/watchdog-control.sh diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 737ce1271f..7c269ad29a 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -237,6 +237,11 @@ sudo LANG=C cp $IMAGE_CONFIGS/warmboot-finalizer/finalize-warmboot.sh $FILESYSTE sudo LANG=C cp $IMAGE_CONFIGS/warmboot-finalizer/warmboot-finalizer.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM echo "warmboot-finalizer.service" | sudo tee -a $GENERATED_SERVICE_FILE +# Copy watchdog-control files +sudo LANG=C cp $IMAGE_CONFIGS/watchdog-control/watchdog-control.sh $FILESYSTEM_ROOT/usr/local/bin/watchdog-control.sh +sudo LANG=C cp $IMAGE_CONFIGS/watchdog-control/watchdog-control.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM +echo "watchdog-control.service" | sudo tee -a $GENERATED_SERVICE_FILE + # Copy rsyslog configuration files and templates sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.sh $FILESYSTEM_ROOT/usr/bin/ diff --git a/files/image_config/watchdog-control/watchdog-control.service b/files/image_config/watchdog-control/watchdog-control.service new file mode 100644 index 0000000000..579e645e24 --- /dev/null +++ b/files/image_config/watchdog-control/watchdog-control.service @@ -0,0 +1,10 @@ +[Unit] +Description=watchdog control service +After=swss.service + +[Service] +Type=simple +ExecStart=/usr/local/bin/watchdog-control.sh + +[Install] +WantedBy=multi-user.target diff --git a/files/image_config/watchdog-control/watchdog-control.sh b/files/image_config/watchdog-control/watchdog-control.sh new file mode 100755 index 0000000000..b26fea03f1 --- /dev/null +++ b/files/image_config/watchdog-control/watchdog-control.sh @@ -0,0 +1,44 @@ +#! /bin/bash + +VERBOSE=no +WATCHDOG_UTIL="/usr/bin/watchdogutil" + +function debug() +{ + /usr/bin/logger "$0 : $1" + if [[ x"${VERBOSE}" == x"yes" ]]; then + echo "$(date) $0: $1" + fi +} + + +function getBootType() +{ + # same code snippet in files/scripts/syncd.sh + case "$(cat /proc/cmdline)" in + *SONIC_BOOT_TYPE=warm*) + TYPE='warm' + ;; + *SONIC_BOOT_TYPE=fastfast*) + TYPE='fastfast' + ;; + *SONIC_BOOT_TYPE=fast*|*fast-reboot*) + TYPE='fast' + ;; + *) + TYPE='cold' + esac + echo "${TYPE}" +} + +function disable_watchdog() +{ + # Obtain boot type from kernel arguments + BOOT_TYPE=`getBootType` + if [[ -x ${WATCHDOG_UTIL} ]]; then + debug "Disabling Watchdog during bootup after $BOOT_TYPE" + ${WATCHDOG_UTIL} disarm + fi +} + +disable_watchdog diff --git a/src/sonic-utilities b/src/sonic-utilities index 16a33f2fb6..9715244d71 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 16a33f2fb67e9da15ecc7780daa6b15408665539 +Subproject commit 9715244d715ca08b54595364c0386111bce7ef02