Skip to content

Misc fixes #5245

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Conversation

ShadowCurse
Copy link
Contributor

Changes

Minor refactors and assert additions.

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 Jun 3, 2025

Codecov Report

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

Project coverage is 82.89%. Comparing base (e36e774) to head (ed878a1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/vmm/src/persist.rs 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5245      +/-   ##
==========================================
+ Coverage   82.84%   82.89%   +0.04%     
==========================================
  Files         250      250              
  Lines       26967    26943      -24     
==========================================
- Hits        22342    22335       -7     
+ Misses       4625     4608      -17     
Flag Coverage Δ
5.10-c5n.metal 83.32% <100.00%> (-0.01%) ⬇️
5.10-m5n.metal 83.32% <100.00%> (-0.01%) ⬇️
5.10-m6a.metal 82.53% <100.00%> (-0.02%) ⬇️
5.10-m6g.metal 79.16% <94.28%> (-0.01%) ⬇️
5.10-m6i.metal 83.32% <100.00%> (-0.01%) ⬇️
5.10-m7a.metal-48xl 82.53% <100.00%> (?)
5.10-m7g.metal 79.16% <94.28%> (-0.01%) ⬇️
5.10-m7i.metal-24xl 83.28% <100.00%> (?)
5.10-m7i.metal-48xl 83.29% <100.00%> (?)
5.10-m8g.metal-24xl 79.15% <94.28%> (?)
5.10-m8g.metal-48xl 79.15% <94.28%> (?)
6.1-c5n.metal 83.37% <100.00%> (-0.01%) ⬇️
6.1-m5n.metal 83.37% <100.00%> (-0.01%) ⬇️
6.1-m6a.metal 82.58% <100.00%> (-0.02%) ⬇️
6.1-m6g.metal 79.16% <94.28%> (-0.01%) ⬇️
6.1-m6i.metal 83.36% <100.00%> (-0.01%) ⬇️
6.1-m7a.metal-48xl 82.57% <100.00%> (?)
6.1-m7g.metal 79.16% <94.28%> (-0.01%) ⬇️
6.1-m7i.metal-24xl 83.38% <100.00%> (?)
6.1-m7i.metal-48xl 83.37% <100.00%> (?)
6.1-m8g.metal-24xl 79.15% <94.28%> (?)
6.1-m8g.metal-48xl 79.15% <94.28%> (?)

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.

It is reasonable to assume that we will not have more than u32::MAX
memory slots since kernel only returns i32 from a query syscall.
Enforce this with `.expect` calls and change the type of `max_memslots`
to u32.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Replaces never used error result type wit optional.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
@ShadowCurse ShadowCurse force-pushed the misc_fixes branch 4 times, most recently from 1f984e4 to d309637 Compare June 10, 2025 10:26
usize cannot be negative.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Add command to run any cargo command from inside container without
needing to enter it.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
@ShadowCurse ShadowCurse force-pushed the misc_fixes branch 14 times, most recently from 609db83 to 70239eb Compare June 11, 2025 09:05
Vcpu TLS must only be initialized once.
Enforce this with an assertion.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Move setting of signal handler into vcpu init to
prevent race condition between setting TLS and signal handler
using TLS.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
- The reset must be called only once on vcpu drop, so move it
directly into the Drop impl.
- Replace errors with asserts since there is an assumption that TLS
will always hold correct vcpu pointer for a given thread.
- Mark Drop impl as non test only as our unit tests create multiple vcpus
which will panic on Drop since they all will be referencing same TLS.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Merge run_on_thread_local into signal handler since it is
only used there.
The error returned from run_on_thread_local was ignored, so
instead replace it with logic to only use vcpu ptr if
TLS is initialized, without returning any errors.
The reason for not asserting on TLS being initialized here
is that during Firecracker shutdown, vcpus will be destroyed
and TLS will be reset. If signal will be send to Firecracker
during that time, the TLS accessed from a signal handler will
be empty. But this is expected, so no assertions/panics are needed.

Because Rust is a good language, it does not allow to reference
TLS_VCPU_PTR definded inside impl block inside the signal_handler
function. So move the TLS_VCPU_PTR definition outside the Vcpu impl
block.

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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant