Learn
Writing a virtio driver for QNX 8.0, from PCI discovery to the first byte read
A hands-on tutorial. By the end of it you will have a QNX 8.0 guest that finds a virtio-9p device on the PCI bus, negotiates the protocol with QEMU, exchanges its first 9P message, and reads the first byte of a file.
<strong>Audience.</strong> Someone who knows C, has heard of QNX resource managers, and wants to write a driver for QNX 8.0 rather than for 7.1. No prior virtio knowledge is assumed; every structure a driver touches is introduced before it is used.
<strong>Prerequisites.</strong>
| QNX SDP 8.0 | the toolchain (qcc) and mkqnximage; a licence is needed, the tutorial does not need a QNX licence key for the parts that run in the guest |
| QEMU 8.2 or later | the hypervisor; qemu-system-x86_64 and qemu-system-aarch64 |
| Linux | the host; a recent distribution is fine |
| CMake 3.16 or later | for the exercises |
| A C11 compiler | for the exercises, which run on the PC |
<strong>Time.</strong> About four hours end to end, and the four hours are not equal: the first two chapters are quick, chapters 3 to 5 are where the time goes, and chapter 6 is the one that can eat an afternoon if the interrupt does not work.
<strong>What you will have at the end.</strong>
- A guest image built with `mkqnximage` that boots under QEMU.
- A program that finds the virtio-9p PCI device, reads its capabilities, negotiates `9P2000.L`, walks to a file, and reads its first byte.
- A resource manager skeleton that turns the prototype into something a program can `open()`.
- A checklist of the places where this goes wrong, and how to tell which one you are looking at.
<strong>The code.</strong> Every listing in this tutorial is either a complete, compilable program in