[PATCH v2] dts: fix port info getter when port is not found
Riley Fletcher
rileyf at linux.ibm.com
Wed Apr 22 20:35:24 CEST 2026
In DTS, when providing an nonexisting PCI address, a ConfigurationError
should be thrown. Instead, because the next() is not given a default
None, it instead hits a StopIteration error, which is harder to debug.
Fixes: 0a210d88c36 ("dts: improve port model")
Cc: stable at dpdk.org
Signed-off-by: Riley Fletcher <rileyf at linux.ibm.com>
---
dts/framework/testbed_model/linux_session.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dts/framework/testbed_model/linux_session.py b/dts/framework/testbed_model/linux_session.py
index ee943462c2..3de92b549e 100644
--- a/dts/framework/testbed_model/linux_session.py
+++ b/dts/framework/testbed_model/linux_session.py
@@ -168,7 +168,7 @@ def get_port_info(self, pci_address: str) -> PortInfo:
ConfigurationError: If the port could not be found.
"""
bus_info = f"pci@{pci_address}"
- port = next(port for port in self._lshw_net_info if port.get("businfo") == bus_info)
+ port = next((port for port in self._lshw_net_info if port.get("businfo") == bus_info), None)
if port is None:
raise ConfigurationError(f"Port {pci_address} could not be found on the node.")
--
2.53.0
More information about the stable
mailing list