config

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: 12 Imported by: 48

Documentation

Index

Constants

View Source
const (
	// DeviceVFIO is the VFIO device type
	DeviceVFIO DeviceType = "vfio"

	// DeviceBlock is the block device type
	DeviceBlock DeviceType = "block"

	// DeviceGeneric is a generic device type
	DeviceGeneric DeviceType = "generic"

	//VhostUserSCSI - SCSI based vhost-user type
	VhostUserSCSI = "vhost-user-scsi-pci"

	//VhostUserNet - net based vhost-user type
	VhostUserNet = "virtio-net-pci"

	//VhostUserBlk represents a block vhostuser device type
	VhostUserBlk = "vhost-user-blk-pci"

	//VhostUserFS represents a virtio-fs vhostuser device type
	VhostUserFS = "vhost-user-fs-pci"
)
View Source
const (
	// VirtioMmio means use virtio-mmio for mmio based drives
	VirtioMmio = "virtio-mmio"

	// VirtioBlock means use virtio-blk for hotplugging drives
	VirtioBlock = "virtio-blk"

	// VirtioBlockCCW means use virtio-blk for hotplugging drives
	VirtioBlockCCW = "virtio-blk-ccw"

	// VirtioSCSI means use virtio-scsi for hotplugging drives
	VirtioSCSI = "virtio-scsi"

	// Nvdimm means use nvdimm for hotplugging drives
	Nvdimm = "nvdimm"
)
View Source
const (
	// Virtio9P means use virtio-9p for the shared file system
	Virtio9P = "virtio-9p"

	// VirtioFS means use virtio-fs for the shared file system
	VirtioFS = "virtio-fs"
)
View Source
const (
	// The OCI spec requires the major-minor number to be provided for a
	// device. We have chosen the below major numbers to represent
	// vhost-user devices.
	VhostUserBlkMajor  = 241
	VhostUserSCSIMajor = 242
)

Variables

View Source
var GetHostPathFunc = GetHostPath

GetHostPathFunc is function pointer used to mock GetHostPath in tests.

View Source
var GetVhostUserNodeStatFunc = GetVhostUserNodeStat

GetVhostUserNodeStatFunc is function pointer used to mock GetVhostUserNodeStat in tests. Through this functon, user can get device type information.

View Source
var SysBusPciDevicesPath = "/sys/bus/pci/devices"

SysBusPciDevicesPath is static string of /sys/bus/pci/devices

View Source
var SysDevPrefix = "/sys/dev"

SysDevPrefix is static string of /sys/dev

View Source
var SysIOMMUPath = "/sys/kernel/iommu_groups"

SysIOMMUPath is static string of /sys/kernel/iommu_groups

Functions

func GetHostPath

func GetHostPath(devInfo DeviceInfo, vhostUserStoreEnabled bool, vhostUserStorePath string) (string, error)

GetHostPath is used to fetch the host path for the device. The path passed in the spec refers to the path that should appear inside the container. We need to find the actual device path on the host based on the major-minor numbers of the device.

func GetVhostUserNodeStat

func GetVhostUserNodeStat(devNodePath string, devNodeStat *unix.Stat_t) (err error)

func SetLogger

func SetLogger(logger *logrus.Entry)

SetLogger sets up a logger for this pkg

Types

type BlockDrive

type BlockDrive struct {
	// File is the path to the disk-image/device which will be used with this drive
	File string

	// Format of the drive
	Format string

	// ID is used to identify this drive in the hypervisor options.
	ID string

	// Index assigned to the drive. In case of virtio-scsi, this is used as SCSI LUN index
	Index int

	// MmioAddr is used to identify the slot at which the drive is attached (order?).
	MmioAddr string

	// PCIPath is the PCI path used to identify the slot at which the drive is attached.
	PCIPath vcTypes.PciPath

	// SCSI Address of the block device, in case the device is attached using SCSI driver
	// SCSI address is in the format SCSI-Id:LUN
	SCSIAddr string

	// NvdimmID is the nvdimm id inside the VM
	NvdimmID string

	// VirtPath at which the device appears inside the VM, outside of the container mount namespace
	VirtPath string

	// DevNo identifies the css bus id for virtio-blk-ccw
	DevNo string

	// ShareRW enables multiple qemu instances to share the File
	ShareRW bool

	// ReadOnly sets the device file readonly
	ReadOnly bool

	// Pmem enables persistent memory. Use File as backing file
	// for a nvdimm device in the guest
	Pmem bool
}

