PCI & Virtio Block Subsystems
Relevant source files
The following files were used as context for generating this wiki page:
The PCI and Virtio block subsystems provide the hardware interface and storage capabilities for the gokrazy Linux 7.0 kernel. These components enable the kernel to run within QEMU virtualized environments, specifically for Tailscale natlab and vmtest workloads.
Sources: README.md:1-6, empty.go:7-10
PCI Infrastructure
The PCI subsystem manages the discovery and configuration of peripheral devices on the system bus. The kernel enables the PCI bus, PCIE port bus support, and Message Signaled Interrupts (MSI) to interface with virtualized hardware.
Sources: config.addendum.txt:90-93
PCI Configuration Details
The following table lists the specific kernel configurations that enable PCI functionality:
| Configuration Option | Description |
|---|---|
CONFIG_PCI | Enables the core PCI bus support. |
CONFIG_PCIEPORTBUS | Provides support for PCI Express port bus services. |
CONFIG_PCI_MSI | Enables Message Signaled Interrupts for device communication. |
Sources: config.addendum.txt:90-93
Virtio Subsystem
The Virtio subsystem provides a standardized interface for virtual machines to access host devices. This project specifically includes support for block devices, networking, and entropy generation via the Virtio protocol.
Sources: config.addendum.txt:78-84, README.md:12-16
Virtio Components and Drivers
The kernel incorporates several Virtio-specific drivers to handle different virtualized hardware functions:
- Virtio PCI: Bridges Virtio devices over the PCI bus.
- Virtio Block: Manages virtual disk drives for storage access.
- Virtio Net: Handles virtualized network interfaces.
- Virtio RNG: Provides hardware random number generation from the host.
Sources: config.addendum.txt:78-84
The diagram shows the hierarchy from the Linux kernel through the PCI bus to specific Virtio device drivers.
Storage and Block Device Integration
The Virtio block driver enables the kernel to mount the root filesystem. The system identifies the boot partition as a standard block device.
Sources: cmdline.txt:1, config.addendum.txt:79
Boot Configuration
The kernel command line specifies the location of the root partition. The system uses the Virtio block device to load the gokrazy init process.
| Parameter | Value | Description |
|---|---|---|
root | /dev/sda2 | Specifies the second partition on the first disk as the root filesystem. |
init | /gokrazy/init | Defines the path to the initial user-space process. |
ro | N/A | Mounts the root filesystem in read-only mode. |
Sources: cmdline.txt:1
Hardware Emulation Environment
The PCI and Virtio subsystems facilitate execution under the QEMU q35 machine type. This environment supports high-performance networking and storage through paravirtualized drivers.
Sources: README.md:12-14
Network and Storage Data Flow
The sequence diagram illustrates the interaction between the host emulator and the guest Virtio drivers for block storage operations.
Summary
The PCI and Virtio Block subsystems establish the foundational hardware abstraction layer for the gokrazy Linux 7.0 kernel. By enabling CONFIG_VIRTIO_BLK and CONFIG_PCI, the kernel supports the virtualized storage requirements of Tailscale vmtest environments. These configurations ensure the system can successfully mount /dev/sda2 and execute the gokrazy init system within QEMU.
Sources: README.md:12-14, config.addendum.txt:78-80, cmdline.txt:1