Skip to content

Commit

Permalink
CA-371311: Handle network USB devices as PCI for interface rename
Browse files Browse the repository at this point in the history
Currently the presence of any network USB device causes issues
with the interface rename due to not being considered during the
rename.
For instance this causes collisions causing renames to fail
due to destination name already used.

Signed-off-by: Frediano Ziglio <[email protected]>
  • Loading branch information
freddy77 committed Feb 9, 2024
1 parent feeb478 commit a48151a
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 a48151a

Please sign in to comment.