diff --git a/pkg/compute/models/isolated_devices.go b/pkg/compute/models/isolated_devices.go index ded7ae7b7a..83a0e05372 100644 --- a/pkg/compute/models/isolated_devices.go +++ b/pkg/compute/models/isolated_devices.go @@ -76,7 +76,7 @@ type SIsolatedDevice struct { HostId string `width:"36" charset:"ascii" nullable:"false" default:"" index:"true" list:"admin" create:"admin_required"` // Column(VARCHAR(36, charset='ascii'), nullable=False, default='', server_default='', index=True) // # PCI / GPU-HPC / GPU-VGA / USB / NIC - DevType string `width:"16" charset:"ascii" nullable:"false" default:"" index:"true" list:"admin" create:"admin_required"` // Column(VARCHAR(16, charset='ascii'), nullable=False, default='', server_default='', index=True) + DevType string `width:"16" charset:"ascii" nullable:"false" default:"" index:"true" list:"admin" create:"admin_required" update:"admin"` // Column(VARCHAR(16, charset='ascii'), nullable=False, default='', server_default='', index=True) // # Specific device name read from lspci command, e.g. `Tesla K40m` ... Model string `width:"32" charset:"ascii" nullable:"false" default:"" index:"true" list:"admin" create:"admin_required" update:"admin"` // Column(VARCHAR(32, charset='ascii'), nullable=False, default='', server_default='', index=True) diff --git a/pkg/hostman/isolated_device/isolated_device.go b/pkg/hostman/isolated_device/isolated_device.go index 1cf330d52c..51770b2422 100644 --- a/pkg/hostman/isolated_device/isolated_device.go +++ b/pkg/hostman/isolated_device/isolated_device.go @@ -26,6 +26,7 @@ import ( "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" + api "yunion.io/x/onecloud/pkg/apis/compute" o "yunion.io/x/onecloud/pkg/hostman/options" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules" @@ -35,12 +36,6 @@ import ( ) const ( - // TODO: merge models/isolated_devices in new file - DIRECT_PCI_TYPE = "PCI" - GPU_HPC_TYPE = "GPU-HPC" // # for compute - GPU_VGA_TYPE = "GPU-VGA" // # for display - USB_TYPE = "USB" - CLASS_CODE_VGA = "0300" CLASS_CODE_3D = "0302" ) @@ -381,7 +376,7 @@ type sGPUVGADevice struct { } func (gpu *sGPUVGADevice) GetDeviceType() string { - return GPU_VGA_TYPE + return api.GPU_VGA_TYPE } func (gpu *sGPUVGADevice) GetVGACmd() string { @@ -411,13 +406,15 @@ type sGPUHPCDevice struct { } func newGPUHPCDevice(dev *PCIDevice) *sGPUHPCDevice { - return &sGPUHPCDevice{ + gpuDev := &sGPUHPCDevice{ sGPUBaseDevice: newGPUBaseDevice(dev), } + gpuDev.devType = gpuDev.GetDeviceType() + return gpuDev } func (gpu *sGPUHPCDevice) GetDeviceType() string { - return GPU_HPC_TYPE + return api.GPU_HPC_TYPE } func (gpu *sGPUHPCDevice) GetPassthroughCmd(index int) string { @@ -798,7 +795,7 @@ func getQemuParams(man *IsolatedDeviceManager, devAddrs []string) *QemuParams { continue } devCmds = append(devCmds, GetDeviceCmd(dev, idx)) - if dev.GetVGACmd() != vgaCmd && dev.GetDeviceType() == GPU_VGA_TYPE { + if dev.GetVGACmd() != vgaCmd && dev.GetDeviceType() == api.GPU_VGA_TYPE { vgaCmd = dev.GetVGACmd() } if dev.GetCPUCmd() != cpuCmd {