Skip to content

fix(snapshot): handle errors in PCI cfg on snap restore#5841

Merged
JamesC1305 merged 3 commits into
firecracker-microvm:mainfrom
JamesC1305:fix_snapshot_pci_panic
Apr 23, 2026
Merged

fix(snapshot): handle errors in PCI cfg on snap restore#5841
JamesC1305 merged 3 commits into
firecracker-microvm:mainfrom
JamesC1305:fix_snapshot_pci_panic

Conversation

@JamesC1305

@JamesC1305 JamesC1305 commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Handle errors in PCI configuration code on snapshot restore

Changes

...

Reason

...

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.

There are a few places in the PCI transport snapshot restore code where
Vecs (serialised in snapshot) are converted to fixed-size arrays (used
at runtime). If a bad snapshot was supplied as input with wrong-sized
vecs, Firecracker would panic.

Add some error handling to prevent such panics.

Signed-off-by: James Curtis <jxcurtis@amazon.co.uk>
@codecov

codecov Bot commented Apr 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.88%. Comparing base (5d697c0) to head (7e506b1).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/vmm/src/devices/virtio/transport/pci/device.rs 50.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5841   +/-   ##
=======================================
  Coverage   82.88%   82.88%           
=======================================
  Files         276      276           
  Lines       29708    29725   +17     
=======================================
+ Hits        24623    24638   +15     
- Misses       5085     5087    +2     
Flag Coverage Δ
5.10-m5n.metal 83.19% <92.00%> (+<0.01%) ⬆️
5.10-m6a.metal 82.51% <92.00%> (+<0.01%) ⬆️
5.10-m6g.metal 79.79% <92.00%> (+<0.01%) ⬆️
5.10-m6i.metal 83.18% <92.00%> (-0.01%) ⬇️
5.10-m7a.metal-48xl 82.50% <92.00%> (+<0.01%) ⬆️
5.10-m7g.metal 79.80% <92.00%> (+<0.01%) ⬆️
5.10-m7i.metal-24xl 83.16% <92.00%> (-0.01%) ⬇️
5.10-m7i.metal-48xl 83.16% <92.00%> (-0.01%) ⬇️
5.10-m8g.metal-24xl 79.79% <92.00%> (+<0.01%) ⬆️
5.10-m8g.metal-48xl 79.79% <92.00%> (+<0.01%) ⬆️
5.10-m8i.metal-48xl 83.16% <92.00%> (-0.01%) ⬇️
5.10-m8i.metal-96xl 83.16% <92.00%> (+<0.01%) ⬆️
6.1-m5n.metal 83.21% <92.00%> (+<0.01%) ⬆️
6.1-m6a.metal 82.55% <92.00%> (+<0.01%) ⬆️
6.1-m6g.metal 79.79% <92.00%> (+<0.01%) ⬆️
6.1-m6i.metal 83.21% <92.00%> (-0.01%) ⬇️
6.1-m7a.metal-48xl 82.53% <92.00%> (+<0.01%) ⬆️
6.1-m7g.metal 79.79% <92.00%> (+<0.01%) ⬆️
6.1-m7i.metal-24xl 83.22% <92.00%> (-0.01%) ⬇️
6.1-m7i.metal-48xl 83.22% <92.00%> (+<0.01%) ⬆️
6.1-m8g.metal-24xl 79.79% <92.00%> (+0.01%) ⬆️
6.1-m8g.metal-48xl 79.79% <92.00%> (+0.01%) ⬆️
6.1-m8i.metal-48xl 83.23% <92.00%> (+<0.01%) ⬆️
6.1-m8i.metal-96xl 83.23% <92.00%> (+<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.

@JamesC1305 JamesC1305 added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Apr 16, 2026
Comment thread src/vmm/src/pci/configuration.rs
zulinx86
zulinx86 previously approved these changes Apr 16, 2026
@JamesC1305

Copy link
Copy Markdown
Contributor Author

Changed to using serde-big-array rather than converting between vec and array.

@JamesC1305 JamesC1305 changed the title fix(snapshot): add error handling in PCI transport restore code fix(snapshot): avoid vec-array conversions using serde-big-array Apr 17, 2026
ShadowCurse
ShadowCurse previously approved these changes Apr 17, 2026
Comment thread src/vmm/Cargo.toml Outdated
zulinx86
zulinx86 previously approved these changes Apr 17, 2026
@JamesC1305 JamesC1305 dismissed stale reviews from zulinx86 and ShadowCurse via 09efdc9 April 20, 2026 12:26
@JamesC1305 JamesC1305 force-pushed the fix_snapshot_pci_panic branch 4 times, most recently from 00013fd to c277037 Compare April 23, 2026 10:08
@JamesC1305 JamesC1305 changed the title fix(snapshot): avoid vec-array conversions using serde-big-array fix(snapshot): handle errors in PCI cfg on snap restore Apr 23, 2026
@JamesC1305 JamesC1305 enabled auto-merge (rebase) April 23, 2026 11:16
@JamesC1305 JamesC1305 merged commit 717f593 into firecracker-microvm:main Apr 23, 2026
7 checks passed
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.

3 participants