Skip to content

Pass the configured pci.ids path to the database - #128

Open
v0ropaev wants to merge 1 commit into
NVIDIA:mainfrom
v0ropaev:fix/pci-database-path
Open

v0ropaev wants to merge 1 commit into
NVIDIA:mainfrom
v0ropaev:fix/pci-database-path

Conversation

@v0ropaev

Copy link
Copy Markdown

Fixes #127.

One line at nvpci.go:385: pciids.NewDB(pciids.WithFilePath(p.pcidbPath)). WithPCIDatabasePath wrote pcidbPath and nothing read it, so a caller that mounts its own pci.ids kept getting names from the host file or the embedded snapshot, silently.

Nothing changes for callers that do not set the option: NewDB prepends the path only when it is non-empty, and newParser returns on the first readable file.

The test uses the package's own MockNvpci fixture plus a t.TempDir() pci.ids renaming 10de:20bf. On d3f4ca8 it reports

--- Expected
+++ Actual
-Device named by the configured database
+GA100 [GRID A100B]

where the actual value is line 13324 of the embedded default_pci.ids. Because the configured path is prepended rather than appended, the assertion does not depend on which distro paths exist on the runner.

go test -mod=vendor -count=1 ./... green on all seven packages, gofmt -l pkg/ and go vet ./... clean, go 1.27.1 darwin/arm64. No vendor or go.mod change.

Separate from this patch, noticed while reading: NewDB is called inside the per-device loop, so the whole database is parsed again for every PCI device on every GetAllDevices call. Happy to file that on its own if it is worth fixing.

WithPCIDatabasePath stored the caller's path in pcidbPath and nothing ever
read it: the only database construction, pciids.NewDB() in
getNvidiaDeviceByPciBusID, took no options, so NewDB fell back to the distro
paths and then the embedded snapshot. The option failed silently, which costs
a caller that mounts its own pci.ids both DeviceName and ClassName, and IsDPU
with them.

pciids.WithFilePath exists for this and had no caller in the repo. The two
halves were added the same afternoon, 76018d2 for the pciids option and
066d8f3 for the nvpci one, and the call site was left alone.

NewDB prepends the path only when it is non-empty and newParser returns on the
first readable file, so nothing changes for a caller that does not set it.

Fixes NVIDIA#127

Signed-off-by: Dmitry Voropaev <dy.voropaev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WithPCIDatabasePath is ignored; the configured pci.ids is never read

1 participant