What it checks

This restart test kills a QNX 8.0 resource manager with SIGKILL inside QEMU and checks on the host whether it came back. It is for developers of QNX device drivers and services, such as in automotive, robotics, and medical systems. The test verifies that a service restarts without a reboot and runs with no target hardware, for example in CI. One C program, src/qnxres.c, has four modes: --serve, --client, --seektest, and --supervise. In --supervise mode, it starts the server with fork and exec, reads from it, and runs 2 restart rounds. On the host, tools/qnxres_check.py (Python 3, standard library only) reads only the serial console log. Exit code 0 means PASS, 1 means FAIL, and 2 means reading the log failed. The script requires the line QNXRES supervise done, the line QNXRES seektest done ok=yes, and 5 checks per round:

  1. kill (kill_rc=0 waitpid_rc=0): --supervise kills the server with SIGKILL and checks the kill and waitpid return codes.
  2. gone (read_after_kill_failed=yes): a read after the kill fails.
  3. back (recovered=yes): --supervise starts a new server and polls until a read works.
  4. fresh (read_after_restart_2 ... ok=yes): --supervise reads twice more from the new server, and the follow-up read succeeds.
  5. reset (state_reset=yes): the counter of the new server starts again.

Before the rounds, --seektest calls lseek past the end of the line (offsets 64 and 4096, and offsets above 2^31 and 2^32 that would wrap if cast to int) and checks that read returns 0 bytes.

Why QNX

This test only makes sense because QNX runs drivers and services as user processes called resource managers. A resource manager owns a path name. When the process dies, the path disappears, and a new process registers it again. The microkernel and the other processes keep running.

After the supervisor exits, ls /dev/qnxres prints No such file or directory, and pidin still lists processes, including:

  • procnto-smp-instr
  • slogger2
  • pci-server
  • devc-ser8250

In an earlier version, opening /dev/qnxres from the same process that called resmgr_attach failed with ENOENT. Server and client therefore run as separate processes: --client waits until /dev/qnxres can be read, then reads it 3 times.

Run it

Requirements

  • An x86_64 Linux host, or Windows with WSL2 (the scripts are bash); QNX SDP does not run on macOS
  • QNX SDP 8.0, available with a free non-commercial license from myQNX
  • QEMU
  • Python 3

Reference environment: QEMU 6.2.0 on Ubuntu 22.04 under WSL2, with 1 CPU and 512 MB for the guest.

One command

Replace the SDP 8.0 placeholder in the first line with your install path. Then run either mode.

source <SDP 8.0>/qnxsdp-env.sh      # qcc and mkqnximage on PATH
scripts/demo.sh kvm                 # build, boot QEMU, check the serial log
scripts/demo.sh tcg                 # same, without hardware virtualization

Separate steps

With the SDP environment active in your shell, run these three commands in order.

scripts/build.sh                    # qcc + mkqnximage -> build/img/output/disk-qemu.vmdk
scripts/run_qemu.sh kvm             # boot; serial console on the terminal and in build/serial.log
python3 tools/qnxres_check.py build/serial.log   # PASS -> exit 0, FAIL -> exit 1

Log checker tests

python3 tests/test_qnxres_check.py   # host only, no QNX needed

What a run looks like

A 2026-11-26 run produced this serial log; the supervisor prints one line per step and no timings.

