Commit 8e2a28e
committed
ext/pci: implement PCI path for device identification
PCI SBDF may change if _another_ device is added/removed from the
system. Use PCI device path to avoid this issue. The PCI device path is
more or less sysfs path, but with bus number behind bridges replaced
with relative bus number to bridge's secondary bus number. Each
component of the path is separated with '-', as that is allowed in
qrexec arguments.
For example device 0000:c1:00.0 behind bridge at 0000:00:08.1 will get
path 0000_00_08.1-00_00.0 (assuming bridge 0000:00:08.1 has secondary
bus at 0xc1). Resolving device path requires access to the system's
sysfs.
As a side effect, this adds also support for multi-segment systems, PCI
segment is no longer hardcoded to 0000.
PCIDevice object will automatically resolve old device identifiers,
which partially covers migration path. The other part is converting BDF
to device path when loading device assignments.
Tests include subset of sysfs from a real system that has multiple
bridges.
TODO:
- consider still allowing attaching via SBDF, or otherwise expose function
to translate SBDF to PCI path (an Admin API call?)
- fix salt listing/attaching devices to sys-net/sys-usb - depending on
the above
Fixes QubesOS/qubes-issues#86811 parent a1778ad commit 8e2a28e
24 files changed
Lines changed: 299 additions & 24 deletions
File tree
- qubes
- ext
- tests
- vm
- vm
- rpm_spec
- templates/libvirt/devices
- tests-data/sysfs/sys
- bus/pci/devices
- devices
- pci0000:00/0000:00:08.1
- pci0000:c0/0000:c0:03.5
- 0000:c5:00.0
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
141 | | - | |
142 | | - | |
| 142 | + | |
| 143 | + | |
143 | 144 | | |
144 | 145 | | |
145 | | - | |
146 | | - | |
| 146 | + | |
| 147 | + | |
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
154 | | - | |
155 | | - | |
156 | | - | |
| 155 | + | |
157 | 156 | | |
158 | 157 | | |
159 | 158 | | |
| |||
162 | 161 | | |
163 | 162 | | |
164 | 163 | | |
165 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
166 | 169 | | |
167 | 170 | | |
168 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
169 | 174 | | |
170 | 175 | | |
| 176 | + | |
| 177 | + | |
171 | 178 | | |
172 | 179 | | |
| 180 | + | |
| 181 | + | |
173 | 182 | | |
174 | 183 | | |
175 | 184 | | |
| |||
249 | 258 | | |
250 | 259 | | |
251 | 260 | | |
252 | | - | |
| 261 | + | |
253 | 262 | | |
254 | 263 | | |
255 | 264 | | |
| |||
380 | 389 | | |
381 | 390 | | |
382 | 391 | | |
| 392 | + | |
383 | 393 | | |
384 | 394 | | |
385 | 395 | | |
386 | 396 | | |
387 | | - | |
| 397 | + | |
| 398 | + | |
388 | 399 | | |
389 | 400 | | |
390 | 401 | | |
391 | 402 | | |
392 | 403 | | |
393 | 404 | | |
394 | 405 | | |
395 | | - | |
| 406 | + | |
396 | 407 | | |
397 | | - | |
| 408 | + | |
| 409 | + | |
398 | 410 | | |
399 | 411 | | |
400 | 412 | | |
401 | 413 | | |
402 | 414 | | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
| 415 | + | |
| 416 | + | |
408 | 417 | | |
409 | 418 | | |
410 | 419 | | |
| |||
458 | 467 | | |
459 | 468 | | |
460 | 469 | | |
461 | | - | |
| 470 | + | |
462 | 471 | | |
463 | 472 | | |
464 | 473 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| |||
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
110 | | - | |
111 | | - | |
112 | 115 | | |
113 | | - | |
| 116 | + | |
114 | 117 | | |
115 | 118 | | |
116 | 119 | | |
117 | 120 | | |
118 | 121 | | |
119 | 122 | | |
120 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
121 | 164 | | |
122 | 165 | | |
123 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| |||
928 | 936 | | |
929 | 937 | | |
930 | 938 | | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
931 | 988 | | |
932 | 989 | | |
933 | 990 | | |
| |||
1527 | 1584 | | |
1528 | 1585 | | |
1529 | 1586 | | |
| 1587 | + | |
1530 | 1588 | | |
1531 | 1589 | | |
1532 | 1590 | | |
| |||
1637 | 1695 | | |
1638 | 1696 | | |
1639 | 1697 | | |
| 1698 | + | |
1640 | 1699 | | |
1641 | 1700 | | |
1642 | 1701 | | |
| |||
0 commit comments