Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop versionize support, substitute with serde #4230

Merged
merged 11 commits into from
Jan 15, 2024

Conversation

bchalios
Copy link
Contributor

@bchalios bchalios commented Nov 9, 2023

Changes

Remove support for Versionize from Firecracker and substitute it with serde. We use bincode for the actual (de)serialization. Also, define a snapshot format version that is decoupled from Firecracker version. The newly defined version of the snapshot format will follow semantic versioning and it will start from version 1.0.0.

This PR breaks compatibility with all previous snapshot versions. From now on, snapshot compatibility will be reflected to the snapshot version. Changes in the major release number are backwards incompatible, changes in the minor release number are backwards compatible and changes in patch releases are always compatible.

That said, we are currently using bincode for the serialization, which means that all changes in the snapshot format will be backwards incompatible (they will imply a major version number bump). However, if the need arises we will investigate alternatives to bincode that would allow greater flexibility for backwards compatibility.

This change makes a lot of our integration tests redundant.

Reason

We used Versionize to allow for extended backwards compatibility for Firecracker snapshots. In practice we did not find this feature useful, so we paid the code maintenance and testing complexity cost without a measurable benefit.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following
Developer Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • If a specific issue led to this PR, this PR closes the issue.
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • API changes follow the Runbook for Firecracker API changes.
  • User-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.
  • New TODOs link to an issue.
  • Commits meet contribution quality standards.

  • This functionality cannot be added in rust-vmm.

@bchalios
Copy link
Contributor Author

bchalios commented Nov 9, 2023

This PR depends on the equivalent PR on kvm-bindings side: firecracker-microvm/kvm-bindings#21

Copy link

codecov bot commented Nov 9, 2023

Codecov Report

Attention: 36 lines in your changes are missing coverage. Please review.

Comparison is base (a774e26) 81.57% compared to head (d58177b) 81.53%.

Files Patch % Lines
src/firecracker/src/main.rs 0.00% 16 Missing ⚠️
src/snapshot-editor/src/info.rs 0.00% 6 Missing ⚠️
src/snapshot-editor/src/utils.rs 0.00% 4 Missing ⚠️
src/vmm/src/persist.rs 50.00% 4 Missing ⚠️
src/snapshot/src/crc.rs 92.59% 2 Missing ⚠️
src/snapshot/src/lib.rs 98.41% 1 Missing ⚠️
src/vmm/src/device_manager/persist.rs 88.88% 1 Missing ⚠️
...vmm/src/devices/virtio/vhost_user_block/persist.rs 0.00% 1 Missing ⚠️
src/vmm/src/rpc_interface.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4230      +/-   ##
==========================================
- Coverage   81.57%   81.53%   -0.05%     
==========================================
  Files         240      241       +1     
  Lines       29408    29238     -170     
==========================================
- Hits        23990    23838     -152     
+ Misses       5418     5400      -18     
Flag Coverage Δ
4.14-c7g.metal ?
4.14-m5d.metal ?
4.14-m6a.metal 77.94% <78.18%> (-0.07%) ⬇️
4.14-m6g.metal 76.92% <81.53%> (-0.06%) ⬇️
4.14-m6i.metal 78.82% <78.18%> (-0.06%) ⬇️
5.10-c7g.metal ?
5.10-m5d.metal 81.49% <78.18%> (-0.08%) ⬇️
5.10-m6a.metal 80.71% <78.18%> (-0.06%) ⬇️
5.10-m6g.metal 79.83% <81.53%> (-0.04%) ⬇️
5.10-m6i.metal 81.48% <78.18%> (-0.06%) ⬇️
6.1-c7g.metal 79.83% <81.53%> (-0.04%) ⬇️
6.1-m5d.metal 81.49% <78.18%> (-0.07%) ⬇️
6.1-m6a.metal ?
6.1-m6g.metal ?
6.1-m6i.metal 81.48% <78.18%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bchalios bchalios force-pushed the drop_versionize_support branch 7 times, most recently from 948f6e0 to 3d54ac2 Compare November 14, 2023 08:23
@bchalios bchalios self-assigned this Nov 14, 2023
@bchalios bchalios added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Nov 14, 2023
@bchalios
Copy link
Contributor Author

