Skip to content

Commit 7ef1f8d

Browse files
committed
Remove lossy vGPU framework detection wrappers
DetectVGPUFramework discarded discovery errors, and its only remaining caller was the integration test gate via DetectHostGPUMode. Route the gate through DiscoverVGPU so a discovery failure surfaces in the skip message, and delete the dead DetectHostGPUMode, DetectVGPUFramework, and DiscoverVFs wrappers on both platforms. Also document that least-loaded placement weighs allocated types absent from the creatable catalog as zero.
1 parent d6e0455 commit 7ef1f8d

5 files changed

Lines changed: 10 additions & 48 deletions

File tree

integration/vgpu_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,13 @@ func checkVGPUTestPrerequisites() (string, string) {
245245
return "vGPU test requires root (sudo) for mdev creation", ""
246246
}
247247

248-
// Check for vGPU mode (SR-IOV VFs present)
249-
mode := devices.DetectHostGPUMode()
250-
if mode != devices.GPUModeVGPU {
251-
return "vGPU test requires SR-IOV VFs in /sys/class/mdev_bus/", ""
248+
// Check for a vGPU framework (SR-IOV VFs present)
249+
framework, _, err := devices.DiscoverVGPU()
250+
if err != nil {
251+
return "vGPU test failed to discover vGPU framework: " + err.Error(), ""
252+
}
253+
if framework == devices.VGPUFrameworkNone {
254+
return "vGPU test requires SR-IOV VFs with an mdev or vendor VFIO vGPU framework", ""
252255
}
253256

254257
// Check for available profiles

lib/devices/gpu_mode.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

lib/devices/mdev_darwin.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,11 @@ func SetGPUProfileCacheTTL(ttl string) {
1515
// No-op on macOS
1616
}
1717

18-
func DetectVGPUFramework() VGPUFramework {
19-
return VGPUFrameworkNone
20-
}
21-
2218
// DiscoverVGPU reports no vGPU framework on macOS.
2319
func DiscoverVGPU() (VGPUFramework, []VirtualFunction, error) {
2420
return VGPUFrameworkNone, nil, nil
2521
}
2622

27-
// DiscoverVFs returns an empty list on macOS.
28-
// SR-IOV Virtual Functions are not available on macOS.
29-
func DiscoverVFs() ([]VirtualFunction, error) {
30-
return []VirtualFunction{}, nil
31-
}
32-
3323
// ListGPUProfiles returns an empty list on macOS.
3424
func ListGPUProfiles() ([]GPUProfile, error) {
3525
return []GPUProfile{}, nil

lib/devices/vendor_vfio_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ func (s vendorVFIOSysfs) reconcile(ctx context.Context, protectedDevicePaths map
284284
}
285285

286286
func (s vendorVFIOSysfs) selectLeastLoadedVF(vfs []VirtualFunction, metadata []profileMetadata, profileType string) (string, error) {
287+
// metadata only covers currently creatable types, so an allocated type no
288+
// longer creatable anywhere weighs 0 and its GPU can look less loaded than
289+
// it is. The driver's creatable lists still bound placement correctness.
287290
framebufferByType := make(map[string]int, len(metadata))
288291
for _, profile := range metadata {
289292
framebufferByType[profile.TypeName] = profile.FramebufferMB

lib/devices/vgpu_linux.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ func discoverVGPUWith(discoverMdev, discoverVendorVFIO func() ([]VirtualFunction
3434
return VGPUFrameworkVendorVFIO, vfs, nil
3535
}
3636

37-
func DetectVGPUFramework() VGPUFramework {
38-
framework, _, _ := DiscoverVGPU()
39-
return framework
40-
}
41-
42-
func DiscoverVFs() ([]VirtualFunction, error) {
43-
_, vfs, err := DiscoverVGPU()
44-
return vfs, err
45-
}
46-
4737
func ListGPUProfiles() ([]GPUProfile, error) {
4838
framework, vfs, err := DiscoverVGPU()
4939
if err != nil {

0 commit comments

Comments
 (0)