Commit 27c7be6
committed
fix: saving/restoring async IO engine transport state
When saving the state of a microVM with one or more block devices backed
by the async IO engine, we need to take a few steps extra steps before
serializing the state to the disk, as we need to make sure that there
aren't any pending io_uring requests that have not been handled by the
kernel yet. For these types of devices that need that we call a
prepare_save() hook before serializing the device state.
If there are indeed pending requests, once we handle them we need to let
the guest know, by adding the corresponding VirtIO descriptors to the
used ring. Moreover, since we use notification suppression, this might
or might not require us to send an interrupt to the guest.
Now, when we save the state of a VirtIO device, we save the device
specific state **and** the transport (MMIO or PCI) state along with it.
There were a few issues with how we were doing the serialization:
1. We were saving the transport state before we run the prepare_save()
hook. The transport state includes information such as the
`interrupt_status` in MMIO or `MSI-X config` in PCI. prepare_save()
in the case of async IO might change this state, so us running it
after saving the transport state essentially looses information.
2. We were saving the devices states after saving the KVM state. This is
problematic because, if prepare_save() sends an interrupt to the
guest we don't save that "pending interrupt" bit of information in
the snapshot.
These two issues, were making microVMs with block devices backed by
async IO freeze in some cases post snapshot resume, since the guest is
stuck in the kernel waiting for some notification for the device
emulation which never arrives.
Currently, this is only a problem with virtio-block with async IO
engine. The only other device using the prepare_save() hook is currently
virtio-net, but this one doesn't modify any VirtIO state, neither sends
interrupts.
Fix this by ensuring the correct ordering of operations during the
snapshot phase.
Signed-off-by: Babis Chalios <bchalios@amazon.es>1 parent ff0e866 commit 27c7be6
File tree
6 files changed
+46
-34
lines changed- src/vmm/src
- device_manager
- devices/virtio
- block
- net
6 files changed
+46
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | | - | |
287 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
288 | 290 | | |
| 291 | + | |
| 292 | + | |
289 | 293 | | |
290 | 294 | | |
291 | 295 | | |
| |||
316 | 320 | | |
317 | 321 | | |
318 | 322 | | |
319 | | - | |
320 | 323 | | |
321 | 324 | | |
322 | 325 | | |
| |||
338 | 341 | | |
339 | 342 | | |
340 | 343 | | |
341 | | - | |
342 | 344 | | |
343 | 345 | | |
344 | 346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
230 | 235 | | |
231 | 236 | | |
232 | 237 | | |
233 | 238 | | |
234 | | - | |
235 | 239 | | |
236 | 240 | | |
237 | 241 | | |
| |||
255 | 259 | | |
256 | 260 | | |
257 | 261 | | |
258 | | - | |
259 | 262 | | |
260 | 263 | | |
261 | 264 | | |
| |||
275 | 278 | | |
276 | 279 | | |
277 | 280 | | |
278 | | - | |
279 | 281 | | |
280 | 282 | | |
281 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | 85 | | |
93 | 86 | | |
94 | 87 | | |
| |||
227 | 220 | | |
228 | 221 | | |
229 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
172 | 175 | | |
173 | 176 | | |
174 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
938 | 938 | | |
939 | 939 | | |
940 | 940 | | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
959 | | - | |
960 | | - | |
961 | 941 | | |
962 | 942 | | |
963 | 943 | | |
| |||
1069 | 1049 | | |
1070 | 1050 | | |
1071 | 1051 | | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
1072 | 1072 | | |
1073 | 1073 | | |
1074 | 1074 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
439 | 445 | | |
440 | 446 | | |
441 | 447 | | |
| |||
450 | 456 | | |
451 | 457 | | |
452 | 458 | | |
453 | | - | |
454 | 459 | | |
455 | 460 | | |
456 | 461 | | |
| |||
0 commit comments