Skip to content

refactor: cleanup vmm::snapshot module #5355

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

roypat
Copy link
Contributor

@roypat roypat commented Aug 11, 2025

Implement the suggestions from #4523 to give a cleaner API for the
snapshot module. Conceptually, the change is that we now store the thing
we are snapshotting inside of the Snapshot struct.
Implementation-wise, this allows us to deserialize the snapshot data in
a single pass (instead of having to read it twice, once for
deserialization and once for CRC validation), which means we do not have
to first query the snapshot file for the size of the snapshot.

Closes #4691, #4523, #5195

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

  • I have read and understand CONTRIBUTING.md.
  • I have run tools/devtool checkbuild --all to verify that the PR passes
    build checks on all supported architectures.
  • I have run tools/devtool checkstyle to verify that the PR passes the
    automated style checks.
  • I have described what is done in these changes, why they are needed, and
    how they are solving the problem in a clear and encompassing way.
  • I have updated any relevant documentation (both in code and in the docs)
    in the PR.
  • I have mentioned all user-facing changes in CHANGELOG.md.
  • If a specific issue led to this PR, this PR closes the issue.
  • When making API changes, I have followed the
    Runbook for Firecracker API changes.
  • I have tested all new and changed functionalities in unit tests and/or
    integration tests.
  • I have linked an issue to every new TODO.

  • This functionality cannot be added in rust-vmm.

Copy link

codecov bot commented Aug 11, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.32%. Comparing base (4e29a70) to head (1be6b70).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/snapshot-editor/src/info.rs 0.00% 9 Missing ⚠️
src/snapshot-editor/src/utils.rs 0.00% 5 Missing ⚠️
src/snapshot-editor/src/edit_vmstate.rs 25.00% 3 Missing ⚠️
src/vmm/src/snapshot/mod.rs 92.68% 3 Missing ⚠️
src/firecracker/src/main.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5355      +/-   ##
==========================================
+ Coverage   82.30%   82.32%   +0.01%     
==========================================
  Files         265      265              
  Lines       30640    30580      -60     
==========================================
- Hits        25219    25174      -45     
+ Misses       5421     5406      -15     
Flag Coverage Δ
5.10-c5n.metal 82.29% <69.35%> (-0.04%) ⬇️
5.10-m5n.metal 82.29% <69.35%> (-0.04%) ⬇️
5.10-m6a.metal 81.56% <69.35%> (-0.04%) ⬇️
5.10-m6g.metal 78.87% <66.66%> (-0.05%) ⬇️
5.10-m6i.metal 82.28% <69.35%> (-0.03%) ⬇️
5.10-m7a.metal-48xl 81.55% <69.35%> (?)
5.10-m7g.metal 78.87% <66.66%> (-0.05%) ⬇️
5.10-m7i.metal-24xl 82.25% <69.35%> (?)
5.10-m7i.metal-48xl 82.25% <69.35%> (?)
5.10-m8g.metal-24xl 78.87% <66.66%> (?)
5.10-m8g.metal-48xl 78.87% <66.66%> (?)
6.1-c5n.metal 82.33% <69.35%> (-0.04%) ⬇️
6.1-m5n.metal 82.33% <69.35%> (-0.04%) ⬇️
6.1-m6a.metal 81.60% <69.35%> (-0.05%) ⬇️
6.1-m6g.metal 78.86% <66.66%> (-0.06%) ⬇️
6.1-m6i.metal 82.32% <69.35%> (-0.03%) ⬇️
6.1-m7a.metal-48xl 81.59% <69.35%> (?)
6.1-m7g.metal 78.87% <66.66%> (-0.05%) ⬇️
6.1-m7i.metal-24xl 82.33% <69.35%> (?)
6.1-m7i.metal-48xl 82.33% <69.35%> (?)
6.1-m8g.metal-24xl 78.87% <66.66%> (?)
6.1-m8g.metal-48xl 78.87% <66.66%> (?)

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@roypat roypat added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Aug 11, 2025
roypat added 2 commits August 12, 2025 17:27
There was a typo in the output of the remove register operation. Fix it.

Signed-off-by: Patrick Roy <[email protected]>
Have snapshot-editor always create a snapshot at the current version. We
cannot load snapshots that have a different snapshot version than is
supported by the running binary anyway (because strongly-typed
deserialization would fail), so we statically know that the `version`
parameter to `save_vmstate` is always `SNAPSHOT_VERSION`.

Signed-off-by: Patrick Roy <[email protected]>
Implement the suggestions from firecracker-microvm#4523 to give a cleaner API for the
snapshot module. Conceptually, the change is that we now store the thing
we are snapshotting inside of the `Snapshot` struct.
Implementation-wise, this allows us to deserialize the snapshot data in
a single pass (instead of having to read it twice, once for
deserialization and once for CRC validation), which means we do not have
to first query the snapshot file for the size of the snapshot.

Closes firecracker-microvm#4691, firecracker-microvm#4523, firecracker-microvm#5195

Signed-off-by: Patrick Roy <[email protected]>
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.

1 participant