api

package
v0.0.0-...-e90dc35 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: Apache-2.0, Apache-2.0 Imports: 2 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)
	// 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 and
	// vfio device returns []*config.VFIODev
	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
}

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
}

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)
	DecrementSandboxBlockIndex() error

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

func (mockDC *MockDeviceReceiver) DecrementSandboxBlockIndex() error

DecrementSandboxBlockIndex decreases virtio-blk index by one

func (*MockDeviceReceiver) GetAndSetSandboxBlockIndex

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

GetAndSetSandboxBlockIndex is used for get and set virtio-blk indexes

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

Jump to

Keyboard shortcuts

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