VirtIO

From FriendOS Wiki
Jump to navigation Jump to search

VirtIO is a standard for performant virtualized hardware for use within virtual machines, created and managed by the OASIS Open Virtual I/O Device TC. VirtIO supports a variety of devices, such as, but not limited to: block (e.g. hard drive), network card, GPU, etc. Each of these devices have their own specific configuration and features, but all use the same underlying VirtIO queue structure for relaying data and commands to & from the device.

The latest specification, 1.3, is available at https://docs.oasis-open.org/virtio/virtio/v1.3/csd01/virtio-v1.3-csd01.html.

VirtIO provides a common framework for devices to be identified and for communicating between the device implementation and the driver. Communication for is handled through so-called virtqueues.

Certain implementations extend the features available.

For example, here is the list of virtio-gpu capsets in Mesa, at src/gfxstream/guest/platform/include/virtgpu_gfxstream_protocol.h:

#define VIRTGPU_CAPSET_VIRGL 1
#define VIRTGPU_CAPSET_VIRGL2 2
#define VIRTGPU_CAPSET_GFXSTREAM_VULKAN 3
#define VIRTGPU_CAPSET_VENUS 4
#define VIRTGPU_CAPSET_CROSS_DOMAIN 5
#define VIRTGPU_CAPSET_DRM 6
#define VIRTGPU_CAPSET_GFXSTREAM_MAGMA 7
#define VIRTGPU_CAPSET_GFXSTREAM_GLES 8
#define VIRTGPU_CAPSET_GFXSTREAM_COMPOSER 9

virtio-gpu can be used to forward various things to Linux hosts, such as native Wayland surfaces, or Linux drm ioctls. Commonly this is used with Linux guests, but there's nothing preventing usage in any other OS running as guest.

Device Types

VirtIO Device Types
Device ID Device Name Description
0 reserved (invalid) TODO
1 network card TODO
2 block device TODO
3 console TODO
4 entropy source TODO
5 memory ballooning (traditional) TODO
6 ioMemory TODO
7 rpmsg TODO
8 SCSI host TODO
9 9P transport TODO
10 mac80211 wlan TODO
11 rproc serial TODO
12 virtio CAIF TODO
13 memory balloon TODO
16 GPU device TODO
17 Timer/Clock device TODO
18 Input device TODO
19 Socket device TODO
20 Crypto device TODO
21 Signal Distribution Module TODO
22 pstore device TODO
23 IOMMU device TODO
24 Memory device TODO
25 Audio device TODO
26 file system device TODO
27 PMEM device TODO
28 RPMB device TODO
29 mac80211 hwsim wireless simulation device TODO
30 Video encoder device TODO
31 Video decoder device TODO
32 SCMI device TODO
33 NitroSecureModule TODO
34 I2C adapter TODO
35 Watchdog TODO
36 CAN device TODO
38 Parameter Server TODO
39 Audio policy device TODO
40 Bluetooth device TODO
41 GPIO device TODO
42 RDMA device TODO

Device Transports

VirtIO supports three different types of device transports: PCI Bus, MMIO, and Channel I/O. The PCIe transport is configured via the normal PCIe configuration mechanisms, while the MMIO transport is configured strictly via MMIO reads and writes.