Skip to content

Conversation

roypat
Copy link
Contributor

@roypat roypat commented Mar 24, 2025

A collection of cleanups I accumulated on a local branch while prototyping for #4522. Mainly

  • Clean up error types in builder.rs slightly to avoid a lot of unsightly .map_err calls
  • Clean up a lot of unnecessary generics in fdt.rs
  • Add a constant to make our left shifts by 20 less mysterious.

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 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 Mar 24, 2025

Codecov Report

Attention: Patch coverage is 96.22642% with 2 lines in your changes missing coverage. Please review.

Project coverage is 83.19%. Comparing base (6b5f4b1) to head (52104ba).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/vmm/src/builder.rs 94.73% 1 Missing ⚠️
src/vmm/src/vstate/memory.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5106      +/-   ##
==========================================
+ Coverage   83.13%   83.19%   +0.06%     
==========================================
  Files         249      249              
  Lines       26937    26885      -52     
==========================================
- Hits        22393    22368      -25     
+ Misses       4544     4517      -27     
Flag Coverage Δ
5.10-c5n.metal 83.60% <90.90%> (+0.09%) ⬆️
5.10-m5n.metal 83.60% <90.90%> (+0.09%) ⬆️
5.10-m6a.metal 82.80% <90.90%> (+0.10%) ⬆️
5.10-m6g.metal 79.60% <90.56%> (+0.03%) ⬆️
5.10-m6i.metal 83.60% <90.90%> (+0.09%) ⬆️
5.10-m7a.metal-48xl 82.80% <90.90%> (?)
5.10-m7g.metal 79.60% <90.56%> (+0.03%) ⬆️
6.1-c5n.metal 83.65% <90.90%> (+0.09%) ⬆️
6.1-m5n.metal 83.65% <90.90%> (+0.09%) ⬆️
6.1-m6a.metal 82.84% <90.90%> (+0.09%) ⬆️
6.1-m6g.metal 79.60% <90.56%> (+0.04%) ⬆️
6.1-m6i.metal 83.64% <90.90%> (+0.09%) ⬆️
6.1-m7a.metal-48xl 82.84% <90.90%> (?)
6.1-m7g.metal 79.60% <90.56%> (+0.03%) ⬆️

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 Mar 24, 2025
@roypat roypat requested review from ShadowCurse and bchalios and removed request for bchalios March 24, 2025 11:55
@roypat roypat force-pushed the small-error-cleanup branch 2 times, most recently from f8bdd1a to 1400476 Compare March 24, 2025 14:03
@roypat roypat force-pushed the small-error-cleanup branch from 8e8a5ca to a36bd7e Compare March 24, 2025 16:59
ShadowCurse
ShadowCurse previously approved these changes Mar 24, 2025
kalyazin
kalyazin previously approved these changes Mar 25, 2025
roypat added 9 commits March 25, 2025 14:28
In CI we always run unittests without `--features gdb`, but actually
with the gdb feature they dont compile. Fix this with some cfgs.

Signed-off-by: Patrick Roy <[email protected]>
There is absolutely no need for generics anywhere in this module, as the
trait we were being generic over had only a single implementor.

Signed-off-by: Patrick Roy <[email protected]>
This test is all about testing what happens when a vsock driver places
virtio buffers close to / around the MMIO gap on x86_64 systems. Since
this test thus doesn't really serve a purpose on aarch64, we can just
cfg(target_arch = "x86_64") it, and reuse the constants from
arch::x86_64 instead of redefining them again.

fwiw, I have no idea what "bof" means. I'm also confused by this test
passing on ARM in the first place, given that some of the comments
indicate to me that it should fail if the buffers overlap the mmio gap
(which doesn't exist on arm, so nothing should fail?).

Signed-off-by: Patrick Roy <[email protected]>
Left-shifting by 20 to convert MiB to bytes is ubiquitous in our
codebase, but probably somewhat arcane to people not familiar with low
level stuff. Let's define a helper for the conversion.

Signed-off-by: Patrick Roy <[email protected]>
The return value here was ignored anyway, so no need to map the unit ()
to VmmData::Empty.

Signed-off-by: Patrick Roy <[email protected]>
This means that `create_vmm_and_vcpus` now does not use any variants of
`StartMicrovmError` directly, and as a next step can be converted to
return `VmmError` directly, which will eliminate all the `map_err`
inside.

Signed-off-by: Patrick Roy <[email protected]>
Eliminate a lot of .map_err(Internal) to make the code more readable.

Signed-off-by: Patrick Roy <[email protected]>
When a variant wraps another error type, and this error type does not
appear in any other variant, use thiserrors #[from] directive to
implement a `From` impl. This allows eliminating almost all remaining
`map_err`s from `create_vmm_and_vcpus`, as the `?` operator will
automatically call .from() once (although it cannot do it for multiple
layers of wrapping, which is why it was important to change the function
to return VmmError).

Signed-off-by: Patrick Roy <[email protected]>
This allows us to eliminate some more .map_err(Internal).

Signed-off-by: Patrick Roy <[email protected]>
@roypat roypat dismissed stale reviews from kalyazin and ShadowCurse via 52104ba March 25, 2025 14:28
@roypat roypat force-pushed the small-error-cleanup branch from 90e2e9b to 52104ba Compare March 25, 2025 14:28
@roypat roypat enabled auto-merge (rebase) March 25, 2025 14:36
@roypat roypat merged commit 99b7e2c into firecracker-microvm:main Mar 25, 2025
6 of 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.

4 participants