Documentation
¶
Index ¶
- func DeviceLogger() *logrus.Entry
- func SetLogger(logger *logrus.Entry)
- type Device
- type DeviceManager
- type DeviceReceiver
- type MockDeviceReceiver
- func (mockDC *MockDeviceReceiver) AppendDevice(Device) error
- func (mockDC *MockDeviceReceiver) GetAndSetSandboxBlockIndex() (int, error)
- func (mockDC *MockDeviceReceiver) GetHypervisorType() string
- func (mockDC *MockDeviceReceiver) GetSandboxBlockOffset() int
- func (mockDC *MockDeviceReceiver) HotplugAddDevice(Device, config.DeviceType) error
- func (mockDC *MockDeviceReceiver) HotplugRemoveDevice(Device, config.DeviceType) error
- func (mockDC *MockDeviceReceiver) UnsetSandboxBlockIndex(int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeviceLogger ¶
DeviceLogger returns logger for device management
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