mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-30 18:23:35 +08:00
fix(region): add hypervisor props on isolated device capabilites (#21321)
This commit is contained in:
@@ -42,6 +42,16 @@ var VALID_PASSTHROUGH_TYPES = []string{
|
||||
GPU_VGA_TYPE, NVME_PT_TYPE, SRIOV_VGPU_TYPE, LEGACY_VGPU_TYPE,
|
||||
}
|
||||
|
||||
var VITRUAL_DEVICE_TYPES = []string{
|
||||
LEGACY_VGPU_TYPE,
|
||||
CONTAINER_DEV_CPH_AMD_GPU,
|
||||
CONTAINER_DEV_CPH_AOSP_BINDER,
|
||||
CONTAINER_DEV_NETINT_CA_QUADRA,
|
||||
CONTAINER_DEV_NETINT_CA_ASIC,
|
||||
CONTAINER_DEV_NVIDIA_MPS,
|
||||
CONTAINER_DEV_ASCEND_NPU,
|
||||
}
|
||||
|
||||
var ID_VENDOR_MAP = map[string]string{
|
||||
NVIDIA_VENDOR_ID: "NVIDIA",
|
||||
AMD_VENDOR_ID: "AMD",
|
||||
|
||||
@@ -840,6 +840,9 @@ type PCIDevModelTypes struct {
|
||||
Model string
|
||||
DevType string
|
||||
SizeMB int
|
||||
|
||||
VirtualDev bool
|
||||
Hypervisor string
|
||||
}
|
||||
|
||||
func getIsolatedDeviceInfo(ctx context.Context, userCred mcclient.TokenCredential, region *SCloudregion, zone *SZone, domainId string) ([]string, []PCIDevModelTypes) {
|
||||
@@ -881,12 +884,23 @@ func getIsolatedDeviceInfo(ctx context.Context, userCred mcclient.TokenCredentia
|
||||
for rows.Next() {
|
||||
var m, t string
|
||||
var sizeMB int
|
||||
var vdev bool
|
||||
var hypervisor string
|
||||
rows.Scan(&m, &t, &sizeMB)
|
||||
|
||||
if m == "" {
|
||||
continue
|
||||
}
|
||||
gpus = append(gpus, PCIDevModelTypes{m, t, sizeMB})
|
||||
if utils.IsInStringArray(t, api.VITRUAL_DEVICE_TYPES) {
|
||||
vdev = true
|
||||
}
|
||||
if utils.IsInStringArray(t, api.VALID_CONTAINER_DEVICE_TYPES) {
|
||||
hypervisor = api.HYPERVISOR_POD
|
||||
} else {
|
||||
hypervisor = api.HYPERVISOR_KVM
|
||||
}
|
||||
|
||||
gpus = append(gpus, PCIDevModelTypes{m, t, sizeMB, vdev, hypervisor})
|
||||
|
||||
if !utils.IsInStringArray(m, gpuModels) {
|
||||
gpuModels = append(gpuModels, m)
|
||||
|
||||
@@ -952,7 +952,19 @@ func (self *SIsolatedDevice) GetSpec(statusCheck bool) *jsonutils.JSONDict {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
var vdev bool
|
||||
var hypervisor string
|
||||
if utils.IsInStringArray(self.DevType, api.VITRUAL_DEVICE_TYPES) {
|
||||
vdev = true
|
||||
}
|
||||
if utils.IsInStringArray(self.DevType, api.VALID_CONTAINER_DEVICE_TYPES) {
|
||||
hypervisor = api.HYPERVISOR_POD
|
||||
} else {
|
||||
hypervisor = api.HYPERVISOR_KVM
|
||||
}
|
||||
ret := jsonutils.NewDict()
|
||||
ret.Set("virtual_dev", jsonutils.NewBool(vdev))
|
||||
ret.Set("hypervisor", jsonutils.NewString(hypervisor))
|
||||
ret.Set("dev_type", jsonutils.NewString(self.DevType))
|
||||
ret.Set("model", jsonutils.NewString(self.Model))
|
||||
ret.Set("pci_id", jsonutils.NewString(self.VendorDeviceId))
|
||||
|
||||
Reference in New Issue
Block a user