pci: improve handling of unresolvable PCI paths - #884
Conversation
If a config space read fails (reported to happen for some Thunderbolt
devices for example, or when device hangs), reads return 0xff.
This resulted in assertion failure like this:
File "/usr/lib/python3.13/site-packages/qubes/ext/pci.py", line 369, in on_device_list_pci
yield PCIDevice(
~~~~~~~~~^
Port(backend_domain=vm, port_id=None, devclass="pci"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
libvirt_name=libvirt_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/lib/python3.13/site-packages/qubes/ext/pci.py", line 156, in __init__
port_id = sbdf_to_path(libvirt_name)
File "/usr/lib/python3.13/site-packages/qubes/utils.py", line 416, in sbdf_to_path
assert int(bridge_match["bus"], 16) >= bus_offset
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
Improve it in several ways:
1. Do not crash in such case, but return None, as unresolvable path
(similar to missing device)
2. Do not list devices that failed path resolution - they can't be
assigned/attached anyway (that operation needs a path)
3. Log a warning with a hint what happened
Fixes QubesOS/qubes-issues#10847
Those return 0xff on read. While I don't have a confirmation yet how such broken device looks in sysfs, assume 0xff gets translated to 255 value.
307f4d8 to
2222a1d
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #884 +/- ##
==========================================
- Coverage 70.72% 70.67% -0.05%
==========================================
Files 61 61
Lines 14315 14324 +9
==========================================
Hits 10124 10124
- Misses 4191 4200 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
OpenQA test summaryComplete test suite and dependencies: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026091002-devel&flavor=pull-requests Test run included the following:
New failures, excluding unstableCompared to: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026050504-devel&flavor=update
Failed tests12 failures
Fixed failuresCompared to: https://openqa.qubes-os.org/tests/176874#dependencies 37 fixed
Unstable testsDetails
Performance TestsPerformance degradation:No issues Remaining performance tests:72 tests
|
If a config space read fails (reported to happen for some Thunderbolt
devices for example, or when device hangs), reads return 0xff.
This resulted in assertion failure like this:
File "/usr/lib/python3.13/site-packages/qubes/ext/pci.py", line 369, in on_device_list_pci
yield PCIDevice(
~~~~~~~~~^
Port(backend_domain=vm, port_id=None, devclass="pci"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
libvirt_name=libvirt_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/lib/python3.13/site-packages/qubes/ext/pci.py", line 156, in init
port_id = sbdf_to_path(libvirt_name)
File "/usr/lib/python3.13/site-packages/qubes/utils.py", line 416, in sbdf_to_path
assert int(bridge_match["bus"], 16) >= bus_offset
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
Improve it in several ways:
(similar to missing device)
assigned/attached anyway (that operation needs a path)
Fixes QubesOS/qubes-issues#10847