Repository navigation
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #127.
One line at
nvpci.go:385:pciids.NewDB(pciids.WithFilePath(p.pcidbPath)).WithPCIDatabasePathwrotepcidbPathand nothing read it, so a caller that mounts its ownpci.idskept getting names from the host file or the embedded snapshot, silently.Nothing changes for callers that do not set the option:
NewDBprepends the path only when it is non-empty, andnewParserreturns on the first readable file.The test uses the package's own
MockNvpcifixture plus at.TempDir()pci.idsrenaming10de:20bf. Ond3f4ca8it reportswhere 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/andgo vet ./...clean, go 1.27.1 darwin/arm64. No vendor or go.mod change.Separate from this patch, noticed while reading:
NewDBis called inside the per-device loop, so the whole database is parsed again for every PCI device on everyGetAllDevicescall. Happy to file that on its own if it is worth fixing.