中文 | English
The VirtIO driver provides support for virtual I/O devices in RT-Thread, primarily used in virtualized environments like QEMU.
The driver now supports both legacy and modern VirtIO specifications:
- Legacy VirtIO (v0.95): Version field 0x1, compatible with older QEMU versions
- Modern VirtIO (v1.0+): Version field 0x2, supports VirtIO 1.0, 1.1, and 1.2 specifications
- VirtIO Block (virtio-blk): Virtual block device
- VirtIO Network (virtio-net): Virtual network interface
- VirtIO Console (virtio-console): Virtual serial console
- VirtIO GPU (virtio-gpu): Virtual graphics device
- VirtIO Input (virtio-input): Virtual input device (keyboard, mouse, tablet)
Use menuconfig to configure VirtIO support:
RT-Thread Components → Device Drivers → Using VirtIO device drivers
Choose between legacy and modern VirtIO:
RT-Thread Components → Device Drivers → Using VirtIO device drivers → VirtIO Version
Options:
- VirtIO Legacy (v0.95): For compatibility with older QEMU versions (default)
- VirtIO Modern (v1.0+): For newer QEMU versions (2.4+) with enhanced features
Enable individual VirtIO devices:
RT_USING_VIRTIO_BLK: VirtIO block device supportRT_USING_VIRTIO_NET: VirtIO network device supportRT_USING_VIRTIO_CONSOLE: VirtIO console device supportRT_USING_VIRTIO_GPU: VirtIO GPU device supportRT_USING_VIRTIO_INPUT: VirtIO input device support
- 32-bit feature negotiation
- Single queue descriptor area
- Simple status flags
- Guest page size configuration
- 64-bit feature negotiation (supports more features)
- Separate descriptor/driver/device queue areas
- Enhanced status flow with FEATURES_OK check
- Better memory alignment and atomicity guarantees
- Update your QEMU command line to use modern VirtIO devices (most recent QEMU versions default to modern)
- Change the VirtIO version in menuconfig:
RT-Thread Components → Device Drivers → Using VirtIO device drivers → VirtIO Version → Select "VirtIO Modern (v1.0+)" - Rebuild your application
- The driver will automatically negotiate the VERSION_1 feature with the device
The driver automatically detects the device version from the MMIO config and adapts its behavior accordingly. Both legacy (version 0x1) and modern (version 0x2) devices are supported in the same build.
The following BSPs have been updated to support both legacy and modern VirtIO:
qemu-virt64-riscv: QEMU RISC-V 64-bitqemu-virt64-aarch64: QEMU ARM64 (AArch64)
- VirtIO Specification v1.2 (Latest, 2022)
- VirtIO Specification v1.1 (2019)
- VirtIO Specification v1.0 (2016)
- OASIS VirtIO TC
Apache-2.0