Documentation
¶
Index ¶
- Constants
- Variables
- func GetApiResourceData(dev IDevice) *jsonutils.JSONDict
- func GetPCIStrByAddr(addr string) ([]string, error)
- func GetUSBDevId(vendorId, devId, bus, addr string) string
- func GetUSBDevQemuOptions(vendorDevId string, addr string) (map[string]string, error)
- func NewGPUHPCDevice(dev *PCIDevice) *sGPUHPCDevice
- func NewNvidiaVgpuDevice(dev *PCIDevice, devType, mdevId, model string, profile map[string]string) *sNVIDIAVgpuDevice
- func NewSRIOVGpuDevice(dev *PCIDevice, devType string) *sSRIOVGpuDevice
- func NewSRIOVNicDevice(dev *PCIDevice, devType, wireId, pfName string, virtfn int, ...) *sSRIOVNicDevice
- func NewSRIOVOffloadNicDevice(dev *PCIDevice, devType, wireId, pfName string, virtfn int, ifname string) *sOvsOffloadNicDevice
- func ParseOutput(output []byte, doTrim bool) []string
- func RegisterContainerDeviceManager(man IContainerDeviceManager)
- func SyncDeviceInfo(session *mcclient.ClientSession, hostId string, dev IDevice) (jsonutils.JSONObject, error)
- type CloudDeviceInfo
- type ContainerDevice
- type ContainerDeviceConfiguration
- type ContainerDeviceType
- type HostNic
- type HotPlugOption
- type HotUnplugOption
- type IContainerDeviceManager
- type IDevice
- type IExecutor
- type IHost
- type IOMMUGroup
- type IsolatedDeviceManager
- type IsolatedDeviceModel
- type PCIDevice
- type QemuParams
- type SBaseDevice
- func (dev *SBaseDevice) CustomProbe(idx int) error
- func (dev *SBaseDevice) DetectByAddr() error
- func (dev *SBaseDevice) GetAddr() string
- func (dev *SBaseDevice) GetCloudId() string
- func (dev *SBaseDevice) GetDevicePath() string
- func (dev *SBaseDevice) GetDeviceType() string
- func (dev *SBaseDevice) GetGuestId() string
- func (dev *SBaseDevice) GetHostId() string
- func (dev *SBaseDevice) GetHotPlugOptions(isolatedDev *desc.SGuestIsolatedDevice, guestDesc *desc.SGuestDesc) ([]*HotPlugOption, error)
- func (dev *SBaseDevice) GetHotUnplugOptions(isolatedDev *desc.SGuestIsolatedDevice) ([]*HotUnplugOption, error)
- func (dev *SBaseDevice) GetIOMMUGroupDeviceCmd() string
- func (dev *SBaseDevice) GetIOMMUGroupRestAddrs() []string
- func (dev *SBaseDevice) GetKernelDriver() (string, error)
- func (dev *SBaseDevice) GetMdevId() string
- func (dev *SBaseDevice) GetModelName() string
- func (dev *SBaseDevice) GetNVIDIAVgpuProfile() map[string]string
- func (dev *SBaseDevice) GetNVMESizeMB() int
- func (dev *SBaseDevice) GetNumaNode() (int, error)
- func (dev *SBaseDevice) GetNvidiaMpsMemoryLimit() int
- func (dev *SBaseDevice) GetNvidiaMpsMemoryTotal() int
- func (dev *SBaseDevice) GetNvidiaMpsThreadPercentage() int
- func (dev *SBaseDevice) GetOvsOffloadInterfaceName() string
- func (dev *SBaseDevice) GetPCIEInfo() *api.IsolatedDevicePCIEInfo
- func (dev *SBaseDevice) GetPassthroughCmd(_ int) string
- func (dev *SBaseDevice) GetPassthroughOptions() map[string]string
- func (dev *SBaseDevice) GetPfName() string
- func (dev *SBaseDevice) GetVendorDeviceId() string
- func (dev *SBaseDevice) GetVirtfn() int
- func (dev *SBaseDevice) GetWireId() string
- func (dev *SBaseDevice) IsInfinibandNic() bool
- func (dev *SBaseDevice) SetAddr(addr string)
- func (dev *SBaseDevice) SetDeviceInfo(info CloudDeviceInfo)
- func (dev *SBaseDevice) SetHostId(hId string)
- func (dev *SBaseDevice) SetModelName(modelName string)
- func (dev *SBaseDevice) String() string
- type SDefaultExecutor
Constants ¶
View Source
const ( CLASS_CODE_VGA = "0300" CLASS_CODE_3D = "0302" CLASS_CODE_DISP = "0380" )
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 ¶
View Source
var ( GpuClassCodes = []string{ CLASS_CODE_VGA, CLASS_CODE_3D, CLASS_CODE_DISP, } )
Functions ¶
func GetApiResourceData ¶
func GetPCIStrByAddr ¶
func GetUSBDevId ¶
func GetUSBDevQemuOptions ¶
func NewGPUHPCDevice ¶
func NewGPUHPCDevice(dev *PCIDevice) *sGPUHPCDevice
func NewNvidiaVgpuDevice ¶
func NewSRIOVGpuDevice ¶
func NewSRIOVNicDevice ¶
func ParseOutput ¶
func RegisterContainerDeviceManager ¶
func RegisterContainerDeviceManager(man IContainerDeviceManager)
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"` MdevId string `json:"mdev_id"` }
type ContainerDevice ¶
type ContainerDevice struct { Path string `json:"path"` Type ContainerDeviceType `json:"type"` VirtualNumber int `json:"virtual_number"` }
type ContainerDeviceConfiguration ¶
type ContainerDeviceConfiguration struct {
Devices []*ContainerDevice `json:"devices"`
}
type ContainerDeviceType ¶
type ContainerDeviceType string
const ( ContainerDeviceTypeCphAMDGPU ContainerDeviceType = api.CONTAINER_DEV_CPH_AMD_GPU ContainerDeviceTypeCphASOPBinder ContainerDeviceType = api.CONTAINER_DEV_CPH_AOSP_BINDER ContainerNetintCAASIC ContainerDeviceType = api.CONTAINER_DEV_NETINT_CA_ASIC ContainerNetintCAQuadra ContainerDeviceType = api.CONTAINER_DEV_NETINT_CA_QUADRA ContainerDeviceTypeNvidiaGpu ContainerDeviceType = api.CONTAINER_DEV_NVIDIA_GPU ContainerDeviceTypeNvidiaMps ContainerDeviceType = api.CONTAINER_DEV_NVIDIA_MPS ContainerDeviceTypeAscendNpu ContainerDeviceType = api.CONTAINER_DEV_ASCEND_NPU ContainerDeviceTypeVastaitechGpu ContainerDeviceType = api.CONTAINER_DEV_VASTAITECH_GPU )
type HotPlugOption ¶
type HotUnplugOption ¶
type HotUnplugOption struct {
Id string
}
type IContainerDeviceManager ¶
type IContainerDeviceManager interface { GetType() ContainerDeviceType NewDevices(dev *ContainerDevice) ([]IDevice, error) NewContainerDevices(input *hostapi.ContainerCreateInput, dev *hostapi.ContainerDevice) ([]*runtimeapi.Device, []*runtimeapi.Device, error) ProbeDevices() ([]IDevice, error) GetContainerExtraConfigures(devs []*hostapi.ContainerDevice) ([]*runtimeapi.KeyValue, []*runtimeapi.Mount) }
func GetContainerDeviceManager ¶
func GetContainerDeviceManager(t ContainerDeviceType) (IContainerDeviceManager, error)
type IDevice ¶
type IDevice interface { String() string GetCloudId() string GetHostId() string SetHostId(hId string) GetGuestId() string GetWireId() string IsInfinibandNic() bool GetOvsOffloadInterfaceName() string GetVendorDeviceId() string GetAddr() string GetDeviceType() string GetModelName() string CustomProbe(idx int) error SetDeviceInfo(info CloudDeviceInfo) DetectByAddr() error GetPassthroughOptions() map[string]string GetPassthroughCmd(index int) string GetIOMMUGroupDeviceCmd() string GetIOMMUGroupRestAddrs() []string GetVGACmd() string GetCPUCmd() string GetQemuId() string GetNumaNode() (int, error) // sriov nic GetPfName() string GetVirtfn() int // NVMe disk GetNVMESizeMB() int // legacy nvidia vgpu GetMdevId() string GetNVIDIAVgpuProfile() map[string]string GetHotPlugOptions(isolatedDev *desc.SGuestIsolatedDevice, guestDesc *desc.SGuestDesc) ([]*HotPlugOption, error) GetHotUnplugOptions(isolatedDev *desc.SGuestIsolatedDevice) ([]*HotUnplugOption, error) // Get extra PCIE information GetPCIEInfo() *api.IsolatedDevicePCIEInfo GetDevicePath() string // mps infos GetNvidiaMpsMemoryLimit() int GetNvidiaMpsMemoryTotal() int GetNvidiaMpsThreadPercentage() int }
type IExecutor ¶
func GetDefaultExecutor ¶
func GetDefaultExecutor() IExecutor
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, addr, mdevId string) IDevice GetDeviceByAddr(addr string) IDevice ProbePCIDevices(skipGPUs, skipUSBs, skipCustomDevs bool, sriovNics, ovsOffloadNics []HostNic, nvmePciDisks, amdVgpuPFs, nvidiaVgpuPFs []string, enableCudaMps, enableContainerNPU, enableWhitelist bool) StartDetachTask() BatchCustomProbe() AppendDetachedDevice(dev *CloudDeviceInfo) GetQemuParams(devAddrs []string) *QemuParams }
func NewManager ¶
func NewManager(host IHost) IsolatedDeviceManager
type IsolatedDeviceModel ¶
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:"-"` PCIEInfo *api.IsolatedDevicePCIEInfo `json:"pcie_info"` }
func NewPCIDevice2 ¶
func (*PCIDevice) GetVendorDeviceId ¶
func (*PCIDevice) IsVFIOPCIDriverUsed ¶
type QemuParams ¶
type SBaseDevice ¶
type SBaseDevice struct {
// contains filtered or unexported fields
}
func NewBaseDevice ¶
func NewBaseDevice(dev *PCIDevice, devType string) *SBaseDevice
func (*SBaseDevice) CustomProbe ¶
func (dev *SBaseDevice) CustomProbe(idx int) error
func (*SBaseDevice) DetectByAddr ¶
func (dev *SBaseDevice) DetectByAddr() error
func (*SBaseDevice) GetAddr ¶
func (dev *SBaseDevice) GetAddr() string
func (*SBaseDevice) GetCloudId ¶
func (dev *SBaseDevice) GetCloudId() string
func (*SBaseDevice) GetDevicePath ¶
func (dev *SBaseDevice) GetDevicePath() string
func (*SBaseDevice) GetDeviceType ¶
func (dev *SBaseDevice) GetDeviceType() string
func (*SBaseDevice) GetGuestId ¶
func (dev *SBaseDevice) GetGuestId() string
func (*SBaseDevice) GetHostId ¶
func (dev *SBaseDevice) GetHostId() string
func (*SBaseDevice) GetHotPlugOptions ¶
func (dev *SBaseDevice) GetHotPlugOptions(isolatedDev *desc.SGuestIsolatedDevice, guestDesc *desc.SGuestDesc) ([]*HotPlugOption, error)
func (*SBaseDevice) GetHotUnplugOptions ¶
func (dev *SBaseDevice) GetHotUnplugOptions(isolatedDev *desc.SGuestIsolatedDevice) ([]*HotUnplugOption, error)
func (*SBaseDevice) GetIOMMUGroupDeviceCmd ¶
func (dev *SBaseDevice) GetIOMMUGroupDeviceCmd() string
func (*SBaseDevice) GetIOMMUGroupRestAddrs ¶
func (dev *SBaseDevice) GetIOMMUGroupRestAddrs() []string
func (*SBaseDevice) GetKernelDriver ¶
func (dev *SBaseDevice) GetKernelDriver() (string, error)
func (*SBaseDevice) GetMdevId ¶
func (dev *SBaseDevice) GetMdevId() string
func (*SBaseDevice) GetModelName ¶
func (dev *SBaseDevice) GetModelName() string
func (*SBaseDevice) GetNVIDIAVgpuProfile ¶
func (dev *SBaseDevice) GetNVIDIAVgpuProfile() map[string]string
func (*SBaseDevice) GetNVMESizeMB ¶
func (dev *SBaseDevice) GetNVMESizeMB() int
func (*SBaseDevice) GetNumaNode ¶
func (dev *SBaseDevice) GetNumaNode() (int, error)
func (*SBaseDevice) GetNvidiaMpsMemoryLimit ¶
func (dev *SBaseDevice) GetNvidiaMpsMemoryLimit() int
func (*SBaseDevice) GetNvidiaMpsMemoryTotal ¶
func (dev *SBaseDevice) GetNvidiaMpsMemoryTotal() int
func (*SBaseDevice) GetNvidiaMpsThreadPercentage ¶
func (dev *SBaseDevice) GetNvidiaMpsThreadPercentage() int
func (*SBaseDevice) GetOvsOffloadInterfaceName ¶
func (dev *SBaseDevice) GetOvsOffloadInterfaceName() string
func (*SBaseDevice) GetPCIEInfo ¶
func (dev *SBaseDevice) GetPCIEInfo() *api.IsolatedDevicePCIEInfo
func (*SBaseDevice) GetPassthroughCmd ¶
func (dev *SBaseDevice) GetPassthroughCmd(_ int) string
func (*SBaseDevice) GetPassthroughOptions ¶
func (dev *SBaseDevice) GetPassthroughOptions() map[string]string
func (*SBaseDevice) GetPfName ¶
func (dev *SBaseDevice) GetPfName() string
func (*SBaseDevice) GetVendorDeviceId ¶
func (dev *SBaseDevice) GetVendorDeviceId() string
func (*SBaseDevice) GetVirtfn ¶
func (dev *SBaseDevice) GetVirtfn() int
func (*SBaseDevice) GetWireId ¶
func (dev *SBaseDevice) GetWireId() string
func (*SBaseDevice) IsInfinibandNic ¶
func (dev *SBaseDevice) IsInfinibandNic() bool
func (*SBaseDevice) SetAddr ¶
func (dev *SBaseDevice) SetAddr(addr string)
func (*SBaseDevice) SetDeviceInfo ¶
func (dev *SBaseDevice) SetDeviceInfo(info CloudDeviceInfo)
func (*SBaseDevice) SetHostId ¶
func (dev *SBaseDevice) SetHostId(hId string)
func (*SBaseDevice) SetModelName ¶
func (dev *SBaseDevice) SetModelName(modelName string)
func (*SBaseDevice) String ¶
func (dev *SBaseDevice) String() string
type SDefaultExecutor ¶
type SDefaultExecutor struct{}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.