I deliberately split up the commits that switch types from Versionize to serde so that I facilitate the review. but I am happy to merge these in a single commit if we decide its cleaner that way.

@bchalios bchalios force-pushed the drop_versionize_support branch 3 times, most recently from 771191d to e0a93b7 Compare November 15, 2023 11:44
Cargo.lock Outdated Show resolved Hide resolved
src/snapshot/src/lib.rs Show resolved Hide resolved
src/vmm/src/arch/aarch64/gic/regs.rs Outdated Show resolved Hide resolved
src/vmm/src/arch/aarch64/regs.rs Outdated Show resolved Hide resolved
src/vmm/src/arch/aarch64/regs.rs Outdated Show resolved Hide resolved
tests/integration_tests/functional/test_snapshot_basic.py Outdated Show resolved Hide resolved
tests/integration_tests/performance/test_snapshot_perf.py Outdated Show resolved Hide resolved
docs/snapshotting/snapshot-support.md Outdated Show resolved Hide resolved
docs/snapshotting/versioning.md Outdated Show resolved Hide resolved
src/snapshot/src/lib.rs Outdated Show resolved Hide resolved
src/snapshot/src/lib.rs Show resolved Hide resolved
src/snapshot/src/lib.rs Show resolved Hide resolved
src/vmm/src/arch/aarch64/regs.rs Outdated Show resolved Hide resolved
@bchalios bchalios force-pushed the drop_versionize_support branch 12 times, most recently from 8b28725 to b727249 Compare November 17, 2023 12:52
Derive Serialize and Deserialize and remove Versionize support. Fix
these two structs together because both depend on kvm-bindings
implementing (De)serialize for its types, so updating to the
kvm-bindings to the version that introduces serde breaks both of these
types.

While implementing serde for VcpuState also remove the `msrs` field.
According to Versionize this was end-of-life and we are anyway breaking
compatibility with previous snapshot versions.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
Derive Serialize and Deserialize for DeviceStates and remove Versionnize
support. Do this for all device types at the same time, since they all
depend on VirtIO related state.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
Remove versionize and versionize_derive dependencies.

Also, re-enable the rust integration tests. Now that we have all of the
state serialized with serde these should work again.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
This test relies on the fact that the current Firecracker binary can
parse snapshots that were created with a previous Firecracker version.
1.7.0 changes the snapshot format header and its parser only understands
the new format. As a result, it can't parse previous snapshots. We fix
this by skipping the tests for Firecracker versions previous to 1.7.0.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
We were skipping the serialization of the "boot_args" field of the
"boot-source" objectm, if kernel boot arguments were not supported. Now,
we return None. This was done so that we have consistent snapshot
formats, now that we use serde to serialize microVM state in a snapshot
file.

Amend this test to expect '"boot_args": None' in the "boot-source"
object.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
Snapshot versions are now independent from Firecracker binary versions.
Use Firecracker --snapshot-version flag to retrieve the supported
snapshot data format version for checking if the created snapshot is
supported from the current release.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
With the new snapshot format we break compatibility with all previous
snapshot format versions. This commits removes all the tests that were
checking functional correctness and performance of loading older
snapshots in the current Firecracker binary.

In the future, it might be that two Firecracker binaries support the
same snapshot versions. When that happens we should thing of a proper
way to test that this works, but the current tests are not fit for
purpose.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
Adapt documentation around snapshot versions format and compatibility to
remove mentions of Versionize and the effects its usage had to snapshot
compatibility. Also, add a CHANGELOG entry regarding the new strategy
for snapshot versioning.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
@bchalios
Copy link
Contributor Author

Changes v4 -> v5:

  • Dropped check for versions existing in src/vmm/src/version_map.rs; the file doesn't exist any more.
  • Added correct year (2020) in copyright notice of src/vmm/src/snapshot/src/crc.rs file. This file was taken from the versionize crate implementation and 2020 was the first year of publication.

@bchalios bchalios merged commit 5452348 into firecracker-microvm:main Jan 15, 2024
5 of 7 checks passed
@bchalios bchalios deleted the drop_versionize_support branch January 15, 2024 14:36
roypat added a commit to roypat/firecracker that referenced this pull request Jan 22, 2024
They were needed for Versionize reasons, but with firecracker-microvm#4230 merged, we can
eliminate them, simplifying the code.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
roypat added a commit to roypat/firecracker that referenced this pull request Jan 22, 2024
They were needed for Versionize reasons, but with firecracker-microvm#4230 merged, we can
eliminate them, simplifying the code.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
roypat added a commit to roypat/firecracker that referenced this pull request Jan 23, 2024
They were needed for Versionize reasons, but with firecracker-microvm#4230 merged, we can
eliminate them, simplifying the code.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
roypat added a commit to roypat/firecracker that referenced this pull request Mar 1, 2024
When switching from Versionize to bincode in firecracker-microvm#4230, we accidentally
dropped a check limiting how much memory the deserialization routine can
allocate [[1]]. This commit reimplements this check for the new
bincode-based deserialization routine, with a limit matching that of the
old Versionize check.

[1]: https://github.com/firecracker-microvm/versionize/blob/main/src/primitives.rs#L14C33-L14C43

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
roypat added a commit to roypat/firecracker that referenced this pull request Mar 1, 2024
When switching from Versionize to bincode in firecracker-microvm#4230, we accidentally
dropped a check limiting how much memory the deserialization routine can
allocate [[1]]. This commit reimplements this check for the new
bincode-based deserialization routine, with a limit matching that of the
old Versionize check.

[1]: https://github.com/firecracker-microvm/versionize/blob/main/src/primitives.rs#L14C33-L14C43

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
roypat added a commit to roypat/firecracker that referenced this pull request Mar 1, 2024
When switching from Versionize to bincode in firecracker-microvm#4230, we accidentally
dropped a check limiting how much memory the deserialization routine can
allocate [[1]]. This commit reimplements this check for the new
bincode-based deserialization routine, with a limit matching that of the
old Versionize check.

[1]: https://github.com/firecracker-microvm/versionize/blob/main/src/primitives.rs#L14C33-L14C43

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
roypat added a commit that referenced this pull request Mar 1, 2024
When switching from Versionize to bincode in #4230, we accidentally
dropped a check limiting how much memory the deserialization routine can
allocate [[1]]. This commit reimplements this check for the new
bincode-based deserialization routine, with a limit matching that of the
old Versionize check.

[1]: https://github.com/firecracker-microvm/versionize/blob/main/src/primitives.rs#L14C33-L14C43

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
roypat added a commit to roypat/firecracker that referenced this pull request Mar 1, 2024
When switching from Versionize to bincode in firecracker-microvm#4230, we accidentally
dropped a check limiting how much memory the deserialization routine can
allocate [[1]]. This commit reimplements this check for the new
bincode-based deserialization routine, with a limit matching that of the
old Versionize check.

[1]: https://github.com/firecracker-microvm/versionize/blob/main/src/primitives.rs#L14C33-L14C43

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
roypat added a commit that referenced this pull request Mar 1, 2024
When switching from Versionize to bincode in #4230, we accidentally
dropped a check limiting how much memory the deserialization routine can
allocate [[1]]. This commit reimplements this check for the new
bincode-based deserialization routine, with a limit matching that of the
old Versionize check.

[1]: https://github.com/firecracker-microvm/versionize/blob/main/src/primitives.rs#L14C33-L14C43

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
@zulinx86 zulinx86 mentioned this pull request Mar 25, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting review Indicates that a pull request is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants