mdevfs

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: 7 Imported by: 0

Documentation

Overview

Package mdevfs facilitates communication with mediated devices through the local sysfs file system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Supported

func Supported() bool

Supported returns true if the local system supports mediated devices.

TODO: Do more than just checking for the presence of the PCI bus.

Types

type MediatedDevice

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

MediatedDevice provides access to a mediated device through the local file system.

func NewMediatedDevice

func NewMediatedDevice(id machina.DeviceID) MediatedDevice

NewMediatedDevice prepares access to a mediated device through the local file system. It expects the device to be present in /sys/bus/mdev/devices.

func (MediatedDevice) Exists

func (mdev MediatedDevice) Exists() (bool, error)

Exists returns true if the mediated device already exists.

func (MediatedDevice) Path

func (mdev MediatedDevice) Path() string

Path returns the sysfs path for the mediated device.

func (MediatedDevice) Remove

func (mdev MediatedDevice) Remove() error

Remove attempts to remove the mediated device from the system.

type PhysicalDevice

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

PhysicalDevice provides access to a physical PCI device through the local file system.

func NewPhysicalDevice

func NewPhysicalDevice(address machina.DeviceAddress) PhysicalDevice

NewPhysicalDevice returns a physical device accessor that will access a PCI device with the given address through the local file system. It expects the device to be present in /sys/bus/pci/devices.

func (PhysicalDevice) Address

func (pdev PhysicalDevice) Address() machina.DeviceAddress

Address returns the PCI address for the physical device.

func (PhysicalDevice) Exists

func (pdev PhysicalDevice) Exists() (bool, error)

Exists returns true if the sysfs path for the device exists.

func (PhysicalDevice) Path

func (pdev PhysicalDevice) Path() string

Path returns the sysfs path for the physical device.

func (PhysicalDevice) Types

func (pdev PhysicalDevice) Types() (types TypeList, err error)

Types returns the set of mediated device types that are supported by the physical device.

type Type

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

Type describes a supported type offered by a mediated device on the local system.

func (Type) AvailableInstances

func (t Type) AvailableInstances() (int, error)

AvailableInstances returns the number of instances currently available for the supported type.

The value is queried at the of the function call, and is not cached.

func (Type) Create

func (t Type) Create(id machina.DeviceID) error

Create requests the creation of a mediated device of type t with the given device ID.

func (Type) Description

func (t Type) Description() string

Description returns the description of the supported type, which is optional.

func (Type) ID

func (t Type) ID() string

ID returns the supported type identifier.

func (Type) Name

func (t Type) Name() string

Name returns the name of the supported type, which is optional.

func (Type) Path

func (t Type) Path() string

Path returns the sysfs path for the supported type on the local system.

type TypeList

type TypeList []Type

TypeList holds a set of mediated device types.

func (TypeList) FindName

func (list TypeList) FindName(name machina.MediatedDeviceType) (typ Type, ok bool)

FindName returns the first supported type with the given name, if present in the list.

Jump to

Keyboard shortcuts

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