@@ -25,7 +25,7 @@ type vendorVFIOSysfs struct {
2525 pciDevicesPath string
2626 procPath string
2727 vfioDevicesPath string
28- owners map [string ]string // assignments created by this process
28+ owners map [string ]string
2929}
3030
3131var (
@@ -135,15 +135,9 @@ func (s vendorVFIOSysfs) create(ctx context.Context, profileName, instanceID str
135135 }
136136 }
137137 if ! found {
138- // A VF with an assigned vGPU reports nothing creatable, and a VF on a
139- // framebuffer-exhausted GPU reports only the header, so a host at full
140- // capacity has an empty catalog. Report that as capacity, not config.
141138 if len (metadata ) == 0 && len (vfs ) > 0 {
142139 return nil , fmt .Errorf ("no creatable vGPU profiles on any VF, GPUs may be at capacity: profile %q" , profileName )
143140 }
144- // The creatable catalog is capacity-dependent: a valid larger profile
145- // disappears once no GPU can fit it while smaller ones remain, so an
146- // absent profile is indistinguishable from an unknown one.
147141 return nil , fmt .Errorf ("profile %q is not creatable on any VF (unknown profile or insufficient capacity)" , profileName )
148142 }
149143
@@ -184,17 +178,10 @@ func (s vendorVFIOSysfs) create(ctx context.Context, profileName, instanceID str
184178 }, nil
185179}
186180
187- // destroy releases the vGPU assignment on vfAddress. In-process ownership
188- // prevents stale instance metadata from releasing a VF before its new QEMU
189- // process opens the device. Open VFIO handles protect assignments recovered
190- // after a hypeman restart.
191181func (s vendorVFIOSysfs ) destroy (ctx context.Context , vfAddress , instanceID string ) error {
192182 return s .destroyWithOpenPaths (ctx , vfAddress , instanceID , nil )
193183}
194184
195- // destroyWithOpenPaths is destroy with an optional pre-scanned set of open
196- // VFIO handles, so reconcile can share one /proc scan across all releases.
197- // A nil openPaths triggers a fresh scan.
198185func (s vendorVFIOSysfs ) destroyWithOpenPaths (ctx context.Context , vfAddress , instanceID string , openPaths map [string ]struct {}) error {
199186 vendorVFIOMu .Lock ()
200187 defer vendorVFIOMu .Unlock ()
@@ -268,9 +255,6 @@ func (s vendorVFIOSysfs) reconcile(ctx context.Context, protectedDevicePaths map
268255 return fmt .Errorf ("scan open VFIO handles: %w" , err )
269256 }
270257 }
271- // destroyWithOpenPaths repeats this probe under the lock; the
272- // pre-check only keeps live VMs from being logged below as failed
273- // destroys.
274258 inUse , err := s .vfioDeviceInUse (vf .PCIAddress , openPaths )
275259 if err != nil {
276260 log .WarnContext (ctx , "failed to check vendor VFIO vGPU usage" , "vf" , vf .PCIAddress , "error" , err )
@@ -287,9 +271,6 @@ func (s vendorVFIOSysfs) reconcile(ctx context.Context, protectedDevicePaths map
287271}
288272
289273func (s vendorVFIOSysfs ) selectLeastLoadedVF (vfs []VirtualFunction , metadata []profileMetadata , profileType string ) (string , error ) {
290- // metadata only covers currently creatable types, so an allocated type no
291- // longer creatable anywhere weighs 0 and its GPU can look less loaded than
292- // it is. The driver's creatable lists still bound placement correctness.
293274 framebufferByType := make (map [string ]int , len (metadata ))
294275 for _ , profile := range metadata {
295276 framebufferByType [profile .TypeName ] = profile .FramebufferMB
@@ -374,8 +355,6 @@ func (s vendorVFIOSysfs) vfioDeviceInUse(vfAddress string, openPaths map[string]
374355 }
375356 }
376357
377- // QEMU holds the legacy /dev/vfio/<group> node unless iommufd is
378- // configured, so check the VF's iommu group alongside the iommufd cdevs.
379358 target , err := os .Readlink (filepath .Join (s .pciDevicesPath , vfAddress , "iommu_group" ))
380359 if os .IsNotExist (err ) {
381360 return false , nil
@@ -397,8 +376,6 @@ func (s vendorVFIOSysfs) vfioDeviceInUse(vfAddress string, openPaths map[string]
397376 return false , nil
398377}
399378
400- // openVFIOPaths returns every path under the VFIO device root that any
401- // process holds open, from a single /proc scan shared by all VF checks.
402379func (s vendorVFIOSysfs ) openVFIOPaths () (map [string ]struct {}, error ) {
403380 processes , err := os .ReadDir (s .procPath )
404381 if err != nil {
@@ -434,11 +411,6 @@ func (s vendorVFIOSysfs) openVFIOPaths() (map[string]struct{}, error) {
434411 return open , nil
435412}
436413
437- // parseCreatableVGPUTypes reads the table the NVIDIA driver emits, with a
438- // header row and the type ID first:
439- //
440- // ID : vGPU Name
441- // 1147 : NVIDIA L40S-1Q
442414func parseCreatableVGPUTypes (value string ) ([]profileMetadata , error ) {
443415 profiles := make ([]profileMetadata , 0 )
444416 for lineNumber , line := range strings .Split (value , "\n " ) {
0 commit comments