BlockDrive represents a block storage drive which may be used in case the storage driver has an underlying block storage device.

type DeviceInfo

type DeviceInfo struct {
	// Hostpath is device path on host
	HostPath string

	// ContainerPath is device path inside container
	ContainerPath string `json:"-"`

	// Type of device: c, b, u or p
	// c , u - character(unbuffered)
	// p - FIFO
	// b - block(buffered) special file
	// More info in mknod(1).
	DevType string

	// Major, minor numbers for device.
	Major int64
	Minor int64

	// Pmem enabled persistent memory. Use HostPath as backing file
	// for a nvdimm device in the guest.
	Pmem bool

	// If applicable, should this device be considered RO
	ReadOnly bool

	// ColdPlug specifies whether the device must be cold plugged (true)
	// or hot plugged (false).
	ColdPlug bool

	// FileMode permission bits for the device.
	FileMode os.FileMode

	// id of the device owner.
	UID uint32

	// id of the device group.
	GID uint32

	// ID for the device that is passed to the hypervisor.
	ID string

	// DriverOptions is specific options for each device driver
	// for example, for BlockDevice, we can set DriverOptions["blockDriver"]="virtio-blk"
	DriverOptions map[string]string
}

DeviceInfo is an embedded type that contains device data common to all types of devices.

func PmemDeviceInfo

func PmemDeviceInfo(source, destination string) (*DeviceInfo, error)

PmemDeviceInfo returns a DeviceInfo if a loop device is mounted on source, and the backing file of the loop device has the PFN signature.

type DeviceType

type DeviceType string

DeviceType indicates device type

type RNGDev

type RNGDev struct {
	// ID is used to identify the device in the hypervisor options.
	ID string
	// Filename is the file to use as entropy source.
	Filename string
}

RNGDev represents a random number generator device

type VFIODev

type VFIODev struct {
	// IsPCIe specifies device is PCIe or PCI
	IsPCIe bool

	// Type of VFIO device
	Type VFIODeviceType

	// ID is used to identify this drive in the hypervisor options.
	ID string

	// BDF (Bus:Device.Function) of the PCI address
	BDF string

	// sysfsdev of VFIO mediated device
	SysfsDev string

	// VendorID specifies vendor id
	VendorID string

	// DeviceID specifies device id
	DeviceID string

	// PCI Class Code
	Class string

	// Bus of VFIO PCIe device
	Bus string
}

VFIODev represents a VFIO drive used for hotplugging

type VFIODeviceType

type VFIODeviceType uint32

VFIODeviceType indicates VFIO device type

const (
	// VFIODeviceErrorType is the error type of VFIO device
	VFIODeviceErrorType VFIODeviceType = iota

	// VFIODeviceNormalType is a normal VFIO device type
	VFIODeviceNormalType

	// VFIODeviceMediatedType is a VFIO mediated device type
	VFIODeviceMediatedType
)

type VhostUserDeviceAttrs

type VhostUserDeviceAttrs struct {
	DevID      string
	SocketPath string
	Type       DeviceType

	// MacAddress is only meaningful for vhost user net device
	MacAddress string

	// These are only meaningful for vhost user fs devices
	Tag       string
	CacheSize uint32
	Cache     string

	// PCIPath is the PCI path used to identify the slot at which
	// the drive is attached.  It is only meaningful for vhost
	// user block devices
	PCIPath vcTypes.PciPath

	// Block index of the device if assigned
	Index int
}

VhostUserDeviceAttrs represents data shared by most vhost-user devices

Jump to

Keyboard shortcuts

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