go-virtio

Pure-Go, transport-agnostic guest virtio drivers — one common.Transport interface, every device class, and zero cgo on a plain go build.

CGO_ENABLED=0 transport-pluggable net · rng · vsock · blk · console · balloon · input · sound · gpu · fs 2D + virgl 3D + Venus (Vulkan-over-virtio) validated on real devices & renderers 100% coverage
Documentation GitHub

go-virtio implements virtio device-class drivers in pure Go — no cgo, no kernel — routing every transport-level operation through one narrow common.Transport interface, so the same driver code runs under UEFI's EFI_PCI_IO_PROTOCOL, bare-metal MMIO, virtio-mmio, or any backplane that satisfies the contract. The drivers sit on a single shared common waist — a PCI capability walker, modern-config registers, and a split-virtqueue with descriptor chaining. Extracted from the cloud-boot TamaGo + UEFI loader, designed from day one to run anywhere virtio runs.

Pure Go, no cgo, real-device validation. The 3D story is split honestly: gpu/soft3d is a dependency-free CPU rasterizer that works on any host; gpu's virgl path hand-encodes the command stream so a host GPU draws (still CGO=0); and venus is Vulkan-over-virtio with a vk.xml→Go generator, a shared-memory ring, and guest-side pixel readback. Every driver plus virgl 3D and the full Venus clear-image-with-readback are validated against real devices and renderers — and that real-hardware validation has caught 9 encoding bugs that fake-device unit tests missed. No architecture-specific assembly: the same source builds for every Go target.

Repositories

common libinfra

v0.1.5

Transport-agnostic infrastructure: PCI capability walker, ModernConfig registers, split-virtqueue with descriptor chaining, device-class IDs, and the Transport interface every driver consumes.

coverage 100%

net libdriver

v0.1.1

virtio-net (DID 0x1041). Frame-level TransmitFrame / ReceiveFrame over a TX/RX queue pair.

coverage 100%

rng libdriver

v0.1.1

virtio-rng (DID 0x1044). Single-queue entropy Read — the minimal device class.

coverage 100%

vsock libdriver

v0.1.1

virtio-vsock (DID 0x1053). Three queues; packet-level SendPacket / ReceivePacket with virtio_vsock_hdr.

coverage 100%

blk libdriver

v0.2.0

virtio-blk (DID 0x1042). ReadBlocks / WriteBlocks / Flush; requests are header + data + status descriptor chains.

coverage 100%

console libdriver

v0.1.0

virtio-console (DID 0x1043). Raw byte-stream Write / Read over an rx/tx pair.

coverage 100%

balloon libdriver

v0.1.0

virtio-balloon (DID 0x1045). Inflate / Deflate via le32 page-frame-number arrays.

coverage 100%

input libdriver

main

virtio-input (DID 0x1052). Device-to-guest event read path (ReadEvent) mirroring Linux’s input_event; keyboard + relative-pointer baseline, buffers re-posted on the eventq.

CI coverage 100%

sound libdriver

main

virtio-sound (DID 0x1059). Modern-transport init plus the minimum PCM playback + capture data paths; routes raw S16_LE frames over the tx/rx queues (single-jack Virtio 1.2 baseline).

CI coverage 100%

gpu lib3d

v0.6.1

virtio-gpu (DID 0x1050). 2D framebuffer + virgl 3D (host-GPU clear / triangle / textured triangle) + a dependency-free pure-Go software 3D rasterizer (gpu/soft3d).

coverage 100%

fs libdriver

v0.2.1

virtio-fs (DID 0x105A). FUSE-over-virtio read-write mount: Init / Lookup / Open / Read + Write / Create / Mkdir / SetAttr / Unlink / Rename / Fsync … (each fuse.h-cited).

coverage 100%

venus lib3d

v0.5.1

Vulkan-over-virtio (Venus). A vk.xml→Go serializer/generator plus a shared-memory ring transport; a clear-image runs end-to-end on a real renderer (virgl_test_server --venus + lavapipe), and on a Linux render-node host the guest maps the cleared HOST3D|MAPPABLE blob and reads the texels back — guest-side pixel readback included.

coverage 100%

validate toolharness

v0.1.0

Multi-driver real-hardware validation harness (tamago + QEMU) plus a pure-Go virglrenderer/Venus vtest client. Exercises every driver on real devices and the virgl 3D paths + full Venus clear-image-with-readback against a real virglrenderer / lavapipe.

coverage 100%

Every driver consumes common.Transport and nothing else — swap the backplane, keep the driver. Pure Go with CGO_ENABLED=0 and held at 100% statement coverage; the newer input and sound drivers gate that in CI, and the others are covered locally. Real-device and real-renderer validation (via the validate harness) is the bar: all the drivers plus virgl 3D and the full Venus clear-image-with-readback run against real hardware and virglrenderer / lavapipe. BSD-3-Clause throughout. First consumer: cloud-boot.