-
Notifications
You must be signed in to change notification settings - Fork 1.9k
chore: Update to kvm-bindings 0.8.0 #4581
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
chore: Update to kvm-bindings 0.8.0 #4581
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4581 +/- ##
=======================================
Coverage 82.13% 82.14%
=======================================
Files 255 255
Lines 31274 31277 +3
=======================================
+ Hits 25688 25691 +3
Misses 5586 5586
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
60ab983
to
6e6b4e6
Compare
73c5678
to
01daf91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me overall other than tiny nitpicking!
f3abea7
to
a530a7a
Compare
78454d9
to
4e65114
Compare
Separate the call to `KVM_RUN` from the handling of the result value. This makes the handling of the `VcpuExit` unit-testable without needing to hack in `cfg(not(test))` code that compiles out the `KVM_RUN` call at compile time. For this, separate the parts of KvmVcpu that the exit handler needs mutable access to into a `Peripherals` structure, which is passed to `handle_kvm_exit`. This is needed so that we can shared the `&mut` to `kvm_vcpu` into `fd` and "the rest". Co-Authored-By: Egor Lazarchuk <[email protected]> Signed-off-by: Patrick Roy <[email protected]>
Upgrade kvm-bindings to 0.8.0 to make use of upstream serialization support. New kvm-bindings no longer derives `Clone` on `kvm_xsave` (since this is not correct to do for all use cases post Linux 5.17, due to the structure now having a flexible array members). While Firecracker does not make use of this flexible array members (according to KVM documentation, it will only be present if `arch_prctl` is used [1]), meaning our usage of `Clone` was not problematic, it's easier for now to just clean up our use-sites of `kvm_xsave::clone` (which was only used in test code) - turns out they were either dead code, or should be replaced with successive calls to `save_state()`. Additionally, `VcpuFd::run` now takes `self` by mutable reference, which is the reason for the preceding refactors. The result of `run` holds references into the `kvm_run` structure contained by `VcpuFd`, meaning the mutable borrow on `Vcpu::fd` will stay alive until the return value is dropped. However, if the call to `run` is behind a function call that takes the entirety of `Vcpu` by mutable reference, this means that we cannot borrow any other fields of `Vcpu` mutably until we drop the `VcpuExit` - yet we need to do exactly this to actually handle the KVM_EXIT. So, instead inline the call to `run` so that the borrow checker understand we only borrow `Vcpu::fd` instead of the entire `Vcpu` object, meaning it allows us to access the _other_ fields of the `Vcpu` struct during handling. [1]: https://docs.kernel.org/virt/kvm/api.html#kvm-get-xsave2 Signed-off-by: Patrick Roy <[email protected]>
Delete various error variants in the x86_64 version of KvmVcpuError that were never constructed/used. Signed-off-by: Patrick Roy <[email protected]>
30b343b
to
7d49849
Compare
Changes
The goal of this PR is to update kvm-bindings from our custom fork to upstream version 0.8.0, as since rust-vmm/kvm-bindings#101 the serialization support we had our fork for is merged upstream.
Additionally, refactor our emulation code to be more easily unit-testable.
Reason
The refactors are necessary due to a change in kvm-ioctls. The
self
parameter toVcpuFd::run
is now a mutable reference. Please see the final commit for a detailed breakdown of why this was incompatible with our existing mocking-based approach to testing vmexits.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
PR.
CHANGELOG.md
.TODO
s link to an issue.contribution quality standards.
rust-vmm
.