DEMO step2: supervisor kills the server twice and restarts it
QNXRES server attached /dev/qnxres
QNXRES supervise start=ok
QNXRES hb seq=2 procs=19
QNXRES hb seq=3 procs=19
QNXRES hb seq=4 procs=19
QNXRES round=1 killed kill_rc=0 waitpid_rc=0
QNXRES round=1 read_after_kill_failed=yes
QNXRES server attached /dev/qnxres
QNXRES inject round=1 killed=yes read_failed_after_kill=yes restarted=yes recovered=yes attempts=2
QNXRES round=1 read_after_restart_1 seq=2
QNXRES round=1 read_after_restart_2 seq=3 ok=yes
QNXRES after_restart round=1 last_seq_before=4 first_seq_after=2 state_reset=yes
QNXRES hb seq=4 procs=19
QNXRES hb seq=5 procs=19
QNXRES hb seq=6 procs=19
QNXRES round=2 killed kill_rc=0 waitpid_rc=0
QNXRES round=2 read_after_kill_failed=yes
QNXRES server attached /dev/qnxres
QNXRES inject round=2 killed=yes read_failed_after_kill=yes restarted=yes recovered=yes attempts=2
QNXRES round=2 read_after_restart_1 seq=2
QNXRES round=2 read_after_restart_2 seq=3 ok=yes
QNXRES after_restart round=2 last_seq_before=6 first_seq_after=2 state_reset=yes
QNXRES supervise done
DEMO step3: after the supervisor exits, the name is gone and the OS is still up
ls: /dev/qnxres: No such file or directory
     pid name              
       1 procnto-smp-instr 
   16386 sh                
   16387 slogger2          
   28676 pci-server        
   49157 devc-ser8250      
   57351 ksh               
   77830 fsevmgr           
DEMO_END

The host check on that log returned this output.

round 1: kill=ok gone=ok back=ok fresh=ok reset=ok attempts=2
round 2: kill=ok gone=ok back=ok fresh=ok reset=ok attempts=2
seektest: ok
supervise done: yes
PASS

That day, qcc printed 0 warnings, and three boots passed the host check with recovered=yes in both rounds:

  • KVM
  • TCG
  • TCG from a fresh copy of the repository with scripts/demo.sh

tests/test_qnxres_check.py runs the checker on 8 logs. Two real logs (KVM and TCG) must PASS, and six copies of the KVM log with one or two lines changed must FAIL with the right reason. All 8 pass.

QNX APIs and files used

src/qnxres.c               resource manager, client, supervisor (runs on QNX)
image/post_start.custom    commands the image runs at the end of boot
scripts/build.sh           qcc + mkqnximage
scripts/run_qemu.sh        QEMU, 1 CPU, 512 MB, serial log
scripts/demo.sh            build + boot + check
tools/qnxres_check.py      host check of the serial log
tests/                     checker tests (8 logs)
evidence/                  serial logs of the runs on 2026-11-26
docs/codelab.md            tutorial

src/qnxres.c

Under --serve, serve() registers /dev/qnxres with resmgr_attach, using:

  • iofunc_func_init
  • iofunc_attr_init
  • dispatch_create
  • dispatch_block
  • dispatch_handler

The read handler io_read() compares the file offset as off_t (0 bytes outside the line), replies from its own buffer with MsgReply and returns _RESMGR_NOREPLY. Each read returns one line, QNXRES hb seq=N procs=M, where seq counts reads and procs counts entries in /proc.

Toolchain and target

  • QNX SDP 8.0
  • qcc -Vgcc_ntox86_64 -Wall -Wextra
  • mkqnximage --type=qemu --arch=x86_64
  • QEMU 6.2.0 on Ubuntu 22.04 under WSL2

The guest reports QNX qnxdemo 8.0.0 ... x86pc x86_64 from uname -a (evidence/serial_kvm.log, line DEMO_BEGIN).

Reuse

For another resource manager, DEVNAME and io_read() in src/qnxres.c change, while the supervisor and the host check stay the same. This was not tried with another resource manager.

Limits and licence

Not checked:

  • Real hardware (QEMU only)
  • Other resource managers
  • More than 2 rounds
  • Concurrent clients during the kill

No speed or timing figures are published.

This repository uses the MIT license and does not include QNX SDP files. QNX SDP 8.0 is available with a free non-commercial license from myQNX.

Demo and tutorial

The demo video is linked on this page. The step-by-step tutorial is docs/codelab.md in the repository.

Built With

Share this project:

Updates

Submission history