Documentation
¶
Overview ¶
Package virtq is the device side of a virtio split virtqueue: it takes descriptor chains the driver made available and returns them used.
Everything in the rings is written by the guest and checked here: the available index may not run ahead of the queue, a chain may not loop or be longer than the queue, every buffer must lie in guest memory, device-writable buffers must follow the readable ones, and indirect descriptors (not negotiated) are refused.
Reference: the virtio spec, split-ring.tex — struct virtq_desc (:185-196), the descriptor rules (:146-151, :218-223, :266-278), struct virtq_avail (:298), struct virtq_used (:393-409) and the used length rules (:456-462).
Index ¶
Constants ¶
const ( DescNext uint16 = 1 DescWrite uint16 = 2 DescIndirect uint16 = 4 )
Descriptor flags (split-ring.tex:192-196).
const MaxSize = 32768
MaxSize is the largest queue size (virtio: 32768).
Variables ¶
var ErrRing = errors.New("virtq: malformed ring")
ErrRing is wrapped by every error a malformed ring causes.
Functions ¶
Types ¶
type Chain ¶
type Chain struct {
Head uint16
Readable [][]byte
Writable [][]byte
ReadLen uint64
WriteLen uint64
}
Chain is one descriptor chain: its head index and its buffers, which are views of guest memory.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is one split virtqueue as the device sees it.
func New ¶
New maps a queue of size entries whose rings the driver placed at the guest-physical addresses desc, avail and used.