Skip to content

Commit

Permalink
Fix parsing of PCI domains longer than 4 digits
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Bishop <151477169+ianb-mp@users.noreply.github.com>
  • Loading branch information
ianb-mp committed Sep 4, 2024
1 parent 22ffa03 commit ccca41a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/pci/address/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

var (
regexAddress *regexp.Regexp = regexp.MustCompile(
`^(([0-9a-f]{0,8}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-9a-f]{1})$`,
`^((1?[0-9a-f]{0,4}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-9a-f]{1})$`,
)
)

Expand Down
10 changes: 10 additions & 0 deletions pkg/pci/address/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ func TestPCIAddressFromString(t *testing.T) {
Function: "a",
},
},
{
// PCI-X / PCI Express extentions may use 5-digit domain
addrStr: "10000:03:00.A",
expected: &pciaddr.Address{
Domain: "10000",
Bus: "03",
Device: "00",
Function: "a",
},
},
}
for x, test := range tests {
got := pciaddr.FromString(test.addrStr)
Expand Down

0 comments on commit ccca41a

Please sign in to comment.