Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builder refactor #5112

Merged
merged 10 commits into from
Mar 26, 2025
Merged

Conversation

ShadowCurse
Copy link
Contributor

@ShadowCurse ShadowCurse commented Mar 25, 2025

Changes

This is another attempt at fixing #4547.

  • Move architecture specific parts from builder.rs into arch modules.
  • Do slight refactoring on top in the arch modules.

Reason

Less arch specific mess in the codebase.

Fixes: #4411
Previous attempt was: #4910

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.

@ShadowCurse ShadowCurse force-pushed the builder_refactor branch 4 times, most recently from 3ff3112 to 10d1896 Compare March 25, 2025 16:23
Copy link

codecov bot commented Mar 25, 2025

Codecov Report

Attention: Patch coverage is 93.66516% with 14 lines in your changes missing coverage. Please review.

Project coverage is 83.06%. Comparing base (a6c9559) to head (2c42f84).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
src/vmm/src/arch/x86_64/mod.rs 94.11% 5 Missing ⚠️
src/vmm/src/initrd.rs 84.61% 4 Missing ⚠️
src/vmm/src/arch/aarch64/mod.rs 98.48% 1 Missing ⚠️
src/vmm/src/builder.rs 80.00% 1 Missing ⚠️
src/vmm/src/cpu_config/aarch64/mod.rs 91.66% 1 Missing ⚠️
src/vmm/src/lib.rs 50.00% 1 Missing ⚠️
src/vmm/src/persist.rs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5112      +/-   ##
==========================================
- Coverage   83.19%   83.06%   -0.14%     
==========================================
  Files         249      250       +1     
  Lines       26885    26888       +3     
==========================================
- Hits        22368    22334      -34     
- Misses       4517     4554      +37     
Flag Coverage Δ
5.10-c5n.metal 83.52% <91.54%> (-0.09%) ⬇️
5.10-m5n.metal 83.52% <91.54%> (-0.09%) ⬇️
5.10-m6a.metal 82.71% <91.54%> (-0.09%) ⬇️
5.10-m6g.metal 79.43% <89.60%> (-0.18%) ⬇️
5.10-m6i.metal 83.52% <91.54%> (-0.08%) ⬇️
5.10-m7a.metal-48xl 82.71% <91.54%> (?)
5.10-m7g.metal 79.43% <89.60%> (-0.18%) ⬇️
6.1-c5n.metal 83.57% <91.54%> (-0.08%) ⬇️
6.1-m5n.metal 83.57% <91.54%> (-0.08%) ⬇️
6.1-m6a.metal 82.76% <91.54%> (-0.09%) ⬇️
6.1-m6g.metal 79.42% <89.60%> (-0.19%) ⬇️
6.1-m6i.metal 83.56% <91.54%> (-0.08%) ⬇️
6.1-m7a.metal-48xl 82.76% <91.54%> (?)
6.1-m7g.metal 79.43% <89.60%> (-0.18%) ⬇️

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 force-pushed the builder_refactor branch 5 times, most recently from 2bad363 to 8eb3cf9 Compare March 25, 2025 17:32
Initrd code was spread across multiple modules, move common part of it
into one and make freestanding `load_initrd_*` functions into methods
for the `InitrdConfig` struct.

Also change `initrd_load_addr` method to return an option instead of an
error to remove extra error nesting.

Signed-off-by: Egor Lazarchuk <[email protected]>
Move `load_kernel` arch specific functions into arch module per
architecture. Make the function to accept the kernel `File`
instead of the `BootConfig`.

Signed-off-by: Egor Lazarchuk <[email protected]>
@ShadowCurse ShadowCurse self-assigned this Mar 26, 2025
@ShadowCurse ShadowCurse added Status: Awaiting review Indicates that a pull request is ready to be reviewed Type: Enhancement Indicates new feature requests labels Mar 26, 2025
@ShadowCurse ShadowCurse marked this pull request as ready for review March 26, 2025 12:00
Split `configure_system_for_boot` into 2 arch specific functions
and move it into arch module.

Signed-off-by: Egor Lazarchuk <[email protected]>
Some places were accessing `guest_memory` directly while others
were using getter. Remove getter to make accesses consistent.

Signed-off-by: Egor Lazarchuk <[email protected]>
Move manual creation of `CpuConfiguration` from
`configure_system_for_boot` into `CpuConfiguration::new`.

Signed-off-by: Egor Lazarchuk <[email protected]>
On aarch64 `apply_template` cannot fail, so no reason for `Result`
return type.

Signed-off-by: Egor Lazarchuk <[email protected]>
There is no reason to have these functions separately, so merge them.

Signed-off-by: Egor Lazarchuk <[email protected]>
This is a dead code, so remove it.

Signed-off-by: Egor Lazarchuk <[email protected]>
Add `align_up` and `align_down` functions to stop reimplementing
them in place all over the codebase.

Signed-off-by: Egor Lazarchuk <[email protected]>
Remove `map_err` calls by adding `#[from]` to error variants.

Signed-off-by: Egor Lazarchuk <[email protected]>
@roypat
Copy link
Contributor

roypat commented Mar 26, 2025

thanks for indulging me with all those #[from]s :D

@roypat roypat merged commit 019dc6b into firecracker-microvm:main Mar 26, 2025
6 of 7 checks passed
@ShadowCurse ShadowCurse deleted the builder_refactor branch March 26, 2025 18:17
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[vmm] refactor vmm builder code to separate the architecture dependent code in their own modules
3 participants