Commit 13879c6
committed
refactor(pci): simplify MSI-X interrupts implementation
Our implementation of MSI-X was taken from the equivalent
Cloud Hypervisor one. Cloud Hypervisor supports non-KVM hypervisors,
hence they introduced a few abstractions to cater for that. More
specifically, they are using a trait (`InterruptSourceGroup`) to
describe the underlying hypervisor-specific mechanism used to drive
MSI-X interrupts from the device to the guest.
Moreover, they use a couple of types to distinguish between MSI, MSI-X
and legacy IRQ interrupts and how these can be configured. This is
especially useful for MSI/MSI-X interrupts where the interrupt
configuration is provided by the guest over PCI bus MMIO accesses.
Finally, in order to allow for transparent error handling, `Result`
types returned by related trait methods was returning `std::io::Error`
types as the error type, which is not very intuitive.
We don't need all of that. We clearly distinguish between legacy
interrupts and MSI-X (we don't use at all MSI), so we can simply plug in
all the definitions directly where we need them without any dynamic
dispatch indirection.
Moreover, various MSI-X components were stored all over the place
creating a lot of unnecessary duplication.
This commit refactors our implementation to get rid of the unnecessary
bit of dynamic dispatch. We still keep the `VirtioInterrupt` trait which
we use to abstract the actual interrupt type (IRQ or MSI-X) from VirtIO
devices. Moreover, it removes the duplication of MSI-X related types
across various types. We only duplicate the MSI-X configuration type
(which is behind an Arc) in a few places to avoid needing to
unnecessarily take a lock(). Moreover, we introduce a single interrupt
related error type and get rid of the `std::io::Error` usage.
Finally, it introduces a couple of metrics for interrupts that are
useful information by themselves, but also help us maintain some unit
testing assertions for which we were relying on a mock type that
implemented `InterruptSourceGroup`.
Signed-off-by: Babis Chalios <[email protected]>1 parent b49d4c9 commit 13879c6
File tree
13 files changed
+436
-527
lines changed- src/vmm/src
- device_manager
- devices
- virtio
- balloon
- block/vhost_user
- transport
- pci
- logger
- pci
- vstate
- tests/host_tools
13 files changed
+436
-527
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | | - | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
129 | 134 | | |
130 | 135 | | |
131 | 136 | | |
| |||
162 | 167 | | |
163 | 168 | | |
164 | 169 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
173 | | - | |
| 174 | + | |
174 | 175 | | |
175 | | - | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
75 | | - | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
399 | 400 | | |
400 | 401 | | |
401 | 402 | | |
402 | | - | |
| 403 | + | |
| 404 | + | |
403 | 405 | | |
404 | 406 | | |
405 | 407 | | |
406 | 408 | | |
407 | 409 | | |
408 | 410 | | |
409 | | - | |
| 411 | + | |
410 | 412 | | |
411 | 413 | | |
412 | 414 | | |
| 415 | + | |
413 | 416 | | |
414 | 417 | | |
415 | 418 | | |
| |||
449 | 452 | | |
450 | 453 | | |
451 | 454 | | |
452 | | - | |
| 455 | + | |
453 | 456 | | |
454 | 457 | | |
455 | 458 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | | - | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | | - | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
0 commit comments