Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA-371311: Handle network USB devices as PCI for interface rename #125

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading