Closed Babar closed 3 months ago
@Babar can you add a couple cases in spec/unit/plugins/linux/lspci_spec.rb to match the additional regex component specifically?
Issues
2 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
No data about Duplication
@tpowell-progress : added one. Can add more but wasn't sure what I should be testing.
Description
(sorry, I'm using domain and root port interchangeably. Maybe domain is more correct, if so I can update the code to use that instead of
root_port
)I'm guessing most machines only have one PCIe root port, but things like ARM hosts tend to have more, and that breaks as it creates collisions.
As we want to keep backwards compatibility, and
lspci
is run with the defaults that doesn't show the root port if it's0000
, only add it when it's non-zero, and also add it as a new extra field calledroot_port
to denote the fact that there is one (useful when using the BDF to find files on disk, as when there is noroot_port
, one needs to add the extra0000:
.More detailed explanation I wrote on the slack channel: On Linux, we run
lspci -vnnmk
, which will show the BDF in the firstDevice:
field. So the first bug is that the regular expression on https://github.com/chef/ohai/blob/main/lib/ohai/plugins/linux/lspci.rb#L54 is missing a\
before the.
, therefore will will match0001:02:03.4
as01:02:03
which is plain broken. But fixing that we end up with02:03.4
which is also plain wrong as it loses the root complex. I see a few ways we could fix this:I like 4 the most, as it mirrors closely what lspci does (https://github.com/pciutils/pciutils/blob/master/lspci.c#L285) or maybe
Test Plan: Before:
After:
Related Issue
pci collection should always include the domain #1693
Types of changes
Checklist:
Gemfile.lock
has changed, I have used--conservative
to do it and included the full output in the Description above.