Skip to content

Harden differential snapshotting tests #5717

Open
Manciukic wants to merge 6 commits intofirecracker-microvm:mainfrom
Manciukic:dirty-dump-fix-proptest
Open

Harden differential snapshotting tests #5717
Manciukic wants to merge 6 commits intofirecracker-microvm:mainfrom
Manciukic:dirty-dump-fix-proptest

Conversation

@Manciukic
Copy link
Contributor

@Manciukic Manciukic commented Feb 25, 2026

Changes

  • extend test_memory_hotplug.py::test_snapshot_restore_incremental to run on all snapshot types
  • extend test_memory_hotplug.py::test_snapshot_restore_incremental to dirty a random page
  • add a proptest for dump_dirty and store_dirty

Reason

Harden tests around incremental snapshots.

test_snapshot_restore_incremental could have also caught the issue with differential snapshots, but it was only run on FULL snapshots.

Property testing automates the testing on random valid inputs to harden the function, catching edge cases. It caught an edge case that our initial fix didn't consider.

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.

The test was only checking FULL snapshots. Run it also on DIFF and
MINCORE.

Signed-off-by: Riccardo Mancini <[email protected]>
As a further check, ensure that when writing an arbitrary page in a
previous block the incremental snapshots work fine.

Signed-off-by: Riccardo Mancini <[email protected]>
s/hptplugged/hotplugged

Signed-off-by: Riccardo Mancini <[email protected]>
This proptest will generate 4096 randomized inputs to harden the testing
on dump_dirty.

Signed-off-by: Riccardo Mancini <[email protected]>
Apply the proptest also to store_dirty_bitmap.

Signed-off-by: Riccardo Mancini <[email protected]>
@Manciukic Manciukic force-pushed the dirty-dump-fix-proptest branch from 1cde1df to c7e49a4 Compare February 25, 2026 12:24
@Manciukic Manciukic marked this pull request as ready for review February 26, 2026 12:31
@Manciukic Manciukic added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Feb 26, 2026
@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.17%. Comparing base (143a4ce) to head (af894aa).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5717   +/-   ##
=======================================
  Coverage   83.17%   83.17%           
=======================================
  Files         277      277           
  Lines       29428    29428           
=======================================
  Hits        24478    24478           
  Misses       4950     4950           
Flag Coverage Δ
5.10-m5n.metal 83.47% <ø> (ø)
5.10-m6a.metal 82.81% <ø> (-0.01%) ⬇️
5.10-m6g.metal 80.18% <ø> (ø)
5.10-m6i.metal 83.47% <ø> (ø)
5.10-m7a.metal-48xl 82.80% <ø> (ø)
5.10-m7g.metal 80.18% <ø> (ø)
5.10-m7i.metal-24xl 83.44% <ø> (ø)
5.10-m7i.metal-48xl 83.45% <ø> (+<0.01%) ⬆️
5.10-m8g.metal-24xl 80.18% <ø> (ø)
5.10-m8g.metal-48xl 80.18% <ø> (-0.01%) ⬇️
5.10-m8i.metal-48xl 83.45% <ø> (-0.01%) ⬇️
5.10-m8i.metal-96xl 83.44% <ø> (-0.01%) ⬇️
6.1-m5n.metal 83.50% <ø> (ø)
6.1-m6a.metal 82.84% <ø> (+<0.01%) ⬆️
6.1-m6g.metal 80.18% <ø> (ø)
6.1-m6i.metal 83.50% <ø> (ø)
6.1-m7a.metal-48xl 82.83% <ø> (ø)
6.1-m7g.metal 80.18% <ø> (-0.01%) ⬇️
6.1-m7i.metal-24xl 83.51% <ø> (-0.01%) ⬇️
6.1-m7i.metal-48xl 83.51% <ø> (ø)
6.1-m8g.metal-24xl 80.18% <ø> (ø)
6.1-m8g.metal-48xl 80.18% <ø> (ø)
6.1-m8i.metal-48xl 83.52% <ø> (+<0.01%) ⬆️
6.1-m8i.metal-96xl 83.52% <ø> (+<0.01%) ⬆️

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.

/// Generate a KVM dirty bitmap for a slot of `num_pages` pages.
fn kvm_bitmap_for(num_pages: usize) -> impl Strategy<Value = Vec<u64>> {
let num_u64s = num_pages.div_ceil(64);
let trailing_bits = num_pages % 64;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing_bits confused me a bit (no pun intended) because it made me think you refer to the MSB, but instead you refer to the LSB. Shall we rename it to something like valid_bits?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point, these are the number of valid bits at the beginning, not the trailing bits at the end. I will change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or something like last_chunk_valid_bits might be a bit more descriptive than just valid_bits

/// A region descriptor produced by the strategy.
#[derive(Debug, Clone)]
struct RegionSpec {
gap_pages: usize,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: A comment here explaining that this is meant to be the gap from the previous region could be useful

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.

2 participants