From a48151a5c2b515c4f5925467f1dba699879be537 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Fri, 9 Feb 2024 14:14:32 +0000 Subject: [PATCH] CA-371311: Handle network USB devices as PCI for interface rename 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 --- tests/data/all_ethN.biosdevname | 8 ++++++++ tests/data/physical.biosdevname | 8 ++++++++ tests/test_biosdevname.py | 4 ++++ xcp/net/biosdevname.py | 4 ++++ 4 files changed, 24 insertions(+) diff --git a/tests/data/all_ethN.biosdevname b/tests/data/all_ethN.biosdevname index 63bdc506..b1541ddc 100644 --- a/tests/data/all_ethN.biosdevname +++ b/tests/data/all_ethN.biosdevname @@ -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 diff --git a/tests/data/physical.biosdevname b/tests/data/physical.biosdevname index 3e0611d7..5392882e 100644 --- a/tests/data/physical.biosdevname +++ b/tests/data/physical.biosdevname @@ -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 diff --git a/tests/test_biosdevname.py b/tests/test_biosdevname.py index ea4bc127..fe1808bd 100644 --- a/tests/test_biosdevname.py +++ b/tests/test_biosdevname.py @@ -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') diff --git a/xcp/net/biosdevname.py b/xcp/net/biosdevname.py index ca00e20f..7099ca55 100644 --- a/xcp/net/biosdevname.py +++ b/xcp/net/biosdevname.py @@ -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: