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

test: Add tests for multi-vCPU setup #4942

Merged
merged 4 commits into from
Dec 10, 2024

Conversation

zulinx86
Copy link
Contributor

@zulinx86 zulinx86 commented Dec 4, 2024

Merge #4934 first, since this PR is based on it. Only the last three commits are for this PR Now unblocked!

Changes

Add the following tests for multi-vCPU setup:

  • Check all vCPUs are online
  • Check all vCPUs have the same features

Note that whether the presented CPU features are expected or not should be tested in (arch-specific) test_cpu_features_*.py only for vCPU 0.

Reason

To prevent a similar type of bugs fixed in #4925 where a bad CPU template made secondary CPUs not work.

Testing

It is confirmed that the bug of the bad CPU template is correctly caught.

...::test_all_vcpus_online[...-custom_aarch64_with_sve_and_pac] PASSED             [  7%]
...::test_all_vcpus_online[...-custom_aarch64_with_sve_and_pac_bad] FAILED         [ 10%]
...
...::test_all_vcpus_online[...-custom_aarch64_with_sve_and_pac] PASSED              [ 20%]
...::test_all_vcpus_online[...-custom_aarch64_with_sve_and_pac_bad] FAILED          [ 22%]
...
...::test_all_vcpus_online[...-custom_aarch64_with_sve_and_pac] PASSED           [ 32%]
...::test_all_vcpus_online[...-custom_aarch64_with_sve_and_pac_bad] FAILED       [ 35%]
...
...::test_all_vcpus_online[...-custom_aarch64_with_sve_and_pac] PASSED            [ 45%]
...::test_all_vcpus_online[...-custom_aarch64_with_sve_and_pac_bad] FAILED        [ 47%]
...
...::test_all_vcpus_have_same_features[...-custom_aarch64_with_sve_and_pac] PASSED [ 57%]
...::test_all_vcpus_have_same_features[...-custom_aarch64_with_sve_and_pac_bad] FAILED [ 60%]
...
...::test_all_vcpus_have_same_features[...-custom_aarch64_with_sve_and_pac] PASSED  [ 70%]
...::test_all_vcpus_have_same_features[...-custom_aarch64_with_sve_and_pac_bad] FAILED [ 72%]
...
...::test_all_vcpus_have_same_features[...-custom_aarch64_with_sve_and_pac] PASSED [ 82%]
...::test_all_vcpus_have_same_features[...-custom_aarch64_with_sve_and_pac_bad] FAILED [ 85%]
...
...::test_all_vcpus_have_same_features[...-custom_aarch64_with_sve_and_pac] PASSED [ 95%]
...::test_all_vcpus_have_same_features[...-custom_aarch64_with_sve_and_pac_bad] FAILED [ 97%]

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 Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.07%. Comparing base (761909d) to head (58cfbde).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4942   +/-   ##
=======================================
  Coverage   84.07%   84.07%           
=======================================
  Files         251      251           
  Lines       28059    28059           
=======================================
  Hits        23592    23592           
  Misses       4467     4467           
Flag Coverage Δ
5.10-c5n.metal 84.65% <ø> (ø)
5.10-m5n.metal 84.63% <ø> (+<0.01%) ⬆️
5.10-m6a.metal 83.93% <ø> (ø)
5.10-m6g.metal 80.74% <ø> (ø)
5.10-m6i.metal 84.62% <ø> (+<0.01%) ⬆️
5.10-m7g.metal 80.74% <ø> (ø)
6.1-c5n.metal 84.65% <ø> (+<0.01%) ⬆️
6.1-m5n.metal 84.63% <ø> (ø)
6.1-m6a.metal 83.93% <ø> (ø)
6.1-m6g.metal 80.74% <ø> (-0.01%) ⬇️
6.1-m6i.metal 84.62% <ø> (ø)
6.1-m7g.metal 80.74% <ø> (ø)

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.

pb8o
pb8o previously approved these changes Dec 4, 2024
tests/integration_tests/functional/test_cpu_multiple.py Outdated Show resolved Hide resolved
tests/integration_tests/functional/test_cpu_multiple.py Outdated Show resolved Hide resolved
@zulinx86
Copy link
Contributor Author

zulinx86 commented Dec 5, 2024

rebased onto the latest state of #4934

@zulinx86
Copy link
Contributor Author

zulinx86 commented Dec 6, 2024

rebased on top of latest main

roypat
roypat previously approved these changes Dec 6, 2024
@zulinx86
Copy link
Contributor Author

zulinx86 commented Dec 6, 2024

[deleted]

As seen in firecracker-microvm#4925, setting the least significant bits of vcpu_features
field to 0 make secondary CPUs not work. There is no reason to use such
an invalid example in doc. The sample in doc intended to enable PAC
(Pointer Authentication) since it checks capabilities 171 and 172 [2].
Thus, not set the other bits than bits 5 and 6.

[1]: https://elixir.bootlin.com/linux/v6.12.1/source/include/uapi/linux/kvm.h#L868-L869
[2]: https://elixir.bootlin.com/linux/v6.12.1/source/arch/arm64/include/uapi/asm/kvm.h#L108-L109

Signed-off-by: Takahiro Itazuri <[email protected]>
@zulinx86 zulinx86 force-pushed the vcpu_online branch 3 times, most recently from b134c0c to 0841f0f Compare December 9, 2024 01:24
@zulinx86 zulinx86 requested review from roypat and pb8o December 9, 2024 01:43
roypat
roypat previously approved these changes Dec 9, 2024
As seen in firecracker-microvm#4925, a bad CPU template made secondary CPUs not come up. To
catch similar bugs of CPU templates, check all the vCPUs are online from
guests' perspective.

Signed-off-by: Takahiro Itazuri <[email protected]>
The test ensures Firecracker or CPU templates don't configure CPU
features differently between vCPUs.

Note that whether the printed CPU features are expected or not should be
tested in (arch-specific) test_cpu_features_*.py only for vCPU 0. Thus,
we only test the equivalence of all CPUs in the same guest.

Signed-off-by: Takahiro Itazuri <[email protected]>
test_max_cpus.py tests vCPUs are online only on a microVM without CPU
templates, which is now covered as part of test_all_vcpus_online().
Remove the test and use the maximum number of vCPUs in the new tests.

Signed-off-by: Takahiro Itazuri <[email protected]>
@roypat roypat merged commit db2e270 into firecracker-microvm:main Dec 10, 2024
6 of 7 checks passed
@zulinx86 zulinx86 deleted the vcpu_online branch December 16, 2024 07:13
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.

4 participants