api

package
v0.0.0-...-5cef3e7 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

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)
	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) 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