Skip to content

Commit 0a17611

Browse files
authored
feat(region): list gpu by index and device_minor (#23010)
1 parent fd35536 commit 0a17611

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

pkg/apis/compute/isolated_device.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ type IsolatedDeviceListInput struct {
7878

7979
// 列出虚拟机上挂载的设备
8080
GuestId string `json:"guest_id"`
81+
82+
// GPU index
83+
Index *int `json:"index"`
84+
// Nvidia GPU minor number, parsing from /proc/driver/nvidia/gpus/*/information
85+
DeviceMinor *int `json:"device_minor"`
8186
}
8287

8388
type IsolatedDeviceCreateInput struct {

pkg/compute/models/isolated_devices.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ func (manager *SIsolatedDeviceManager) ListItemFilter(
360360
if len(query.NumaNode) > 0 {
361361
q = q.In("numa_node", query.NumaNode)
362362
}
363+
if query.Index != nil && *query.Index >= 0 {
364+
q = q.Equals("index", query.Index)
365+
}
366+
if query.DeviceMinor != nil && *query.DeviceMinor >= 0 {
367+
q = q.Equals("device_minor", query.DeviceMinor)
368+
}
363369

364370
if !query.ShowBaremetalIsolatedDevices {
365371
sq := HostManager.Query("id").In("host_type", []string{api.HOST_TYPE_HYPERVISOR, api.HOST_TYPE_CONTAINER, api.HOST_TYPE_ZETTAKIT}).SubQuery()

pkg/mcclient/modules/compute/mod_isolatedevices.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func init() {
2828
[]string{"ID", "Dev_type",
2929
"Model", "Addr", "Vendor_device_id", "Mdev_id",
3030
"Host_id", "Host", "numa_node",
31-
"Guest_id", "Guest", "Guest_status", "Device_path", "Render_path", "PCIE_Info"},
31+
"Guest_id", "Guest", "Guest_status", "Device_path", "Render_path", "PCIE_Info", "Index", "Device_minor"},
3232
[]string{})
3333
modules.RegisterCompute(&IsolatedDevices)
3434
}

pkg/mcclient/options/compute/isolated_devices.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ type DeviceListOptions struct {
3535
DevicePath []string `help:"filter by device path"`
3636
VendorDeviceId []string `help:"filter by vendor device id(PCIID)"`
3737
NumaNode []uint8 `help:"fitler by numa node index"`
38+
Index *int `help:"filter by index"`
39+
DeviceMinor *int `help:"filter by device minor"`
3840
}
3941

4042
func (o *DeviceListOptions) Params() (jsonutils.JSONObject, error) {

0 commit comments

Comments
 (0)