Skip to content

virtio-pmem: fixes and improvements#5789

Open
ShadowCurse wants to merge 6 commits intofirecracker-microvm:mainfrom
ShadowCurse:pmem_fixes
Open

virtio-pmem: fixes and improvements#5789
ShadowCurse wants to merge 6 commits intofirecracker-microvm:mainfrom
ShadowCurse:pmem_fixes

Conversation

@ShadowCurse
Copy link
Copy Markdown
Contributor

@ShadowCurse ShadowCurse commented Mar 24, 2026

Changes

  • Validate descriptors len field to be 4 since the code expects this
  • Cache msync result for better efficiency in case multiple flush requests are presented at once
  • Add rate-limiter support

Reason

Edge case handling and addition of missing features

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 31.25000% with 88 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.80%. Comparing base (f314fdd) to head (24441ed).

Files with missing lines Patch % Lines
src/vmm/src/devices/virtio/pmem/device.rs 48.38% 32 Missing ⚠️
src/firecracker/src/api_server/request/pmem.rs 0.00% 23 Missing ⚠️
src/vmm/src/rpc_interface.rs 0.00% 13 Missing ⚠️
src/vmm/src/lib.rs 0.00% 12 Missing ⚠️
src/vmm/src/devices/virtio/pmem/event_handler.rs 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5789      +/-   ##
==========================================
- Coverage   83.02%   82.80%   -0.23%     
==========================================
  Files         276      276              
  Lines       29430    29547     +117     
==========================================
+ Hits        24435    24467      +32     
- Misses       4995     5080      +85     
Flag Coverage Δ
5.10-m5n.metal 83.06% <31.25%> (-0.24%) ⬇️
5.10-m6a.metal 82.38% <31.25%> (-0.25%) ⬇️
5.10-m6g.metal 79.80% <31.25%> (-0.24%) ⬇️
5.10-m6i.metal 83.06% <31.25%> (-0.25%) ⬇️
5.10-m7a.metal-48xl 82.36% <31.25%> (-0.26%) ⬇️
5.10-m7g.metal 79.80% <31.25%> (-0.24%) ⬇️
5.10-m7i.metal-24xl 83.03% <31.25%> (-0.25%) ⬇️
5.10-m7i.metal-48xl 83.02% <31.25%> (-0.25%) ⬇️
5.10-m8g.metal-24xl 79.79% <31.25%> (-0.25%) ⬇️
5.10-m8g.metal-48xl 79.80% <31.25%> (-0.24%) ⬇️
5.10-m8i.metal-48xl 83.03% <31.25%> (-0.24%) ⬇️
5.10-m8i.metal-96xl 83.03% <31.25%> (-0.25%) ⬇️
6.1-m5n.metal 83.08% <31.25%> (-0.24%) ⬇️
6.1-m6a.metal 82.41% <31.25%> (-0.25%) ⬇️
6.1-m6g.metal 79.79% <31.25%> (-0.25%) ⬇️
6.1-m6i.metal 83.08% <31.25%> (-0.25%) ⬇️
6.1-m7a.metal-48xl 82.40% <31.25%> (-0.25%) ⬇️
6.1-m7g.metal 79.79% <31.25%> (-0.25%) ⬇️
6.1-m7i.metal-24xl 83.09% <31.25%> (-0.25%) ⬇️
6.1-m7i.metal-48xl 83.09% <31.25%> (-0.25%) ⬇️
6.1-m8g.metal-24xl 79.79% <31.25%> (-0.24%) ⬇️
6.1-m8g.metal-48xl 79.79% <31.25%> (-0.24%) ⬇️
6.1-m8i.metal-48xl 83.10% <31.25%> (-0.25%) ⬇️
6.1-m8i.metal-96xl 83.10% <31.25%> (-0.25%) ⬇️

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.

@ShadowCurse ShadowCurse marked this pull request as ready for review March 24, 2026 17:15
@ShadowCurse ShadowCurse added Status: Awaiting review Indicates that a pull request is ready to be reviewed Type: Enhancement Indicates new feature requests Type: Fix Indicates a fix to existing code labels Mar 24, 2026
@ShadowCurse ShadowCurse force-pushed the pmem_fixes branch 2 times, most recently from 46cccd5 to 813efa7 Compare March 25, 2026 10:25
@ShadowCurse ShadowCurse force-pushed the pmem_fixes branch 2 times, most recently from d140771 to e48ab2a Compare March 26, 2026 09:41
@ShadowCurse ShadowCurse changed the title Pmem fixes virtio-pmem: fixes and improvements Mar 27, 2026
@ShadowCurse ShadowCurse force-pushed the pmem_fixes branch 4 times, most recently from 5061c8c to e4ccee4 Compare March 30, 2026 13:38
Head and status descriptors must be 4 bytes long by the spec.
Add validation for this.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
There is only one type of request virto-pmem accepts, but guest still
can issue many of them and Firecracker will need to process it all.
Instead of doing one `msync` per request, it is less resource intensive
to do it once on the first valid descriptor and then duplicate the
result to other descriptors. This is safe since the guest will only
know the result of the execution after Firecracker will signal it,
which will only happen after all descriptors are processed.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Add rate-limiter support to the virtio-pmem device to allow users to
configure limits of the I/O bandwidth generated by the `msync` call in
the device which could be triggered by the guest FLUSH requests.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Add a section in the pmem.md file describing a way of
limiting I/O usage of `msync` calls from a virtio-pmem device.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Mention new rate-limiter API for the virtio-pmem device in the
CHANGELOG.md

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Fix incorrect NOTE section formatting in memory usage
section

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
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 Type: Enhancement Indicates new feature requests Type: Fix Indicates a fix to existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants