api

package
v0.0.0-...-04f2983 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 26 modules, 113 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeviceLogger

func DeviceLogger() *logrus.Entry

DeviceLogger returns logger for device management

func SetLogger

func SetLogger(logger *logrus.Entry)

SetLogger sets the logger for device api package.

Types

type Device

type Device interface {
	Attach(DeviceReceiver) error
	Detach(DeviceReceiver) error

	// ID returns device identifier
	DeviceID() string

	// DeviceType indicates which kind of device it is
	// e.g. block, vfio or vhost user
	DeviceType() config.DeviceType

	// GetMajorMinor returns major and minor numbers
	GetMajorMinor() (int64, int64)

	// GetHostPath return the device path in the host
	GetHostPath() string

	// GetDeviceInfo returns device specific data used for hotplugging by hypervisor
	// Caller could cast the return value to device specific struct
	// e.g. Block device returns *config.BlockDrive,
	// vfio device returns []*config.VFIODev,
	// VhostUser device returns []*config.VhostUserDeviceAttrs
	GetDeviceInfo() interface{}

	// GetAttachCount returns how many times the device has been attached
	GetAttachCount() uint

	// Reference adds one reference to device then returns final ref count
	Reference() uint

	// Dereference removes one reference to device then returns final ref count
	Dereference() uint

	// Save converts Device to DeviceState
	Save() persistapi.DeviceState

	// Load loads DeviceState and converts it to specific device
	Load(persistapi.DeviceState)
}

Device is the virtcontainers device interface.

type DeviceManager

type DeviceManager interface {
	NewDevice(config.DeviceInfo) (Device, error)
	RemoveDevice(string) error
	AttachDevice(string, DeviceReceiver) error
	DetachDevice(string, DeviceReceiver) error
	IsDeviceAttached(string) bool
	GetDeviceByID(string) Device
	GetAllDevices() []Device
	LoadDevices([]persistapi.DeviceState)
}

DeviceManager can be used to create a new device, this can be used as single device management object.

type DeviceReceiver

type DeviceReceiver interface {
	// these are for hotplug/hot-unplug devices to/from hypervisor
	HotplugAddDevice(Device, config.DeviceType) error
	HotplugRemoveDevice(Device, config.DeviceType) error

	// this is only for virtio-blk and virtio-scsi support
	GetAndSetSandboxBlockIndex() (int, error)

	// Offset w.r.t. the sandbox block index, to be used when determining
	// a virtio-block drive name.
	GetSandboxBlockOffset() int

	UnsetSandboxBlockIndex(int) error
	GetHypervisorType() string

	// this is for appending device to hypervisor boot params
	AppendDevice(Device) error
}

DeviceReceiver is an interface used for accepting devices a device should be attached/added/plugged to a DeviceReceiver

type MockDeviceReceiver

type MockDeviceReceiver struct{}

MockDeviceReceiver is a fake DeviceReceiver API implementation only used for test

func (*MockDeviceReceiver) AppendDevice

func (mockDC *MockDeviceReceiver) AppendDevice(Device) error

AppendDevice adds new vhost user device

func (*MockDeviceReceiver) GetAndSetSandboxBlockIndex

func (mockDC *MockDeviceReceiver) GetAndSetSandboxBlockIndex() (int, error)

GetAndSetSandboxBlockIndex is used for get and set virtio-blk indexes

func (*MockDeviceReceiver) GetHypervisorType

func (mockDC *MockDeviceReceiver) GetHypervisorType() string

GetHypervisorType is used for getting Hypervisor name currently used.

func (*MockDeviceReceiver) GetSandboxBlockOffset

func (mockDC *MockDeviceReceiver) GetSandboxBlockOffset() int

GetSandboxBlockOffset returns an offset w.r.t. the sandbox block index

func (*MockDeviceReceiver) HotplugAddDevice

func (mockDC *MockDeviceReceiver) HotplugAddDevice(Device, config.DeviceType) error

HotplugAddDevice adds a new device

func (*MockDeviceReceiver) HotplugRemoveDevice

func (mockDC *MockDeviceReceiver) HotplugRemoveDevice(Device, config.DeviceType) error

HotplugRemoveDevice removes a device

func (*MockDeviceReceiver) UnsetSandboxBlockIndex

func (mockDC *MockDeviceReceiver) UnsetSandboxBlockIndex(int) error

DecrementSandboxBlockIndex decreases virtio-blk index by one

Jump to

Keyboard shortcuts

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