From f952fa26db9b88a16c33453463ed88512afefd37 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 12 Apr 2026 01:42:47 +0000 Subject: [PATCH] Bump github.com/NVIDIA/go-nvlib from 0.9.0 to 0.10.0 Bumps [github.com/NVIDIA/go-nvlib](https://github.com/NVIDIA/go-nvlib) from 0.9.0 to 0.10.0. - [Release notes](https://github.com/NVIDIA/go-nvlib/releases) - [Commits](https://github.com/NVIDIA/go-nvlib/compare/v0.9.0...v0.10.0) --- updated-dependencies: - dependency-name: github.com/NVIDIA/go-nvlib dependency-version: 0.10.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../go-nvlib/pkg/nvlib/device/device.go | 6 +- .../NVIDIA/go-nvlib/pkg/nvpci/nvpci.go | 27 ++++++-- .../NVIDIA/go-nvlib/pkg/nvpci/nvpci_mock.go | 64 ++++++++++++++++--- vendor/modules.txt | 2 +- 6 files changed, 84 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 87941645..e3958a3a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/NVIDIA/vgpu-device-manager go 1.25.0 require ( - github.com/NVIDIA/go-nvlib v0.9.0 + github.com/NVIDIA/go-nvlib v0.10.0 github.com/NVIDIA/mig-parted v0.13.1 github.com/go-playground/validator/v10 v10.30.1 github.com/google/uuid v1.6.0 diff --git a/go.sum b/go.sum index f89b2d06..36c5da12 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= -github.com/NVIDIA/go-nvlib v0.9.0 h1:GKLIvLJ0uhCtTLLZp2Q8QIDRxOYH45MM4Y5OO3U5Rho= -github.com/NVIDIA/go-nvlib v0.9.0/go.mod h1:7mzx9FSdO9fXWP9NKuZmWkCwhkEcSWQFe2tmFwtLb9c= +github.com/NVIDIA/go-nvlib v0.10.0 h1:2jbAFmvLBntIc/4iUChI9DzxyYNI92pohXU4kFuNrg0= +github.com/NVIDIA/go-nvlib v0.10.0/go.mod h1:7mzx9FSdO9fXWP9NKuZmWkCwhkEcSWQFe2tmFwtLb9c= github.com/NVIDIA/go-nvml v0.13.0-1 h1:OLX8Jq3dONuPOQPC7rndB6+iDmDakw0XTYgzMxObkEw= github.com/NVIDIA/go-nvml v0.13.0-1/go.mod h1:+KNA7c7gIBH7SKSJ1ntlwkfN80zdx8ovl4hrK3LmPt4= github.com/NVIDIA/mig-parted v0.13.1 h1:KTAtBGuXGQmB7bF7mULeh7moAWXa3QJu1e9MG/yBq+c= diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/device.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/device.go index a67ce3c1..6f016354 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/device.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/device.go @@ -149,7 +149,11 @@ func (d *device) GetBrandAsString() (string, error) { // GetAddressingModeAsString returns the Device addressing mode as a string. func (d *device) GetAddressingModeAsString() (string, error) { - mode, ret := d.GetAddressingMode() + if !d.lib.hasSymbol("nvmlDeviceGetAddressingMode") { + return "", nil + } + + mode, ret := nvml.Device(d).GetAddressingMode() switch ret { case nvml.SUCCESS: diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go index f41d0f24..a322ea26 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go @@ -56,6 +56,7 @@ type Interface interface { GetGPUs() ([]*NvidiaPCIDevice, error) GetGPUByIndex(int) (*NvidiaPCIDevice, error) GetGPUByPciBusID(string) (*NvidiaPCIDevice, error) + GetNvidiaDeviceByPciBusID(string) (*NvidiaPCIDevice, error) GetNetworkControllers() ([]*NvidiaPCIDevice, error) GetPciBridges() ([]*NvidiaPCIDevice, error) GetDPUs() ([]*NvidiaPCIDevice, error) @@ -211,7 +212,7 @@ func (p *nvpci) GetAllDevices() ([]*NvidiaPCIDevice, error) { cache := make(map[string]*NvidiaPCIDevice) for _, deviceDir := range deviceDirs { deviceAddress := deviceDir.Name() - nvdevice, err := p.getGPUByPciBusID(deviceAddress, cache) + nvdevice, err := p.getNvidiaDeviceByPciBusID(deviceAddress, cache) if err != nil { return nil, fmt.Errorf("error constructing NVIDIA PCI device %s: %v", deviceAddress, err) } @@ -235,13 +236,27 @@ func (p *nvpci) GetAllDevices() ([]*NvidiaPCIDevice, error) { return nvdevices, nil } -// GetGPUByPciBusID constructs an NvidiaPCIDevice for the specified address (PCI Bus ID). +// GetGPUByPciBusID returns an NvidiaPCIDevice for the specified address (PCI Bus ID) +// only if the device is a GPU. Returns nil if the device exists but is not a GPU. func (p *nvpci) GetGPUByPciBusID(address string) (*NvidiaPCIDevice, error) { - // Pass nil as to force reading device information from sysfs. - return p.getGPUByPciBusID(address, nil) + dev, err := p.GetNvidiaDeviceByPciBusID(address) + if err != nil { + return nil, err + } + if dev == nil || !dev.IsGPU() { + return nil, nil + } + return dev, nil +} + +// GetNvidiaDeviceByPciBusID constructs an NvidiaPCIDevice for the specified +// address (PCI Bus ID). This returns any NVIDIA PCI device at the given +// address, including GPUs, NVSwitches, and other NVIDIA devices. +func (p *nvpci) GetNvidiaDeviceByPciBusID(address string) (*NvidiaPCIDevice, error) { + return p.getNvidiaDeviceByPciBusID(address, nil) } -func (p *nvpci) getGPUByPciBusID(address string, cache map[string]*NvidiaPCIDevice) (*NvidiaPCIDevice, error) { +func (p *nvpci) getNvidiaDeviceByPciBusID(address string, cache map[string]*NvidiaPCIDevice) (*NvidiaPCIDevice, error) { if cache != nil { if pciDevice, exists := cache[address]; exists { return pciDevice, nil @@ -357,7 +372,7 @@ func (p *nvpci) getGPUByPciBusID(address string, cache map[string]*NvidiaPCIDevi physFnAddress, err := filepath.EvalSymlinks(path.Join(devicePath, "physfn")) switch { case err == nil: - physFn, err := p.getGPUByPciBusID(filepath.Base(physFnAddress), cache) + physFn, err := p.getNvidiaDeviceByPciBusID(filepath.Base(physFnAddress), cache) if err != nil { return nil, fmt.Errorf("unable to detect physfn for %s: %v", address, err) } diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci_mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci_mock.go index 04ab56b8..ef9030e5 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci_mock.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci_mock.go @@ -41,6 +41,9 @@ var _ Interface = &InterfaceMock{} // GetNetworkControllersFunc: func() ([]*NvidiaPCIDevice, error) { // panic("mock out the GetNetworkControllers method") // }, +// GetNvidiaDeviceByPciBusIDFunc: func(s string) (*NvidiaPCIDevice, error) { +// panic("mock out the GetNvidiaDeviceByPciBusID method") +// }, // GetPciBridgesFunc: func() ([]*NvidiaPCIDevice, error) { // panic("mock out the GetPciBridges method") // }, @@ -78,6 +81,9 @@ type InterfaceMock struct { // GetNetworkControllersFunc mocks the GetNetworkControllers method. GetNetworkControllersFunc func() ([]*NvidiaPCIDevice, error) + // GetNvidiaDeviceByPciBusIDFunc mocks the GetNvidiaDeviceByPciBusID method. + GetNvidiaDeviceByPciBusIDFunc func(s string) (*NvidiaPCIDevice, error) + // GetPciBridgesFunc mocks the GetPciBridges method. GetPciBridgesFunc func() ([]*NvidiaPCIDevice, error) @@ -114,6 +120,11 @@ type InterfaceMock struct { // GetNetworkControllers holds details about calls to the GetNetworkControllers method. GetNetworkControllers []struct { } + // GetNvidiaDeviceByPciBusID holds details about calls to the GetNvidiaDeviceByPciBusID method. + GetNvidiaDeviceByPciBusID []struct { + // S is the s argument value. + S string + } // GetPciBridges holds details about calls to the GetPciBridges method. GetPciBridges []struct { } @@ -121,16 +132,17 @@ type InterfaceMock struct { GetVGAControllers []struct { } } - lockGet3DControllers sync.RWMutex - lockGetAllDevices sync.RWMutex - lockGetDPUs sync.RWMutex - lockGetGPUByIndex sync.RWMutex - lockGetGPUByPciBusID sync.RWMutex - lockGetGPUs sync.RWMutex - lockGetNVSwitches sync.RWMutex - lockGetNetworkControllers sync.RWMutex - lockGetPciBridges sync.RWMutex - lockGetVGAControllers sync.RWMutex + lockGet3DControllers sync.RWMutex + lockGetAllDevices sync.RWMutex + lockGetDPUs sync.RWMutex + lockGetGPUByIndex sync.RWMutex + lockGetGPUByPciBusID sync.RWMutex + lockGetGPUs sync.RWMutex + lockGetNVSwitches sync.RWMutex + lockGetNetworkControllers sync.RWMutex + lockGetNvidiaDeviceByPciBusID sync.RWMutex + lockGetPciBridges sync.RWMutex + lockGetVGAControllers sync.RWMutex } // Get3DControllers calls Get3DControllersFunc. @@ -359,6 +371,38 @@ func (mock *InterfaceMock) GetNetworkControllersCalls() []struct { return calls } +// GetNvidiaDeviceByPciBusID calls GetNvidiaDeviceByPciBusIDFunc. +func (mock *InterfaceMock) GetNvidiaDeviceByPciBusID(s string) (*NvidiaPCIDevice, error) { + if mock.GetNvidiaDeviceByPciBusIDFunc == nil { + panic("InterfaceMock.GetNvidiaDeviceByPciBusIDFunc: method is nil but Interface.GetNvidiaDeviceByPciBusID was just called") + } + callInfo := struct { + S string + }{ + S: s, + } + mock.lockGetNvidiaDeviceByPciBusID.Lock() + mock.calls.GetNvidiaDeviceByPciBusID = append(mock.calls.GetNvidiaDeviceByPciBusID, callInfo) + mock.lockGetNvidiaDeviceByPciBusID.Unlock() + return mock.GetNvidiaDeviceByPciBusIDFunc(s) +} + +// GetNvidiaDeviceByPciBusIDCalls gets all the calls that were made to GetNvidiaDeviceByPciBusID. +// Check the length with: +// +// len(mockedInterface.GetNvidiaDeviceByPciBusIDCalls()) +func (mock *InterfaceMock) GetNvidiaDeviceByPciBusIDCalls() []struct { + S string +} { + var calls []struct { + S string + } + mock.lockGetNvidiaDeviceByPciBusID.RLock() + calls = mock.calls.GetNvidiaDeviceByPciBusID + mock.lockGetNvidiaDeviceByPciBusID.RUnlock() + return calls +} + // GetPciBridges calls GetPciBridgesFunc. func (mock *InterfaceMock) GetPciBridges() ([]*NvidiaPCIDevice, error) { if mock.GetPciBridgesFunc == nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 411f6082..b27b219a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/NVIDIA/go-nvlib v0.9.0 +# github.com/NVIDIA/go-nvlib v0.10.0 ## explicit; go 1.20 github.com/NVIDIA/go-nvlib/pkg/nvlib/device github.com/NVIDIA/go-nvlib/pkg/nvmdev