qdev

package
v0.0.0-...-ede35a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package qdev describes PCI Express device topologies of a QEMU guest.

The design of this package is intentionally limited to encourage good topologies that follow recommendations laid out in the QEMU documentation. Many QEMU device features are not included or exposed by the types in this package.

To create a new QEMU device hierarchy, prepare a new Topology and add PCI Express Root Ports to it.

Index

Examples

Constants

View Source
const (
	// MaxMultifunctionDevices is the maximum number of devices that can be
	// addressed at a single PCI Express slot using multifunction addressing.
	MaxMultifunctionDevices = 8

	// MaxRoots is the maximum number of PCI Express Root devices within a
	// PCI Express Root Complex.
	MaxRoots = 32 * MaxMultifunctionDevices
)
View Source
const (
	// MaxSATADevices is the maximum number of SATA devices supported by the
	// ICH9's SATA controller on q35 machines.
	MaxSATADevices = 6
)
View Source
const (
	// MaxSCSIDevices is the maximum number of devices supported by an SCSI
	// controller.
	MaxSCSIDevices = 28
)
View Source
const (
	// MaxSerialPorts is the maximum number of Serial Ports supported by a
	// Serial Controller.
	MaxSerialPorts = 31
)
View Source
const (
	// MaxUSBPorts is the maximum number of USB Ports supported by an xHCI
	// controller.
	MaxUSBPorts = 15
)

Variables

View Source
var (
	// ErrDownstreamOccupied is returned when an attempt is made to connect a
	// a device to a PCI Express port that already has a device connected
	// to it.
	ErrDownstreamOccupied = errors.New("a device is already connected to the PCI Express downstream port")
)
View Source
var (
	// ErrRootComplexFull is returned when the addition of a new PCI Express
	// Root would exceed MaxRoots.
	ErrRootComplexFull = errors.New("the PCI Express root complex is full and cannot accommodate more devices")
)
View Source
var (
	// ErrSATAFull is returned when the addition of a new SATA device
	// would exceed MaxSATADevices.
	ErrSATAFull = errors.New("the SATA controller is full and cannot accommodate more devices")
)
View Source
var (
	// ErrSCSIControllerFull is returned when the addition of a new SCSI disk
	// would exceed MaxSCSIDevices.
	ErrSCSIControllerFull = errors.New("the SCSI Controller is full and cannot accommodate more devices")
)
View Source
var (
	// ErrSerialControllerFull is returned when the addition of a new Serial
	// device would exceed MaxSerialPorts.
	ErrSerialControllerFull = errors.New("the serial controller is full and cannot accommodate more devices")
)
View Source
var (
	// ErrUSBControllerFull is returned when the addition of a new USB device
	// would exceed MaxUSBPorts.
	ErrUSBControllerFull = errors.New("the USB Controller is full and cannot accommodate more devices")
)

Functions

func Walk

func Walk(devices []Device, fn WalkFn)

Walk visits all of the members of devices and their downstream descendents in depth-first traversal order.

Devices implementing the Upstream or Switch interfaces will have their non-nil descendents visited.

Types

type Addr

type Addr struct {
	Slot     int
	Function int
}

Addr is an address on a PCI or PCIe bus.

func (Addr) String

func (addr Addr) String() string

String returns a string representation of the PCI address.

type Block

type Block struct {
	// contains filtered or unexported fields
}

Block is a Virtio Block device.

func (Block) Driver

func (block Block) Driver() Driver

Driver returns the driver for the Virtio Block device, virtio-blk-pci.

func (Block) Properties

func (block Block) Properties() Properties

Properties returns the properties of the Virtio Block device.

type BlockOption

type BlockOption interface {
	// contains filtered or unexported methods
}

BlockOption is an option for a Virtio Block device.

type BootIndex

type BootIndex int

BootIndex holds the boot index assigned to a boot device.

func (BootIndex) String

func (boot BootIndex) String() string

String returns a string representation of the boot index.

type BootOrder

type BootOrder struct {
	// contains filtered or unexported fields
}

BootOrder keeps track of the preferred order of boot devices.

func (*BootOrder) Next

func (boot *BootOrder) Next() BootIndex

Next returns the next available boot index.

type BusMap

type BusMap map[string]int

BusMap keeps track of index assignments for QEMU device buses.

The QEMU machinery forcefully adds a numeric suffix such as ".0" to the ID of many controllers in order to form the controller's bus address used by downstream devices. This seems to contradict the behavior of the PCI Express bus, which uses the controller's ID directly as the bus address.

When declaring controller identifiers to QEMU, many controllers must supply their ID prefix (such as "usb") and then anticipate the actual bus address assignment that will be assigned by QEMU.

TODO: Find someone, somewhere, that can actually explain QEMU's bus addresss naming requirements and conventions. Thus far, no documentation on this topic has been found.

func (BusMap) Allocate

func (m BusMap) Allocate(name string) ID

Allocate returns the next ID for a device on the given bus name.

func (BusMap) Count

func (m BusMap) Count(name string) int

Count returns the number of devices that have been allocated with the given bus name.

type ControllerMap

type ControllerMap struct {
	// contains filtered or unexported fields
}

ControllerMap keeps track of which device controllers have been added to a QEMU virtual machine definition.

func NewControllerMap

func NewControllerMap(topo *Topology) *ControllerMap

NewControllerMap returns a controller map that will keep track of device controllers assigned to the given QEMU virtual machine definition.

TODO: Consider walking the existing topology to find controllers.

func (*ControllerMap) SCSI

func (m *ControllerMap) SCSI(iothread qhost.IOThread) (*SCSI, error)

SCSI returns a SCSI controller device for the virtual machine.

func (*ControllerMap) Serial

func (m *ControllerMap) Serial() (*Serial, error)

Serial returns a serial controller device for the virtual machine.

func (*ControllerMap) Topology

func (m *ControllerMap) Topology() *Topology

Topology returns the virtual machine topology that the map is bound to.

func (*ControllerMap) USB

func (m *ControllerMap) USB() (*USB, error)

USB returns a USB controller device for the virtual machine.

func (*ControllerMap) USBAttachedSCSI

func (m *ControllerMap) USBAttachedSCSI() (*USBAttachedSCSI, error)

USBAttachedSCSI returns a USB Attached SCSI controller device for the virtual machine.

type Device

type Device interface {
	Driver() Driver
	Properties() Properties
}

Device describes a virtual device to qemu.

type Driver

type Driver string

Driver identifies a QEMU device driver.

type ID

type ID string

ID identifies a device within a PCI Express topology.

By convention downstream devices often use an ID that has the upstream device ID as its prefix.

func (ID) Downstream

func (id ID) Downstream(sub string) ID

Downstream returns a downstream child ID derived from id.

type Network

type Network struct {
	// contains filtered or unexported fields
}

Network is a PCI Express Virtio Network Controller device.

Example
package main

import (
	"fmt"

	"github.com/gentlemanautomaton/machina/qemu/qdev"
	"github.com/gentlemanautomaton/machina/qemu/qhost"
)

func main() {
	var (
		host qhost.Resources
		topo qdev.Topology
	)

	// Prepare a network tap that connects to the kvmbr0 interface
	tap, err := host.AddNetworkTap("kvmbr0", "", "")
	if err != nil {
		panic(err)
	}

	// Add a PCI Express Root Port that we'll connect the Network Controller to
	root, err := topo.AddRoot()
	if err != nil {
		panic(err)
	}

	// Add the Network Controller and connect it to the host network tap
	if _, err := root.AddVirtioNetwork("00:00:00:00:00:00", tap); err != nil {
		panic(err)
	}

	// Print the configuration
	options := topo.Options()
	for _, option := range options {
		fmt.Printf("%s\n", option)
	}

}
Output:

-device ioh3420,id=pcie.1.0,chassis=0,bus=pcie.0,addr=1.0,multifunction=on
-device virtio-net-pci,bus=pcie.1.0,mac=00:00:00:00:00:00,netdev=net.0

func (Network) Driver

func (n Network) Driver() Driver

Driver returns the driver used for the Network Controller device, virtio-net-pci.

func (Network) Properties

func (n Network) Properties() Properties

Properties returns the properties of the Network Controller device.

type PVPanic

type PVPanic struct {
	// contains filtered or unexported fields
}

PVPanic is a paravirtualized panic PCI device.

func (PVPanic) Driver

func (p PVPanic) Driver() Driver

Driver returns the driver for the paravirtualized panic PCI device, pvpanic-pci.

func (PVPanic) Properties

func (p PVPanic) Properties() Properties

Properties returns the properties of the paravirtualized panic PCI device.

type Properties

type Properties = qemu.Parameters

Properties holds a set of QEMU device properties.

type Property

type Property = qemu.Parameter

Property describes a QEMU device property.

type QXL

type QXL struct {
	// contains filtered or unexported fields
}

QXL is a QXL display device.

Example
package main

import (
	"fmt"

	"github.com/gentlemanautomaton/machina/qemu/qdev"
)

func main() {
	var topo qdev.Topology

	const heads = 2

	for i := 0; i < heads; i++ {
		// Add QXL display devices directly to the root complex
		if _, err := topo.AddQXL(); err != nil {
			panic(err)
		}
	}

	// Print the configuration
	options := topo.Options()
	for _, option := range options {
		fmt.Printf("%s\n", option)
	}

}
Output:

-device qxl-vga,id=qxl.0,bus=pcie.0,addr=1.0,multifunction=on
-device qxl,id=qxl.1,bus=pcie.0,addr=1.1

func (QXL) Driver

func (qxl QXL) Driver() Driver

Driver returns the driver for the QXL display device, qxl-vga for primary devices and qxl for secondary devices.

func (QXL) Properties

func (qxl QXL) Properties() Properties

Properties returns the properties of the QXL display device.

type Root

type Root struct {
	// contains filtered or unexported fields
}

Root represents a PCI Express Root Port device. It connects a single downstream device to a PCI Express Root Complex.

func (*Root) AddUSB

func (r *Root) AddUSB() (*USB, error)

AddUSB connects a PCI Express xHCI Controller device to the PCI Express Root Port.

func (*Root) AddVFIO

func (r *Root) AddVFIO(device qhost.SystemDevicePath) (VFIO, error)

AddVFIO connects a PCI device on the host to the PCI Express Root Port.

The connection is made with the Virtual Function I/O framework. It relies on an I/O Memory Management Unit on the host, which allows the device to be passed through while isolating the guest from the host.

func (*Root) AddVirtioBlock

func (r *Root) AddVirtioBlock(thread qhost.IOThread, bdev blockdev.Node, options ...BlockOption) (Block, error)

AddVirtioBlock connects a PCI Express Virtio Block device to the PCI Express Root Port.

func (*Root) AddVirtioNetwork

func (r *Root) AddVirtioNetwork(mac string, netdev qhost.NetDev) (Network, error)

AddVirtioNetwork connects a PCI Express Virtio Network controller to the PCI Express Root Port.

TODO: Consider naming this AddNetwork.

func (*Root) AddVirtioSCSI

func (r *Root) AddVirtioSCSI(thread qhost.IOThread) (*SCSI, error)

AddVirtioSCSI connects a PCI Express Virtio SCSI controller to the PCI Express Root Port.

TODO: Consider naming this AddSCSI.

func (*Root) AddVirtioSerial

func (r *Root) AddVirtioSerial() (*Serial, error)

AddVirtioSerial connects a PCI Express Virtio Serial controller to the PCI Express Root Port.

TODO: Consider naming this AddSerial.

func (*Root) Connect

func (r *Root) Connect(dev Device) error

Connect connects a device to the PCI Express Root Port.

This function should only be used for custom devices not already supplied by the qdev package. Use of the Root.Add* functions are preferred because they take care of bus assignments and are safer for common use cases.

It is the caller's responsibility to properly configure the bus of the connected device.

func (Root) Downstream

func (r Root) Downstream() Device

Downstream returns the downstream device connected to the PCI Express root port.

It returns nil if a downstream device hasn't been connected.

func (Root) Driver

func (r Root) Driver() Driver

Driver returns the driver for the PCI Express Root Port device, ioh3420.

TODO: Consider using pcie-root-port instead.

