Skip to content

Commit

Permalink
Merge pull request #125 from freddy77/support_usb_nics
Browse files Browse the repository at this point in the history
CA-371311: Handle network USB devices as PCI for interface rename
  • Loading branch information
andyhhp authored Feb 12, 2024
2 parents 21987f1 + a48151a commit a17b271
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/data/all_ethN.biosdevname
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,11 @@ VPD Port: 4
VPD Index: 1
VPD PCI master: 0000:07:00.1

BIOS device: eth4
Kernel name: eth4
Permanent MAC: 40:54:00:12:34:56
Assigned MAC : 40:54:00:12:34:56
Driver: cdc_ether
Driver version: 22-Aug-2005
Firmware version: CDC Ethernet Device
Bus Info: usb-0000:00:02.0-1
8 changes: 8 additions & 0 deletions tests/data/physical.biosdevname
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,11 @@ VPD Port: 4
VPD Index: 1
VPD PCI master: 0000:07:00.1

BIOS device:
Kernel name: eth4
Permanent MAC: 40:54:00:12:34:56
Assigned MAC : 40:54:00:12:34:56
Driver: cdc_ether
Driver version: 22-Aug-2005
Firmware version: CDC Ethernet Device
Bus Info: usb-0000:00:02.0-1
4 changes: 4 additions & 0 deletions tests/test_biosdevname.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ def test(self):

self.assertEqual(devices['eth0']['BIOS device'],
{'all_ethN': 'eth0', 'physical': 'em1'})

self.assertEqual(devices['eth4']['BIOS device'],
{'all_ethN': 'eth4', 'physical': ''})
self.assertEqual(devices['eth4']['Bus Info'], '0000:00:02.0')
4 changes: 4 additions & 0 deletions xcp/net/biosdevname.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def all_devices_all_names():
"BIOS device" not in dinfo ):
continue

# Treat USB devices the PCI device of their host adapter
if dinfo.get("Bus Info", "").startswith("usb-"):
dinfo["Bus Info"] = dinfo["Bus Info"].split('-')[1]

kname = dinfo["Kernel name"]

if kname in devices:
Expand Down

0 comments on commit a17b271

Please sign in to comment.