Commit b49d4c9
committed
refactor(pci): separate functions for new and restored types
The code we inherited from Cloud Hypervisor was using a single `new`
method for creating objects both for booted and snapshot resumed VMs.
The `new` method had an optional `state` argument. When this argument
was `Some(state)` the construction of the object happened through
copying values from `state`.
Split this functionality, for various types, in two distinct methods
`new` & `from_state` which are only called for booted and snapshotted
microVMs respectively. This is similar to the pattern we're using
throughout Firecracker, reduces if/else branches, as well as the
arguments of distinct methods.
Signed-off-by: Babis Chalios <[email protected]>1 parent 3219931 commit b49d4c9
File tree
4 files changed
+104
-123
lines changed- src/vmm/src
- devices/virtio/transport/pci
- pci
4 files changed
+104
-123
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | | - | |
316 | 315 | | |
317 | 316 | | |
318 | 317 | | |
| |||
339 | 338 | | |
340 | 339 | | |
341 | 340 | | |
342 | | - | |
343 | 341 | | |
344 | 342 | | |
345 | 343 | | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | 344 | | |
362 | 345 | | |
363 | 346 | | |
| |||
399 | 382 | | |
400 | 383 | | |
401 | 384 | | |
402 | | - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
403 | 390 | | |
404 | 391 | | |
405 | 392 | | |
406 | | - | |
407 | 393 | | |
408 | 394 | | |
409 | 395 | | |
| |||
448 | 434 | | |
449 | 435 | | |
450 | 436 | | |
451 | | - | |
| 437 | + | |
| 438 | + | |
452 | 439 | | |
453 | 440 | | |
454 | | - | |
455 | | - | |
| 441 | + | |
456 | 442 | | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
461 | 446 | | |
462 | 447 | | |
463 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
| |||
500 | 499 | | |
501 | 500 | | |
502 | 501 | | |
503 | | - | |
504 | 502 | | |
505 | 503 | | |
506 | 504 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | 105 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
138 | 118 | | |
139 | 119 | | |
140 | 120 | | |
141 | 121 | | |
142 | | - | |
143 | | - | |
144 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
145 | 140 | | |
146 | 141 | | |
147 | 142 | | |
| |||
654 | 649 | | |
655 | 650 | | |
656 | 651 | | |
657 | | - | |
658 | 652 | | |
659 | 653 | | |
660 | 654 | | |
| |||
0 commit comments