TODO: Find some sort of documentation for pcie-root-port, somewhere. Anywhere. Any documentation at all would be really great.

TODO: Find out why this patch wasn't merged: https://patchwork.kernel.org/project/qemu-devel/patch/20170802155113.62471-1-marcel@redhat.com/

func (Root) ID

func (r Root) ID() ID

ID returns the bus identifier of the PCI Express Root Port device.

func (Root) Properties

func (r Root) Properties() Properties

Properties returns the properties of the PCI Express Root Port device.

type SATACD

type SATACD struct {
	// contains filtered or unexported fields
}

SATACD is a SATA CD-ROM device.

func (SATACD) Driver

func (cd SATACD) Driver() Driver

Driver returns the driver for the SATA CD device, ide-cd.

The Q35 machine foolishly uses "ide" as the identifier for its AHCI bus that's built into its ICH9 controller. As such, ide-cd devices are actually interpreted as SATA CD devices on this architecture.

See: https://bugzilla.redhat.com/show_bug.cgi?id=1368300

func (SATACD) Properties

func (cd SATACD) Properties() Properties

Properties returns the properties of the SATA CD device.

type SCSI

type SCSI struct {
	// contains filtered or unexported fields
}

SCSI is a Virtio SCSI Controller device.

Example
package main

import (
	"fmt"

	"github.com/gentlemanautomaton/machina/qemu/qdev"
	"github.com/gentlemanautomaton/machina/qemu/qhost"
	"github.com/gentlemanautomaton/machina/qemu/qhost/blockdev"
)

func main() {
	var (
		host qhost.Resources
		topo qdev.Topology
	)

	// Allocate an I/O thread for the SCSI Controller to use.
	ioThread, err := host.AddIOThread()
	if err != nil {
		panic(err)
	}

	// Prepare a block graph the describes the I/O processing for the
	// disk image on the QEMU host.
	graph := host.BlockDevs()

	// We'll refer to the final node in the graph by its node name.
	name := blockdev.NodeName("testdrive")

	// Add a file protocol node to the graph that reads and writes to our
	// disk image.
	file, err := blockdev.File{
		Name: name.Child("file"),
		Path: blockdev.FilePath("/tmp/test-drive.raw"),
	}.Connect(graph)
	if err != nil {
		panic(err)
	}

	// Add a raw format node to the graph that interprets the file data
	// as a raw image.
	drive, err := blockdev.Raw{Name: name}.Connect(file)
	if err != nil {
		panic(err)
	}

	// Add a PCI Express Root Port that we'll connect the SCSI Controller to
	root, err := topo.AddRoot()
	if err != nil {
		panic(err)
	}

	// Add a SCSI Controller with the I/O Thread that we prepared earlier
	scsi, err := root.AddVirtioSCSI(ioThread)
	if err != nil {
		panic(err)
	}

	// Attach a SCSI Disk to the controller that's backed by the drive we
	// prepared earlier
	if _, err := scsi.AddDisk(drive); err != nil {
		panic(err)
	}

	// Print the configuration
	options := topo.Options()
	for _, option := range options {
		fmt.Printf("%s\n", option)
	}

}
Output:

-device ioh3420,id=pcie.1.0,chassis=0,bus=pcie.0,addr=1.0,multifunction=on
-device virtio-scsi-pci,id=scsi,bus=pcie.1.0,iothread=iothread.0,num_queues=4
-device scsi-hd,id=scsi.0.0,bus=scsi.0,channel=0,scsi-id=0,lun=0,drive=testdrive

func (*SCSI) AddCD

func (controller *SCSI) AddCD(bdev blockdev.Node) (SCSICD, error)

AddCD connects a SCSI CD-ROM device to the Virtio SCSI Controller.

func (*SCSI) AddDisk

func (controller *SCSI) AddDisk(bdev blockdev.Node, options ...SCSIHDOption) (SCSIHD, error)

AddDisk connects a SCSI HD device to the Virtio SCSI Controller.

func (*SCSI) Devices

func (controller *SCSI) Devices() []Device

Devices returns all of the SCSI devices attached to the controller.

func (*SCSI) Driver

func (controller *SCSI) Driver() Driver

