Skip to content

Commit

Permalink
Fix can't get pfname for virtio pci path
Browse files Browse the repository at this point in the history
Fixed issue with virtio driver by adding a conditional check for the virtio path under the PCI address,
preventing errors when the pf name cannot be found. This ensures successful acquisition of vf resources.

Fixes k8snetworkplumbingwg#507

Signed-off-by: JasinlikeEatingOrange <[email protected]>
  • Loading branch information
JasinlikeEatingOrange authored and huangyunpeng committed Nov 30, 2023
1 parent ed52ba7 commit 5fac342
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ func GetPfName(pciAddr string) (string, error) {
}

path := filepath.Join(sysBusPci, pciAddr, "physfn", "net")
vertIOpath := filepath.Join(sysBusPci, pciAddr, "physfn")
dir, err := os.ReadDir(vertIOpath)
if err != nil {
return "", nil
}
for _, file := range dir {
if strings.Contains(file.Name(), "virtio") {
path = filepath.Join(vertIOpath, file.Name(), "net")
break
}
}
files, err := os.ReadDir(path)
if err != nil {
if os.IsNotExist(err) {
Expand Down Expand Up @@ -512,3 +523,4 @@ func ParseAuxDeviceType(deviceID string) string {
// not an auxiliary device
return ""
}

0 comments on commit 5fac342

Please sign in to comment.