nvmdev

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Path       string
	UUID       string
	MDEVType   string
	Driver     string
	IommuGroup int
	Parent     *ParentDevice
}

Device represents an NVIDIA MDEV (vGPU) device.

func (*Device) Delete

func (m *Device) Delete() error

Delete deletes a mediated device (vGPU).

func (*Device) GetPhysicalFunction

func (m *Device) GetPhysicalFunction() *nvpci.NvidiaPCIDevice

GetPhysicalFunction gets the physical PCI device that a vGPU is created on.

type Interface

type Interface interface {
	GetAllDevices() ([]*Device, error)
	GetAllParentDevices() ([]*ParentDevice, error)
}

Interface allows us to get a list of NVIDIA MDEV (vGPU) and parent devices.

func New

func New(opts ...Option) Interface

New interface that allows us to get a list of all NVIDIA parent and MDEV (vGPU) devices.

type MockNvmdev

type MockNvmdev struct {
	// contains filtered or unexported fields
}

MockNvmdev mock mdev device.

func NewMock

func NewMock() (mock *MockNvmdev, rerr error)

NewMock creates new mock mediated (vGPU) and parent PCI devices and removes old devices.

func (*MockNvmdev) AddMockA100Mdev

func (m *MockNvmdev) AddMockA100Mdev(uuid string, mdevType string, mdevTypeDir string, parentDeviceDir string) error

AddMockA100Mdev creates an A100 like MDEV (vGPU) mock device. The corresponding mocked parent A100 device must be created beforehand.

func (*MockNvmdev) AddMockA100Parent

func (m *MockNvmdev) AddMockA100Parent(address string, numaNode int) error

AddMockA100Parent creates an A100 like parent GPU mock device.

func (*MockNvmdev) Cleanup

func (m *MockNvmdev) Cleanup()

Cleanup removes the mocked mediated (vGPU) and parent PCI devices root folders.

func (MockNvmdev) GetAllDevices

func (m MockNvmdev) GetAllDevices() ([]*Device, error)

GetAllDevices returns all NVIDIA mdev (vGPU) devices on the system.

func (MockNvmdev) GetAllParentDevices

func (m MockNvmdev) GetAllParentDevices() ([]*ParentDevice, error)

GetAllParentDevices returns all NVIDIA Parent PCI devices on the system.

func (MockNvmdev) NewDevice added in v0.6.1

func (n MockNvmdev) NewDevice(root string, uuid string) (*Device, error)

NewDevice constructs a Device, which represents an NVIDIA mdev (vGPU) device.

func (MockNvmdev) NewParentDevice added in v0.6.1

func (m MockNvmdev) NewParentDevice(devicePath string) (*ParentDevice, error)

NewParentDevice constructs a ParentDevice.

type Option added in v0.6.1

type Option func(*nvmdev)

Option defines a function for passing options to the New() call.

func WithNvpciLib added in v0.6.1

func WithNvpciLib(nvpciLib nvpci.Interface) Option

WithNvpciLib provides an Option to set the nvpci library.

type ParentDevice

type ParentDevice struct {
	*nvpci.NvidiaPCIDevice
	// contains filtered or unexported fields
}

ParentDevice represents an NVIDIA parent PCI device.

func (*ParentDevice) CreateMDEVDevice

func (p *ParentDevice) CreateMDEVDevice(mdevType string, id string) error

CreateMDEVDevice creates a mediated device (vGPU) on the parent GPU.

func (*ParentDevice) DeleteMDEVDevice

func (p *ParentDevice) DeleteMDEVDevice(id string) error

DeleteMDEVDevice deletes a mediated device (vGPU).

func (*ParentDevice) GetAvailableMDEVInstances

func (p *ParentDevice) GetAvailableMDEVInstances(mdevType string) (int, error)

GetAvailableMDEVInstances returns the available instances for mdevType. Return -1 if mdevType is not supported for the device.

func (*ParentDevice) GetPhysicalFunction

func (p *ParentDevice) GetPhysicalFunction() *nvpci.NvidiaPCIDevice

GetPhysicalFunction gets the physical PCI device backing a 'parent' device.

func (*ParentDevice) IsMDEVTypeAvailable

func (p *ParentDevice) IsMDEVTypeAvailable(mdevType string) (bool, error)

IsMDEVTypeAvailable checks if a vGPU instance of mdevType can be created on the parent GPU.

func (*ParentDevice) IsMDEVTypeSupported

func (p *ParentDevice) IsMDEVTypeSupported(mdevType string) bool

IsMDEVTypeSupported checks if the mdevType is supported by the GPU.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL