This repository was archived by the owner on Nov 6, 2024. It is now read-only.
Commit da48ab3
committed
Add
Add implementations of `serde::{Serialize, Deserialize}` for
kvm-bindings structures commonly used for live migration/snapshotting.
The selections of structures to add the derives to was determined by
finding the minimal set that allows both Firecracker and CloudHypervisor
to compile against this branch.
Serialization happens as opaque binary blobs via the `zerocopy` crate.
This is to support live migration across different versions of
kvm-bindings (which can potentially be using bindings generated from
different versions of the kernel headers). Since the kernel's ABI is
backward-compatible, the only changes that can happen are:
- "reserved" areas of structures acquire meaning. This is a change
purely at the representational level, and has no impact on the
underlying binary representation. Thus, our serialization is
roboust to these changes (whereas simply deriving the serde traits
would cause incompatibilities here).
- Adding new fields to the end of a structure. When deserializating, we
compare the length of the deserialized data with the size of the
struct, and pad with zeros/truncate as appropriate.
This allows seamless live update.
We pick the `zerocopy` crate for binary serialization as it is already
in use in the rust-vmm ecosystem (in `acpi_tables`), and it has a very
strong security stance (for example, using formal verification in their
CI). The alternative would have been using `ByteValued` from
`vm-memory`, but I do not want `kvm-bindings` to gain a dependency on
`vm-memory` (especially since `vm-memory` brings in a lot more
functionality that `kvm-bindings` does not need).
Signed-off-by: Patrick Roy <[email protected]>serde support for various bindings1 parent 33a89cc commit da48ab3
File tree
10 files changed
+394
-5
lines changed- src
- arm64
- x86_64
10 files changed
+394
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
| 19 | + | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | | - | |
| 37 | + | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
955 | 955 | | |
956 | 956 | | |
957 | 957 | | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
958 | 962 | | |
959 | 963 | | |
960 | 964 | | |
| |||
1019 | 1023 | | |
1020 | 1024 | | |
1021 | 1025 | | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
1022 | 1030 | | |
1023 | 1031 | | |
1024 | 1032 | | |
| |||
1499 | 1507 | | |
1500 | 1508 | | |
1501 | 1509 | | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
1502 | 1514 | | |
1503 | 1515 | | |
1504 | 1516 | | |
| |||
1574 | 1586 | | |
1575 | 1587 | | |
1576 | 1588 | | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
1577 | 1593 | | |
1578 | 1594 | | |
1579 | 1595 | | |
| |||
6511 | 6527 | | |
6512 | 6528 | | |
6513 | 6529 | | |
| 6530 | + | |
| 6531 | + | |
| 6532 | + | |
| 6533 | + | |
6514 | 6534 | | |
6515 | 6535 | | |
6516 | 6536 | | |
| |||
8786 | 8806 | | |
8787 | 8807 | | |
8788 | 8808 | | |
| 8809 | + | |
| 8810 | + | |
| 8811 | + | |
| 8812 | + | |
8789 | 8813 | | |
8790 | 8814 | | |
8791 | 8815 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
15 | 25 | | |
16 | 26 | | |
17 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
0 commit comments