Module virtio_blk

Source
Expand description

§VirtIO Block Device Driver

This module provides a driver for VirtIO block devices, implementing the BlockDevice trait for integration with the kernel’s block device subsystem.

The driver supports basic block operations (read/write) and handles the VirtIO queue management for block device requests.

§Features Support

The driver checks for and handles the following VirtIO block device features:

  • VIRTIO_BLK_F_BLK_SIZE: Custom sector size
  • VIRTIO_BLK_F_RO: Read-only device detection

§Implementation Details

The driver uses a single virtqueue for processing block I/O requests. Each request consists of three parts:

  1. Request header (specifying operation type and sector)
  2. Data buffer (for read/write content)
  3. Status byte (for operation result)

Requests are processed through the VirtIO descriptor chain mechanism, with proper memory management using Box allocations to ensure data remains valid during transfers.

Structs§

VirtioBlkConfig
VirtioBlkGeometry
VirtioBlkReqHeader
VirtioBlkTopology
VirtioBlockDevice

Constants§

VIRTIO_BLK_F_BLK_SIZE 🔒
VIRTIO_BLK_F_CONFIG_WCE 🔒
VIRTIO_BLK_F_MQ 🔒
VIRTIO_BLK_F_RO 🔒
VIRTIO_BLK_F_SCSI 🔒
VIRTIO_BLK_S_IOERR 🔒
VIRTIO_BLK_S_OK 🔒
VIRTIO_BLK_S_UNSUPP 🔒
VIRTIO_BLK_T_IN 🔒
VIRTIO_BLK_T_OUT 🔒
VIRTIO_F_ANY_LAYOUT 🔒
VIRTIO_RING_F_EVENT_IDX 🔒
VIRTIO_RING_F_INDIRECT_DESC 🔒