The QNX Hypervisor provides virtual watchdog devices that you can use in a VM just as you would a hardware watchdog on a board in a non-hypervisor system.
The QNX Hypervisor is a QNX Neutrino OS microkernel plus virtualization support. As such, it provides the same support for a watchdog as the microkernel of which it is a superset. You can use a board-specific utility to kick the hardware watchdog, and use the High Availability Manager (HAM) to manage the host in the event that a watchdog detects an anomaly in the host's behavior (see ham in the QNX Neutrino OS Utilities Reference).
To learn more about watchdogs in QNX systems, see the OS Core Components documentation; to learn more about your board-specific watchdog kicker utility, see your board's BSP User's Guide.
The watchdog vdevs implemented with the QNX Hypervisor emulate a hardware watchdog in a VM. A watchdog kicker utility (see wdtkick in the Utilities and Drivers Reference chapter) running in the guest enables its virtual hardware watchdog, then writes at specific intervals to guest-physical registers monitored by the watchdog vdev to inform the watchdog that the guest is running (it kicks the watchdog).
If the watchdog kicker fails to write to the registers within the required delay, the watchdog vdev triggers a SIGQUIT to force the qvm process instance in which it is running (and which is hosting the misbehaving guest) to perform an orderly termination.
Since the qvm process is a QNX Neutrino OS process, you can trap its exit codes just as you do for any OS process (see the QNX Neutrino OS documentation). If you are implementing a watchdog service for your guests, you should configure your hypervisor host to trap the qvm process exit codes so you can decide what you want the host to do in the event that a qvm process instance terminates unexpectedly. These actions can range from simply logging the error and waiting for user intervention, to using the High Availability Manager to attempt to restart the qvm process and its guest OS.
To implement a watchdog service in a QNX guest running in a QNX Hypervisor VM, you need to:
Implement a watchdog kicker in the guest, and configure it to kick the watchdog vdev (for QNX Neutrino OS guests the kicker is provided in the BSP, see QNX guest watchdog kicker (wdtkick) below).
For Linux and Android guests, see Implementing a watchdog in a Linux or Android guest below.
The watchdog vdevs emulate a subset of the functions provided by hardware watchdogs. Refer to the chip documentation for information about your hardware watchdog (e.g., the SP805 documentation at the ARM Documentation Center).
The QNX Hypervisor BSP includes scripts for starting and stopping watchdogs in your QNX guests. These are located in the BSP's scripts directory:
To start or stop your watchdog vdev and the kicker in the QNX guest, run either watchdog-start.sh or watchdog-stop.sh, as appropriate.
The wdtkick watchdog kicker (wdtkick-generic for QNX Neutrino OS 6.6 guests) is board-specific for QNX guests in a QNX Hypervisor system (see wdtkick in the Utilities and Drivers Reference chapter). It is shipped in the BSPs for supported boards. For hypervisor systems, it is included in the BSPs for QNX guests at hardware/support/wdtkick.
The buildfiles for the QNX guests made available with the hypervisor include commented out sections with configurations for wdtkick. To use these utilities, you can uncomment these files and rebuild your guest.
For reference, below are examples of wdtkick configurations for ARM and for x86 guests.
Kick the watchdog every second (1), and set the timeout period to three (3) seconds, which in fact translates to six (6) seconds because the timer on ARM platforms counts down twice and asserts the reset only on the second timer expiry:
wdtkick -v -a 0x1C0F0000 -t 1000 -E 8:3 -W 0:0x47868C0
where:
Kick the watchdog every five (5) seconds, and set the timeout period to 10 seconds:
wdtkick -v -a 0x441 -t 5000 -w 8 -W 2:0xA
where:
You can enter the watchdog configuration via the command line at startup, or you can modify your guest startup to store it in the guest system page's hwinfo section (see the System Page chapter in Building Embedded Systems).
For up-to-date information about your board-specific watchdog kicker utility, see the wdtkick.use file included with the BSP.
For information about the watchdog vdevs, see vdev wdt-sp805 (ARM) and vdev wdt-ib700 (x86) in the Configuration chapter.
If you want to use a watchdog in a Linux or Android guest, you must do the following:
Enable the watchdog module – the Linux or Android kernel must include the correct watchdog kernel module for your target (IB700 or SP805).
In most Linux and Android distributions, this module isn't enabled by default. See menuconfig, and the Linux kernal configuration documentation's Device Drivers section for details on how to rebuild a Linux kernel with the watchdog module enabled.