Driver returns the driver for the Virtio SCSI Controller device, virtio-scsi-pci.

func (*SCSI) Properties

func (controller *SCSI) Properties() Properties

Properties returns the properties of the Virtio SCSI Controller device.

type SCSICD

type SCSICD struct {
	// contains filtered or unexported fields
}

SCSICD is a SCSI CD-ROM device.

func (SCSICD) Driver

func (cd SCSICD) Driver() Driver

Driver returns the driver for the SCSI CD device, scsi-cd.

func (SCSICD) Properties

func (cd SCSICD) Properties() Properties

Properties returns the properties of the SCSI CD device.

type SCSIHD

type SCSIHD struct {
	// contains filtered or unexported fields
}

SCSIHD is a SCSI hard disk device.

func (SCSIHD) Driver

func (disk SCSIHD) Driver() Driver

Driver returns the driver for the SCSI HD device, scsi-hd.

func (SCSIHD) Properties

func (disk SCSIHD) Properties() Properties

Properties returns the properties of the SCSI HD device.

type SCSIHDOption

type SCSIHDOption interface {
	// contains filtered or unexported methods
}

SCSIHDOption is an option for a SCSI HD device

type Serial

type Serial struct {
	// contains filtered or unexported fields
}

Serial is a Virtio Serial Controller device.

func (*Serial) AddPort

func (controller *Serial) AddPort(chardev chardev.ID, name string) (SerialPort, error)

AddPort connects a Serial Port device to the Virtio Serial Controller.

func (*Serial) Devices

func (controller *Serial) Devices() []Device

Devices returns all of the serial devices attached to the controller.

func (*Serial) Driver

func (controller *Serial) Driver() Driver

Driver returns the driver for the Virtio Serial Controller device, virtio-serial-pci.

func (*Serial) Properties

func (controller *Serial) Properties() Properties

Properties returns the properties of the Virtio Serial Controller device.

type SerialNumber

type SerialNumber string

SerialNumber defines a serial number for a QEMU disk device.

type SerialPort

type SerialPort struct {
	// contains filtered or unexported fields
}

SerialPort is a Virtio Serial Port device.

func (SerialPort) Driver

func (port SerialPort) Driver() Driver

Driver returns the driver for the Virtio Serial Port device, virtserialport.

func (SerialPort) Properties

func (port SerialPort) Properties() Properties

Properties returns the properties of the Virtio Serial Port device.

type Switch

type Switch interface {
	Devices() []Device
}

Switch is implemented by devices capable of hosting zero or more downstream devices.

type Topology

type Topology struct {
	// contains filtered or unexported fields
}

Topology describes the PCI Express device topology for a virtual machine. It holds a set of PCI Express Root ports present in the PCI Express Root Complex.

To add PCI Express devices, add PCI Express Roots then add devices to those roots.

TODO: Consider representing the PCI Express Root Complex with its own struct.

func (*Topology) AddCDROM

func (t *Topology) AddCDROM(bdev blockdev.Node) (SATACD, error)

AddCDROM connects a SATA CD-ROM device to the AHCI bus built into the q35 machine's ICH9 controller.

func (*Topology) AddPanic

func (t *Topology) AddPanic() (PVPanic, error)

AddPanic connects a paravirtualized panic device to the PCI Express Root Complex as an integrated PCI device.

func (*Topology) AddQXL

func (t *Topology) AddQXL() (*QXL, error)

AddQXL connects a PCI Express QXL display device to the PCI Express Root Complex.

func (*Topology) AddRoot

func (t *Topology) AddRoot() (*Root, error)

AddRoot adds a new PCI Express Root Port device to the PCI Express Root Complex.

An error is returned if the addition would cause the root complex to exceed MaxRoots.

TODO: Consider allowing the caller to supply a preferred bus address.

func (*Topology) Devices

func (t *Topology) Devices() []Device

Devices returns all of the PCI Express Roots within the PCI Express Root Complex.

func (*Topology) Options

func (t *Topology) Options() qemu.Options

Options returns a set of QEMU virtual machine options for creating the topology.

type USB

type USB struct {
	// contains filtered or unexported fields
}

