isolated_device

package
v0.3.9-9 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 23 Imported by: 7

Documentation

Index

Constants

View Source
const (
	CLASS_CODE_VGA = "0300"
	CLASS_CODE_3D  = "0302"
)
View Source
const (
	BUSID_REGEX = `[0-9a-fA-F]{2}:[0-9a-fA-F]{2}\.[0-9a-fA-F]`
	CODE_REGEX  = `[0-9a-fA-F]{4}`
	LABEL_REGEX = `[\w+\ \.\,\:\+\&\-\/\[\]\(\)]+`

	VFIO_PCI_KERNEL_DRIVER = "vfio-pci"
	DEFAULT_VGA_CMD        = " -vga std"
	// 在qemu/kvm下模拟Windows Hyper-V的一些半虚拟化特性,以便更好地使用Win虚拟机
	// http://blog.wikichoon.com/2014/07/enabling-hyper-v-enlightenments-with-kvm.html
	// 但实际测试不行,虚拟机不能运行nvidia驱动
	// DEFAULT_CPU_CMD = "host,kvm=off,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time"
	DEFAULT_CPU_CMD = "host,kvm=off"
)
View Source
const (
	RESOURCE = "isolated_devices"
)

Variables

This section is empty.

Functions

func GetApiResourceData

func GetApiResourceData(dev IDevice) *jsonutils.JSONDict

func GetUSBDevId

func GetUSBDevId(vendorId, devId, bus, addr string) string

func GetUSBDevQemuOptions

func GetUSBDevQemuOptions(vendorDevId string, addr string) (map[string]interface{}, error)

func NewGPUHPCDevice

func NewGPUHPCDevice(dev *PCIDevice) *sGPUHPCDevice

func ParseOutput

func ParseOutput(output []byte, doTrim bool) []string

func SyncDeviceInfo

func SyncDeviceInfo(session *mcclient.ClientSession, hostId string, dev IDevice) (jsonutils.JSONObject, error)

Types

type CloudDeviceInfo

type CloudDeviceInfo struct {
	Id             string `json:"id"`
	GuestId        string `json:"guest_id"`
	HostId         string `json:"host_id"`
	DevType        string `json:"dev_type"`
	VendorDeviceId string `json:"vendor_device_id"`
	Addr           string `json:"addr"`
	DetectedOnHost bool   `json:"detected_on_host"`
}

type HotPlugOption

type HotPlugOption struct {
	Device  string
	Options map[string]interface{}
}

type HotUnplugOption

type HotUnplugOption struct {
	Id string
}

type IDevice

type IDevice interface {
	String() string
	GetCloudId() string
	GetHostId() string
	SetHostId(hId string)
	GetGuestId() string
	GetVendorDeviceId() string
	GetAddr() string
	GetDeviceType() string
	GetModelName() string
	CustomProbe() error
	SetDeviceInfo(info CloudDeviceInfo)
	SetDetectedOnHost(isDetected bool)
	DetectByAddr() error

	GetPassthroughCmd(index int) string
	GetIOMMUGroupDeviceCmd() string
	GetVGACmd() string
	GetCPUCmd() string

	GetHotPlugOptions() ([]*HotPlugOption, error)
	GetHotUnplugOptions() ([]*HotUnplugOption, error)
}

type IHost

type IHost interface {
	GetHostId() string
	GetSession() *mcclient.ClientSession
}

type IOMMUGroup

type IOMMUGroup struct {
	// contains filtered or unexported fields
}

func NewIOMMUGroup

func NewIOMMUGroup() (*IOMMUGroup, error)

func (*IOMMUGroup) FindSameGroupDevs

func (g *IOMMUGroup) FindSameGroupDevs(devAddr string, vendorId string) []*PCIDevice

func (*IOMMUGroup) ListDevices

func (g *IOMMUGroup) ListDevices(groupNum, selfAddr, vendorId string) []*PCIDevice

func (*IOMMUGroup) String

func (g *IOMMUGroup) String() string

type IsolatedDeviceManager

type IsolatedDeviceManager interface {
	GetDevices() []IDevice
	GetDeviceByIdent(vendorDevId string, addr string) IDevice
	ProbePCIDevices(skipGPUs, skipUSBs bool) error
	StartDetachTask()
	BatchCustomProbe() error
	AppendDetachedDevice(dev *CloudDeviceInfo)
	GetQemuParams(devAddrs []string) *QemuParams
}

func NewManager

func NewManager(host IHost) IsolatedDeviceManager

type PCIDevice

type PCIDevice struct {
	Addr          string `json:"bus_id"`
	ClassName     string `json:"class_name"`
	ClassCode     string `json:"class_code"`
	VendorName    string `json:"vendor_name"`
	VendorId      string `json:"vendor_id"`
	DeviceName    string `json:"device_name"`
	DeviceId      string `json:"device_id"`
	SubvendorName string `json:"subvendor_name"`
	SubvendorId   string `json:"subvendor_id"`
	SubdeviceName string `json:"subdevice_name"`
	SubdeviceId   string `json:"subdevice_id"`
	ModelName     string `json:"model_name"`

	RestIOMMUGroupDevs []*PCIDevice `json:"-"`
}

func NewPCIDevice

func NewPCIDevice(line string) (*PCIDevice, error)

func NewPCIDevice2

func NewPCIDevice2(line string) *PCIDevice

func (*PCIDevice) GetVendorDeviceId

func (d *PCIDevice) GetVendorDeviceId() string

func (*PCIDevice) IsBootVGA

func (d *PCIDevice) IsBootVGA() (bool, error)

func (*PCIDevice) IsVFIOPCIDriverUsed

func (d *PCIDevice) IsVFIOPCIDriverUsed() bool

func (*PCIDevice) String

func (d *PCIDevice) String() string

type QemuParams

type QemuParams struct {
	Cpu     string
	Vga     string
	Devices []string
}

Jump to

Keyboard shortcuts

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