From 627c8f11d2774e250e341c3aedfabb286e938aa8 Mon Sep 17 00:00:00 2001 From: Christopher Desiniotis Date: Thu, 20 Jul 2023 16:09:55 -0700 Subject: [PATCH 1/2] Add 'vfio' mode to pkg/nvcdi for generating CDI specs for NVIDIA passthrough GPUs Signed-off-by: Christopher Desiniotis --- pkg/nvcdi/lib-vfio.go | 122 ++++++++++++++++++++++++++++++++++++ pkg/nvcdi/lib-vfio_test.go | 123 +++++++++++++++++++++++++++++++++++++ pkg/nvcdi/lib.go | 11 ++++ pkg/nvcdi/mode.go | 3 + pkg/nvcdi/options.go | 8 +++ 5 files changed, 267 insertions(+) create mode 100644 pkg/nvcdi/lib-vfio.go create mode 100644 pkg/nvcdi/lib-vfio_test.go diff --git a/pkg/nvcdi/lib-vfio.go b/pkg/nvcdi/lib-vfio.go new file mode 100644 index 000000000..facd40c85 --- /dev/null +++ b/pkg/nvcdi/lib-vfio.go @@ -0,0 +1,122 @@ +/** +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package nvcdi + +import ( + "fmt" + "path/filepath" + "strconv" + + "tags.cncf.io/container-device-interface/pkg/cdi" + "tags.cncf.io/container-device-interface/specs-go" +) + +type vfiolib nvcdilib + +type vfioDevice struct { + index int + group int + devRoot string +} + +var _ deviceSpecGeneratorFactory = (*vfiolib)(nil) + +func (l *vfiolib) DeviceSpecGenerators(ids ...string) (DeviceSpecGenerator, error) { + vfioDevices, err := l.getVfioDevices(ids...) + if err != nil { + return nil, err + } + var deviceSpecGenerators DeviceSpecGenerators + for _, vfioDevice := range vfioDevices { + deviceSpecGenerators = append(deviceSpecGenerators, vfioDevice) + } + + return deviceSpecGenerators, nil +} + +// GetDeviceSpecs returns the CDI device specs for a vfio device. +func (l *vfioDevice) GetDeviceSpecs() ([]specs.Device, error) { + path := fmt.Sprintf("/dev/vfio/%d", l.group) + deviceSpec := specs.Device{ + Name: fmt.Sprintf("%d", l.index), + ContainerEdits: specs.ContainerEdits{ + DeviceNodes: []*specs.DeviceNode{ + { + Path: path, + HostPath: filepath.Join(l.devRoot, path), + }, + }, + }, + } + return []specs.Device{deviceSpec}, nil +} + +// GetCommonEdits returns common edits for ALL devices. +// Note, currently there are no common edits. +func (l *vfiolib) GetCommonEdits() (*cdi.ContainerEdits, error) { + e := cdi.ContainerEdits{ + ContainerEdits: &specs.ContainerEdits{ + DeviceNodes: []*specs.DeviceNode{ + { + Path: "/dev/vfio/vfio", + HostPath: filepath.Join(l.devRoot, "/dev/vfio/vfio"), + }, + }, + }, + } + return &e, nil +} + +func (l *vfiolib) getVfioDevices(ids ...string) ([]*vfioDevice, error) { + var vfioDevices []*vfioDevice + for _, id := range ids { + if id == "all" { + return l.getAllVfioDevices() + } + index, err := strconv.ParseInt(id, 10, 32) + if err != nil { + return nil, fmt.Errorf("invalid channel ID %v: %w", id, err) + } + i := int(index) + dev, err := l.nvpcilib.GetGPUByIndex(i) + if err != nil { + return nil, fmt.Errorf("failed to get device: %w", err) + } + vfioDevices = append(vfioDevices, &vfioDevice{index: i, group: dev.IommuGroup, devRoot: l.devRoot}) + } + + return vfioDevices, nil +} + +func (l *vfiolib) getAllVfioDevices() ([]*vfioDevice, error) { + devices, err := l.nvpcilib.GetGPUs() + if err != nil { + return nil, fmt.Errorf("failed getting NVIDIA GPUs: %v", err) + } + + var vfioDevices []*vfioDevice + for i, dev := range devices { + if dev.Driver != "vfio-pci" { + continue + } + l.logger.Debugf("Found NVIDIA device: address=%s, driver=%s, iommu_group=%d, deviceId=%x", + dev.Address, dev.Driver, dev.IommuGroup, dev.Device) + vfioDevices = append(vfioDevices, &vfioDevice{index: i, group: dev.IommuGroup, devRoot: l.devRoot}) + } + return vfioDevices, nil +} diff --git a/pkg/nvcdi/lib-vfio_test.go b/pkg/nvcdi/lib-vfio_test.go new file mode 100644 index 000000000..0b638c7fb --- /dev/null +++ b/pkg/nvcdi/lib-vfio_test.go @@ -0,0 +1,123 @@ +/** +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package nvcdi + +import ( + "bytes" + "testing" + + "github.com/NVIDIA/go-nvlib/pkg/nvpci" + "github.com/stretchr/testify/require" +) + +func TestModeVfio(t *testing.T) { + testCases := []struct { + description string + pcilib *nvpci.InterfaceMock + ids []string + expectedError error + expectedSpec string + }{ + { + description: "get all specs single device", + pcilib: &nvpci.InterfaceMock{ + GetGPUsFunc: func() ([]*nvpci.NvidiaPCIDevice, error) { + devices := []*nvpci.NvidiaPCIDevice{ + { + Driver: "vfio-pci", + IommuGroup: 5, + }, + } + return devices, nil + }, + }, + expectedSpec: `--- +cdiVersion: 0.5.0 +kind: nvidia.com/pgpu +devices: + - name: "0" + containerEdits: + deviceNodes: + - path: /dev/vfio/5 + hostPath: /dev/vfio/5 +containerEdits: + env: + - NVIDIA_VISIBLE_DEVICES=void + deviceNodes: + - path: /dev/vfio/vfio + hostPath: /dev/vfio/vfio +`, + }, + { + description: "get single device spec by index", + pcilib: &nvpci.InterfaceMock{ + GetGPUByIndexFunc: func(n int) (*nvpci.NvidiaPCIDevice, error) { + devices := []*nvpci.NvidiaPCIDevice{ + { + Driver: "vfio-pci", + IommuGroup: 45, + }, + { + Driver: "vfio-pci", + IommuGroup: 5, + }, + } + return devices[n], nil + }, + }, + ids: []string{"1"}, + expectedSpec: `--- +cdiVersion: 0.5.0 +kind: nvidia.com/pgpu +devices: + - name: "1" + containerEdits: + deviceNodes: + - path: /dev/vfio/5 + hostPath: /dev/vfio/5 +containerEdits: + env: + - NVIDIA_VISIBLE_DEVICES=void + deviceNodes: + - path: /dev/vfio/vfio + hostPath: /dev/vfio/vfio +`, + }, + } + + for _, tc := range testCases { + t.Run(tc.description, func(t *testing.T) { + lib, err := New( + WithMode(ModeVfio), + WithPCILib(tc.pcilib), + ) + require.NoError(t, err) + + spec, err := lib.GetSpec(tc.ids...) + require.EqualValues(t, tc.expectedError, err) + + var output bytes.Buffer + + _, err = spec.WriteTo(&output) + require.NoError(t, err) + + require.Equal(t, tc.expectedSpec, output.String()) + }) + } + +} diff --git a/pkg/nvcdi/lib.go b/pkg/nvcdi/lib.go index 94750f429..de9b3bda5 100644 --- a/pkg/nvcdi/lib.go +++ b/pkg/nvcdi/lib.go @@ -21,6 +21,7 @@ import ( "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" "github.com/NVIDIA/go-nvlib/pkg/nvlib/info" + "github.com/NVIDIA/go-nvlib/pkg/nvpci" "github.com/NVIDIA/go-nvml/pkg/nvml" "github.com/NVIDIA/nvidia-container-toolkit/internal/discover" @@ -54,6 +55,8 @@ type nvcdilib struct { driver *root.Driver infolib info.Interface + nvpcilib nvpci.Interface + mergedDeviceOptions []transform.MergedDeviceOption featureFlags map[FeatureFlag]bool @@ -151,6 +154,14 @@ func New(opts ...Option) (Interface, error) { l.class = classImexChannel } factory = (*imexlib)(l) + case ModeVfio: + if l.class == "" { + l.class = "pgpu" + } + if l.nvpcilib == nil { + l.nvpcilib = nvpci.New() + } + factory = (*vfiolib)(l) default: return nil, fmt.Errorf("unknown mode %q", l.mode) } diff --git a/pkg/nvcdi/mode.go b/pkg/nvcdi/mode.go index 5b8f0369e..6a600657e 100644 --- a/pkg/nvcdi/mode.go +++ b/pkg/nvcdi/mode.go @@ -42,6 +42,8 @@ const ( ModeCSV = Mode("csv") // ModeImex configures the CDI spec generated to generate a spec for the available IMEX channels. ModeImex = Mode("imex") + // ModeVfio configures the CDI spec generator to generate a VFIO spec. + ModeVfio = Mode("vfio") ) type modeConstraint interface { @@ -66,6 +68,7 @@ func getModes() modes { ModeGds, ModeMofed, ModeCSV, + ModeVfio, } lookup := make(map[Mode]bool) diff --git a/pkg/nvcdi/options.go b/pkg/nvcdi/options.go index 25494ebf5..535f2dfa0 100644 --- a/pkg/nvcdi/options.go +++ b/pkg/nvcdi/options.go @@ -19,6 +19,7 @@ package nvcdi import ( "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" "github.com/NVIDIA/go-nvlib/pkg/nvlib/info" + "github.com/NVIDIA/go-nvlib/pkg/nvpci" "github.com/NVIDIA/go-nvml/pkg/nvml" "github.com/NVIDIA/nvidia-container-toolkit/internal/discover" @@ -43,6 +44,13 @@ func WithInfoLib(infolib info.Interface) Option { } } +// WithPCILib sets the pci library to be used for CDI spec generation. +func WithPCILib(pcilib nvpci.Interface) Option { + return func(l *nvcdilib) { + l.nvpcilib = pcilib + } +} + // WithDeviceNamers sets the device namer for the library func WithDeviceNamers(namers ...DeviceNamer) Option { return func(l *nvcdilib) { From 81047b1bce545f945e9407b1214deaf01af87b40 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Mon, 7 Jul 2025 16:16:28 +0200 Subject: [PATCH 2/2] [no-relnote] Bump github.com/NVIDIA/go-nvlib to 532907f496285164342fe77c7a9ac1c84ae8b0aa Signed-off-by: Evan Lezar --- go.mod | 2 +- go.sum | 4 +- .../NVIDIA/go-nvlib/pkg/nvpci/nvpci.go | 2 + .../NVIDIA/go-nvlib/pkg/nvpci/nvpci_mock.go | 414 ++++++++++++++++++ vendor/modules.txt | 2 +- 5 files changed, 420 insertions(+), 4 deletions(-) create mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci_mock.go diff --git a/go.mod b/go.mod index aebfb73b9..885cfb92c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/NVIDIA/nvidia-container-toolkit go 1.23.0 require ( - github.com/NVIDIA/go-nvlib v0.7.3 + github.com/NVIDIA/go-nvlib v0.7.4-0.20250707141440-532907f49628 github.com/NVIDIA/go-nvml v0.12.9-0 github.com/cyphar/filepath-securejoin v0.4.1 github.com/moby/sys/reexec v0.1.0 diff --git a/go.sum b/go.sum index f0bc21384..3840b079d 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/NVIDIA/go-nvlib v0.7.3 h1:kXc8PkWUlrwedSpM4fR8xT/DAq1NKy8HqhpgteFcGAw= -github.com/NVIDIA/go-nvlib v0.7.3/go.mod h1:i95Je7GinMy/+BDs++DAdbPmT2TubjNP8i8joC7DD7I= +github.com/NVIDIA/go-nvlib v0.7.4-0.20250707141440-532907f49628 h1:epoT+CVQMISAldX5fx78gjJs23Kx17B/6dOwcXvmPaE= +github.com/NVIDIA/go-nvlib v0.7.4-0.20250707141440-532907f49628/go.mod h1:i95Je7GinMy/+BDs++DAdbPmT2TubjNP8i8joC7DD7I= github.com/NVIDIA/go-nvml v0.12.9-0 h1:e344UK8ZkeMeeLkdQtRhmXRxNf+u532LDZPGMtkdus0= github.com/NVIDIA/go-nvml v0.12.9-0/go.mod h1:+KNA7c7gIBH7SKSJ1ntlwkfN80zdx8ovl4hrK3LmPt4= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= 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 5caf03435..1165ab138 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go @@ -46,6 +46,8 @@ const ( ) // Interface allows us to get a list of all NVIDIA PCI devices. +// +//go:generate moq -rm -fmt=goimports -out nvpci_mock.go . Interface type Interface interface { GetAllDevices() ([]*NvidiaPCIDevice, error) Get3DControllers() ([]*NvidiaPCIDevice, error) 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 new file mode 100644 index 000000000..04ab56b88 --- /dev/null +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci_mock.go @@ -0,0 +1,414 @@ +// Code generated by moq; DO NOT EDIT. +// github.com/matryer/moq + +package nvpci + +import ( + "sync" +) + +// Ensure, that InterfaceMock does implement Interface. +// If this is not the case, regenerate this file with moq. +var _ Interface = &InterfaceMock{} + +// InterfaceMock is a mock implementation of Interface. +// +// func TestSomethingThatUsesInterface(t *testing.T) { +// +// // make and configure a mocked Interface +// mockedInterface := &InterfaceMock{ +// Get3DControllersFunc: func() ([]*NvidiaPCIDevice, error) { +// panic("mock out the Get3DControllers method") +// }, +// GetAllDevicesFunc: func() ([]*NvidiaPCIDevice, error) { +// panic("mock out the GetAllDevices method") +// }, +// GetDPUsFunc: func() ([]*NvidiaPCIDevice, error) { +// panic("mock out the GetDPUs method") +// }, +// GetGPUByIndexFunc: func(n int) (*NvidiaPCIDevice, error) { +// panic("mock out the GetGPUByIndex method") +// }, +// GetGPUByPciBusIDFunc: func(s string) (*NvidiaPCIDevice, error) { +// panic("mock out the GetGPUByPciBusID method") +// }, +// GetGPUsFunc: func() ([]*NvidiaPCIDevice, error) { +// panic("mock out the GetGPUs method") +// }, +// GetNVSwitchesFunc: func() ([]*NvidiaPCIDevice, error) { +// panic("mock out the GetNVSwitches method") +// }, +// GetNetworkControllersFunc: func() ([]*NvidiaPCIDevice, error) { +// panic("mock out the GetNetworkControllers method") +// }, +// GetPciBridgesFunc: func() ([]*NvidiaPCIDevice, error) { +// panic("mock out the GetPciBridges method") +// }, +// GetVGAControllersFunc: func() ([]*NvidiaPCIDevice, error) { +// panic("mock out the GetVGAControllers method") +// }, +// } +// +// // use mockedInterface in code that requires Interface +// // and then make assertions. +// +// } +type InterfaceMock struct { + // Get3DControllersFunc mocks the Get3DControllers method. + Get3DControllersFunc func() ([]*NvidiaPCIDevice, error) + + // GetAllDevicesFunc mocks the GetAllDevices method. + GetAllDevicesFunc func() ([]*NvidiaPCIDevice, error) + + // GetDPUsFunc mocks the GetDPUs method. + GetDPUsFunc func() ([]*NvidiaPCIDevice, error) + + // GetGPUByIndexFunc mocks the GetGPUByIndex method. + GetGPUByIndexFunc func(n int) (*NvidiaPCIDevice, error) + + // GetGPUByPciBusIDFunc mocks the GetGPUByPciBusID method. + GetGPUByPciBusIDFunc func(s string) (*NvidiaPCIDevice, error) + + // GetGPUsFunc mocks the GetGPUs method. + GetGPUsFunc func() ([]*NvidiaPCIDevice, error) + + // GetNVSwitchesFunc mocks the GetNVSwitches method. + GetNVSwitchesFunc func() ([]*NvidiaPCIDevice, error) + + // GetNetworkControllersFunc mocks the GetNetworkControllers method. + GetNetworkControllersFunc func() ([]*NvidiaPCIDevice, error) + + // GetPciBridgesFunc mocks the GetPciBridges method. + GetPciBridgesFunc func() ([]*NvidiaPCIDevice, error) + + // GetVGAControllersFunc mocks the GetVGAControllers method. + GetVGAControllersFunc func() ([]*NvidiaPCIDevice, error) + + // calls tracks calls to the methods. + calls struct { + // Get3DControllers holds details about calls to the Get3DControllers method. + Get3DControllers []struct { + } + // GetAllDevices holds details about calls to the GetAllDevices method. + GetAllDevices []struct { + } + // GetDPUs holds details about calls to the GetDPUs method. + GetDPUs []struct { + } + // GetGPUByIndex holds details about calls to the GetGPUByIndex method. + GetGPUByIndex []struct { + // N is the n argument value. + N int + } + // GetGPUByPciBusID holds details about calls to the GetGPUByPciBusID method. + GetGPUByPciBusID []struct { + // S is the s argument value. + S string + } + // GetGPUs holds details about calls to the GetGPUs method. + GetGPUs []struct { + } + // GetNVSwitches holds details about calls to the GetNVSwitches method. + GetNVSwitches []struct { + } + // GetNetworkControllers holds details about calls to the GetNetworkControllers method. + GetNetworkControllers []struct { + } + // GetPciBridges holds details about calls to the GetPciBridges method. + GetPciBridges []struct { + } + // GetVGAControllers holds details about calls to the GetVGAControllers method. + 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 +} + +// Get3DControllers calls Get3DControllersFunc. +func (mock *InterfaceMock) Get3DControllers() ([]*NvidiaPCIDevice, error) { + if mock.Get3DControllersFunc == nil { + panic("InterfaceMock.Get3DControllersFunc: method is nil but Interface.Get3DControllers was just called") + } + callInfo := struct { + }{} + mock.lockGet3DControllers.Lock() + mock.calls.Get3DControllers = append(mock.calls.Get3DControllers, callInfo) + mock.lockGet3DControllers.Unlock() + return mock.Get3DControllersFunc() +} + +// Get3DControllersCalls gets all the calls that were made to Get3DControllers. +// Check the length with: +// +// len(mockedInterface.Get3DControllersCalls()) +func (mock *InterfaceMock) Get3DControllersCalls() []struct { +} { + var calls []struct { + } + mock.lockGet3DControllers.RLock() + calls = mock.calls.Get3DControllers + mock.lockGet3DControllers.RUnlock() + return calls +} + +// GetAllDevices calls GetAllDevicesFunc. +func (mock *InterfaceMock) GetAllDevices() ([]*NvidiaPCIDevice, error) { + if mock.GetAllDevicesFunc == nil { + panic("InterfaceMock.GetAllDevicesFunc: method is nil but Interface.GetAllDevices was just called") + } + callInfo := struct { + }{} + mock.lockGetAllDevices.Lock() + mock.calls.GetAllDevices = append(mock.calls.GetAllDevices, callInfo) + mock.lockGetAllDevices.Unlock() + return mock.GetAllDevicesFunc() +} + +// GetAllDevicesCalls gets all the calls that were made to GetAllDevices. +// Check the length with: +// +// len(mockedInterface.GetAllDevicesCalls()) +func (mock *InterfaceMock) GetAllDevicesCalls() []struct { +} { + var calls []struct { + } + mock.lockGetAllDevices.RLock() + calls = mock.calls.GetAllDevices + mock.lockGetAllDevices.RUnlock() + return calls +} + +// GetDPUs calls GetDPUsFunc. +func (mock *InterfaceMock) GetDPUs() ([]*NvidiaPCIDevice, error) { + if mock.GetDPUsFunc == nil { + panic("InterfaceMock.GetDPUsFunc: method is nil but Interface.GetDPUs was just called") + } + callInfo := struct { + }{} + mock.lockGetDPUs.Lock() + mock.calls.GetDPUs = append(mock.calls.GetDPUs, callInfo) + mock.lockGetDPUs.Unlock() + return mock.GetDPUsFunc() +} + +// GetDPUsCalls gets all the calls that were made to GetDPUs. +// Check the length with: +// +// len(mockedInterface.GetDPUsCalls()) +func (mock *InterfaceMock) GetDPUsCalls() []struct { +} { + var calls []struct { + } + mock.lockGetDPUs.RLock() + calls = mock.calls.GetDPUs + mock.lockGetDPUs.RUnlock() + return calls +} + +// GetGPUByIndex calls GetGPUByIndexFunc. +func (mock *InterfaceMock) GetGPUByIndex(n int) (*NvidiaPCIDevice, error) { + if mock.GetGPUByIndexFunc == nil { + panic("InterfaceMock.GetGPUByIndexFunc: method is nil but Interface.GetGPUByIndex was just called") + } + callInfo := struct { + N int + }{ + N: n, + } + mock.lockGetGPUByIndex.Lock() + mock.calls.GetGPUByIndex = append(mock.calls.GetGPUByIndex, callInfo) + mock.lockGetGPUByIndex.Unlock() + return mock.GetGPUByIndexFunc(n) +} + +// GetGPUByIndexCalls gets all the calls that were made to GetGPUByIndex. +// Check the length with: +// +// len(mockedInterface.GetGPUByIndexCalls()) +func (mock *InterfaceMock) GetGPUByIndexCalls() []struct { + N int +} { + var calls []struct { + N int + } + mock.lockGetGPUByIndex.RLock() + calls = mock.calls.GetGPUByIndex + mock.lockGetGPUByIndex.RUnlock() + return calls +} + +// GetGPUByPciBusID calls GetGPUByPciBusIDFunc. +func (mock *InterfaceMock) GetGPUByPciBusID(s string) (*NvidiaPCIDevice, error) { + if mock.GetGPUByPciBusIDFunc == nil { + panic("InterfaceMock.GetGPUByPciBusIDFunc: method is nil but Interface.GetGPUByPciBusID was just called") + } + callInfo := struct { + S string + }{ + S: s, + } + mock.lockGetGPUByPciBusID.Lock() + mock.calls.GetGPUByPciBusID = append(mock.calls.GetGPUByPciBusID, callInfo) + mock.lockGetGPUByPciBusID.Unlock() + return mock.GetGPUByPciBusIDFunc(s) +} + +// GetGPUByPciBusIDCalls gets all the calls that were made to GetGPUByPciBusID. +// Check the length with: +// +// len(mockedInterface.GetGPUByPciBusIDCalls()) +func (mock *InterfaceMock) GetGPUByPciBusIDCalls() []struct { + S string +} { + var calls []struct { + S string + } + mock.lockGetGPUByPciBusID.RLock() + calls = mock.calls.GetGPUByPciBusID + mock.lockGetGPUByPciBusID.RUnlock() + return calls +} + +// GetGPUs calls GetGPUsFunc. +func (mock *InterfaceMock) GetGPUs() ([]*NvidiaPCIDevice, error) { + if mock.GetGPUsFunc == nil { + panic("InterfaceMock.GetGPUsFunc: method is nil but Interface.GetGPUs was just called") + } + callInfo := struct { + }{} + mock.lockGetGPUs.Lock() + mock.calls.GetGPUs = append(mock.calls.GetGPUs, callInfo) + mock.lockGetGPUs.Unlock() + return mock.GetGPUsFunc() +} + +// GetGPUsCalls gets all the calls that were made to GetGPUs. +// Check the length with: +// +// len(mockedInterface.GetGPUsCalls()) +func (mock *InterfaceMock) GetGPUsCalls() []struct { +} { + var calls []struct { + } + mock.lockGetGPUs.RLock() + calls = mock.calls.GetGPUs + mock.lockGetGPUs.RUnlock() + return calls +} + +// GetNVSwitches calls GetNVSwitchesFunc. +func (mock *InterfaceMock) GetNVSwitches() ([]*NvidiaPCIDevice, error) { + if mock.GetNVSwitchesFunc == nil { + panic("InterfaceMock.GetNVSwitchesFunc: method is nil but Interface.GetNVSwitches was just called") + } + callInfo := struct { + }{} + mock.lockGetNVSwitches.Lock() + mock.calls.GetNVSwitches = append(mock.calls.GetNVSwitches, callInfo) + mock.lockGetNVSwitches.Unlock() + return mock.GetNVSwitchesFunc() +} + +// GetNVSwitchesCalls gets all the calls that were made to GetNVSwitches. +// Check the length with: +// +// len(mockedInterface.GetNVSwitchesCalls()) +func (mock *InterfaceMock) GetNVSwitchesCalls() []struct { +} { + var calls []struct { + } + mock.lockGetNVSwitches.RLock() + calls = mock.calls.GetNVSwitches + mock.lockGetNVSwitches.RUnlock() + return calls +} + +// GetNetworkControllers calls GetNetworkControllersFunc. +func (mock *InterfaceMock) GetNetworkControllers() ([]*NvidiaPCIDevice, error) { + if mock.GetNetworkControllersFunc == nil { + panic("InterfaceMock.GetNetworkControllersFunc: method is nil but Interface.GetNetworkControllers was just called") + } + callInfo := struct { + }{} + mock.lockGetNetworkControllers.Lock() + mock.calls.GetNetworkControllers = append(mock.calls.GetNetworkControllers, callInfo) + mock.lockGetNetworkControllers.Unlock() + return mock.GetNetworkControllersFunc() +} + +// GetNetworkControllersCalls gets all the calls that were made to GetNetworkControllers. +// Check the length with: +// +// len(mockedInterface.GetNetworkControllersCalls()) +func (mock *InterfaceMock) GetNetworkControllersCalls() []struct { +} { + var calls []struct { + } + mock.lockGetNetworkControllers.RLock() + calls = mock.calls.GetNetworkControllers + mock.lockGetNetworkControllers.RUnlock() + return calls +} + +// GetPciBridges calls GetPciBridgesFunc. +func (mock *InterfaceMock) GetPciBridges() ([]*NvidiaPCIDevice, error) { + if mock.GetPciBridgesFunc == nil { + panic("InterfaceMock.GetPciBridgesFunc: method is nil but Interface.GetPciBridges was just called") + } + callInfo := struct { + }{} + mock.lockGetPciBridges.Lock() + mock.calls.GetPciBridges = append(mock.calls.GetPciBridges, callInfo) + mock.lockGetPciBridges.Unlock() + return mock.GetPciBridgesFunc() +} + +// GetPciBridgesCalls gets all the calls that were made to GetPciBridges. +// Check the length with: +// +// len(mockedInterface.GetPciBridgesCalls()) +func (mock *InterfaceMock) GetPciBridgesCalls() []struct { +} { + var calls []struct { + } + mock.lockGetPciBridges.RLock() + calls = mock.calls.GetPciBridges + mock.lockGetPciBridges.RUnlock() + return calls +} + +// GetVGAControllers calls GetVGAControllersFunc. +func (mock *InterfaceMock) GetVGAControllers() ([]*NvidiaPCIDevice, error) { + if mock.GetVGAControllersFunc == nil { + panic("InterfaceMock.GetVGAControllersFunc: method is nil but Interface.GetVGAControllers was just called") + } + callInfo := struct { + }{} + mock.lockGetVGAControllers.Lock() + mock.calls.GetVGAControllers = append(mock.calls.GetVGAControllers, callInfo) + mock.lockGetVGAControllers.Unlock() + return mock.GetVGAControllersFunc() +} + +// GetVGAControllersCalls gets all the calls that were made to GetVGAControllers. +// Check the length with: +// +// len(mockedInterface.GetVGAControllersCalls()) +func (mock *InterfaceMock) GetVGAControllersCalls() []struct { +} { + var calls []struct { + } + mock.lockGetVGAControllers.RLock() + calls = mock.calls.GetVGAControllers + mock.lockGetVGAControllers.RUnlock() + return calls +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 4757095ea..9bf294819 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/NVIDIA/go-nvlib v0.7.3 +# github.com/NVIDIA/go-nvlib v0.7.4-0.20250707141440-532907f49628 ## explicit; go 1.20 github.com/NVIDIA/go-nvlib/pkg/nvlib/device github.com/NVIDIA/go-nvlib/pkg/nvlib/info