Skip to content

virtio-pmem: fixes and improvements - #5789

Merged
ShadowCurse merged 7 commits into
firecracker-microvm:mainfrom
ShadowCurse:pmem_fixes
Apr 23, 2026
Merged

virtio-pmem: fixes and improvements#5789
ShadowCurse merged 7 commits into
firecracker-microvm:mainfrom
ShadowCurse:pmem_fixes

Conversation

@ShadowCurse

@ShadowCurse ShadowCurse commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

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

codecov Bot commented Mar 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.33577% with 79 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.88%. Comparing base (a6b64fc) to head (f525b6c).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/vmm/src/devices/virtio/pmem/device.rs 45.45% 36 Missing ⚠️
src/vmm/src/rpc_interface.rs 0.00% 18 Missing ⚠️
src/vmm/src/lib.rs 0.00% 12 Missing ⚠️
src/vmm/src/devices/virtio/pmem/event_handler.rs 0.00% 8 Missing ⚠️
src/firecracker/src/api_server/request/pmem.rs 78.26% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5789      +/-   ##
==========================================
- Coverage   83.06%   82.88%   -0.19%     
==========================================
  Files         276      276              
  Lines       29583    29708     +125     
==========================================
+ Hits        24573    24623      +50     
- Misses       5010     5085      +75     
Flag Coverage Δ
5.10-m5n.metal 83.18% <42.33%> (-0.20%) ⬇️
5.10-m6a.metal 82.51% <42.33%> (-0.21%) ⬇️
5.10-m6g.metal 79.79% <42.33%> (-0.20%) ⬇️
5.10-m6i.metal 83.18% <42.33%> (-0.21%) ⬇️
5.10-m7a.metal-48xl 82.50% <42.33%> (-0.21%) ⬇️
5.10-m7g.metal 79.79% <42.33%> (-0.20%) ⬇️
5.10-m7i.metal-24xl 83.15% <42.33%> (-0.21%) ⬇️
5.10-m7i.metal-48xl 83.15% <42.33%> (-0.21%) ⬇️
5.10-m8g.metal-24xl 79.79% <42.33%> (-0.20%) ⬇️
5.10-m8g.metal-48xl 79.79% <42.33%> (-0.20%) ⬇️
5.10-m8i.metal-48xl 83.16% <42.33%> (-0.20%) ⬇️
5.10-m8i.metal-96xl 83.16% <42.33%> (-0.20%) ⬇️
6.1-m5n.metal 83.21% <42.33%> (-0.21%) ⬇️
6.1-m6a.metal 82.53% <42.33%> (-0.22%) ⬇️
6.1-m6g.metal 79.79% <42.33%> (-0.20%) ⬇️
6.1-m6i.metal 83.21% <42.33%> (-0.20%) ⬇️
6.1-m7a.metal-48xl 82.53% <42.33%> (-0.21%) ⬇️
6.1-m7g.metal 79.79% <42.33%> (-0.20%) ⬇️
6.1-m7i.metal-24xl 83.22% <42.33%> (-0.21%) ⬇️
6.1-m7i.metal-48xl 83.22% <42.33%> (-0.21%) ⬇️
6.1-m8g.metal-24xl 79.79% <42.33%> (-0.20%) ⬇️
6.1-m8g.metal-48xl 79.79% <42.33%> (-0.20%) ⬇️
6.1-m8i.metal-48xl 83.22% <42.33%> (-0.20%) ⬇️
6.1-m8i.metal-96xl 83.22% <42.33%> (-0.20%) ⬇️

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
Comment thread src/vmm/src/devices/virtio/pmem/device.rs
Comment thread src/vmm/src/devices/virtio/pmem/device.rs
Comment thread src/vmm/src/devices/virtio/pmem/device.rs
Comment thread src/vmm/src/devices/virtio/pmem/device.rs
Comment thread src/vmm/src/devices/virtio/pmem/device.rs
@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 5 times, most recently from e4ccee4 to 24441ed Compare March 31, 2026 11:08
Comment thread docs/pmem.md Outdated
Comment thread src/vmm/src/devices/virtio/pmem/device.rs
@ShadowCurse
ShadowCurse force-pushed the pmem_fixes branch 7 times, most recently from a0aae35 to a9a3d01 Compare April 7, 2026 13:19
Comment thread src/vmm/src/devices/virtio/pmem/device.rs Outdated
@ShadowCurse
ShadowCurse force-pushed the pmem_fixes branch 2 times, most recently from 1033b96 to 777ceb0 Compare April 16, 2026 11:32
Comment thread src/firecracker/src/api_server/request/pmem.rs Outdated
Comment thread src/vmm/src/rpc_interface.rs
@ShadowCurse
ShadowCurse force-pushed the pmem_fixes branch 3 times, most recently from b9588ce to ba905dd Compare April 16, 2026 15:14
JamesC1305
JamesC1305 previously approved these changes Apr 17, 2026

@JamesC1305 JamesC1305 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall LGTM. The only thing I wonder is if it could do with integration tests for the rate limiting functionality, similar to how the block device has test_patch_drive_limiter.

Comment thread src/vmm/src/devices/virtio/pmem/device.rs
@ShadowCurse

Copy link
Copy Markdown
Contributor Author

Added rate-limiter integration tests as well

Manciukic
Manciukic previously approved these changes Apr 22, 2026

@Manciukic Manciukic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

a few more nits for inconsistencies in unit test, error messages, and docs

Comment thread src/firecracker/src/api_server/request/pmem.rs Outdated
Comment thread src/vmm/src/vmm_config/pmem.rs Outdated
Comment thread docs/device-api.md
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>
Update device-api.md with rate-limiter field and new patch request
available for virtio-pmem.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
@ShadowCurse
ShadowCurse enabled auto-merge (rebase) April 23, 2026 11:15
@ShadowCurse
ShadowCurse merged commit 5d697c0 into firecracker-microvm:main Apr 23, 2026
6 of 7 checks passed
@ShadowCurse
ShadowCurse deleted the pmem_fixes branch April 23, 2026 11:15
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.

4 participants