USB is a PCI Express xHCI Controller device.

Example
package main

import (
	"fmt"

	"github.com/gentlemanautomaton/machina/qemu/qdev"
)

func main() {
	var topo qdev.Topology

	// Add a PCI Express Root Port that we'll connect the USB Controller to
	root, err := topo.AddRoot()
	if err != nil {
		panic(err)
	}

	// Add a USB Controller
	usb, err := root.AddUSB()
	if err != nil {
		panic(err)
	}

	// Attach a USB Tablet to the controller
	if _, err := usb.AddTablet(); err != nil {
		panic(err)
	}

	// Print the configuration
	options := topo.Options()
	for _, option := range options {
		fmt.Printf("%s\n", option)
	}

}
Output:

-device ioh3420,id=pcie.1.0,chassis=0,bus=pcie.0,addr=1.0,multifunction=on
-device qemu-xhci,id=usb,bus=pcie.1.0,p2=4,p3=4
-device usb-tablet,id=usb.0.1,bus=usb.0,port=1

func (*USB) AddRedir

func (controller *USB) AddRedir(chardev chardev.ID) (USBRedir, error)

AddRedir connects a USB redirection device to the xHCI Controller.

func (*USB) AddSCSI

func (controller *USB) AddSCSI() (*USBAttachedSCSI, error)

AddSCSI connects a USB Attached SCSI controller to the xHCI Controller.

func (*USB) AddStorage

func (controller *USB) AddStorage(bdev blockdev.Node) (USBStorage, error)

AddStorage connects a USB Storage device to the xHCI Controller.

func (*USB) AddTablet

func (controller *USB) AddTablet() (USBTablet, error)

AddTablet connects a USB tablet device to the xHCI Controller.

func (*USB) Devices

func (controller *USB) Devices() []Device

Devices returns all of the USB devices attached to the controller.

func (*USB) Driver

func (controller *USB) Driver() Driver

Driver returns the driver for the xHCI Controller device, qemu-xhci.

func (*USB) ID

func (controller *USB) ID() ID

ID returns the identifier of the xHCI Controller device.

func (*USB) Properties

func (controller *USB) Properties() Properties

Properties returns the properties of the xHCI Controller device.

type USBAttachedSCSI

type USBAttachedSCSI struct {
	// contains filtered or unexported fields
}

USBAttachedSCSI is a USB device that acts as a SCSI controller using the USB Attached SCSI protocol.

Example
package main

import (
	"fmt"

	"github.com/gentlemanautomaton/machina/qemu/qdev"
	"github.com/gentlemanautomaton/machina/qemu/qhost"
	"github.com/gentlemanautomaton/machina/qemu/qhost/blockdev"
)

func main() {
	var (
		resources qhost.Resources
		topo      qdev.Topology
	)

	// Grab a reference to the node graph for block devices.
	graph := resources.BlockDevs()

	// Prepare the disk's file protocol block device
	file, err := blockdev.File{
		Name:     "uas-disk",
		Path:     "uas-disk.iso",
		ReadOnly: true,
	}.Connect(graph)
	if err != nil {
		panic(err)
	}

	// Add a PCI Express Root Port that we'll connect the USB Controller to
	root, err := topo.AddRoot()
	if err != nil {
		panic(err)
	}

	// Add a USB Controller
	usb, err := root.AddUSB()
	if err != nil {
		panic(err)
	}

	// Add a USB Attached SCSI Controller to the USB Controller
	scsi, err := usb.AddSCSI()
	if err != nil {
		panic(err)
	}

	// Add a SCSI disk to the SCSI controller
	if _, err := scsi.AddDisk(file); err != nil {
		panic(err)
	}

	// Print the configuration
	options := append(resources.Options(), topo.Options()...)
	for _, option := range options {
		fmt.Printf("%s\n", option)
	}

}
Output:

-blockdev driver=file,node-name=uas-disk,read-only=on,filename=uas-disk.iso
-device ioh3420,id=pcie.1.0,chassis=0,bus=pcie.0,addr=1.0,multifunction=on
-device qemu-xhci,id=usb,bus=pcie.1.0,p2=4,p3=4
-device usb-uas,id=uas,bus=usb.0,port=1
-device scsi-hd,id=uas.0.0,bus=uas.0,channel=0,scsi-id=0,lun=0,drive=uas-disk

func (*USBAttachedSCSI) AddCD

func (controller *USBAttachedSCSI) AddCD(bdev blockdev.Node) (SCSICD, error)

AddCD connects a SCSI CD-ROM device to the Virtio SCSI Controller.

func (*USBAttachedSCSI) AddDisk

func (controller *USBAttachedSCSI) AddDisk(bdev blockdev.Node) (SCSIHD, error)

AddDisk connects a SCSI HD device to the USB SCSI Controller.

func (*USBAttachedSCSI) Devices

func (controller *USBAttachedSCSI) Devices() []Device

Devices returns all of the SCSI devices attached to the controller.

func (*USBAttachedSCSI) Driver

func (controller *USBAttachedSCSI) Driver() Driver

Driver returns the driver for the USB Attached SCSI device, usb-uas.

func (*USBAttachedSCSI) Properties

func (controller *USBAttachedSCSI) Properties() Properties

Properties returns the properties of the USB Redirection device.

type USBRedir

type USBRedir struct {
	// contains filtered or unexported fields
}

USBRedir is a USB Redirection device.

Documentation: https://www.spice-space.org/usbredir.html

func (USBRedir) Driver

func (redir USBRedir) Driver() Driver

Driver returns the driver for the USB Redirection device, usb-redir.

func (USBRedir) Properties

func (redir USBRedir) Properties() Properties

Properties returns the properties of the USB Redirection device.

type USBStorage

type USBStorage struct {
	// contains filtered or unexported fields
}

USBStorage is a USB Storage device.

Documentation: https://www.spice-space.org/usbredir.html

func (USBStorage) Driver

func (redir USBStorage) Driver() Driver

Driver returns the driver for the USB Redirection device, usb-redir.

func (USBStorage) Properties

func (redir USBStorage) Properties() Properties

Properties returns the properties of the USB Redirection device.

type USBTablet

type USBTablet struct {
	// contains filtered or unexported fields
}

USBTablet is a USB Tablet device.

func (USBTablet) Driver

func (tablet USBTablet) Driver() Driver

Driver returns the driver for the USB Tablet device, usb-tablet.

func (USBTablet) Properties

func (tablet USBTablet) Properties() Properties

Properties returns the properties of the USB Tablet device.

type Upstream

type Upstream interface {
	Downstream() Device
}

Upstream is implemented by devices capable of hosting a single downstream device.

type VFIO

type VFIO struct {
	// contains filtered or unexported fields
}

VFIO is a VFIO PCI passthrough device.

Example
package main

import (
	"fmt"

	"github.com/gentlemanautomaton/machina/qemu/qdev"
)

func main() {
	var topo qdev.Topology

	// Add a PCI Express Root Port that we'll connect the device to
	root, err := topo.AddRoot()
	if err != nil {
		panic(err)
	}

	// Add a VFIO PCI passthrough device to the root port
	if _, err := root.AddVFIO("/sys/bus/mdev/devices/79db70f1-92a5-4879-95f7-6325b66c1ff9"); err != nil {
		panic(err)
	}

	// Print the configuration
	options := topo.Options()
	for _, option := range options {
		fmt.Printf("%s\n", option)
	}

}
Output:

-device ioh3420,id=pcie.1.0,chassis=0,bus=pcie.0,addr=1.0,multifunction=on
-device vfio-pci,id=vfio.0,bus=pcie.1.0,sysfsdev=/sys/bus/mdev/devices/79db70f1-92a5-4879-95f7-6325b66c1ff9

func (VFIO) Driver

func (vfio VFIO) Driver() Driver

Driver returns the driver for the VFIO PCI passthrough device, virtio-pci.

func (VFIO) Properties

func (vfio VFIO) Properties() Properties

Properties returns the properties of the QXL display device.

type WWN

type WWN [16]byte

WWN defines a World Wide Name for a QEMU disk device.

type WalkFn

type WalkFn func(depth int, device Device)

WalkFn is capable of visiting QEMU devices.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL