-
Notifications
You must be signed in to change notification settings - Fork 126
feat: Add KVM Nested State support and upgrade to Rust edition 2024 #331
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
Conversation
This type is a helper, making the use of get_nested_state() and set_nested_state(), which are added in a following commit, much more convenient. Note that this type's name uses UpperCamelCase as it is not just a plain old data type but actually contains some logic: the `size` field is properly initialized. Effectively, KVM expects a dynamic buffer with a header reporting the size to either store the nested state in or load it from. As such data structures with a certain alignment are challenging to work with (note that Vec<u8> always have an alignment of 1 but we need 4), this type sacrifices a little memory overhead in some cases for better UX; copying 8K once is cheap anyway. Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP [email protected]
More info: https://docs.kernel.org/virt/kvm/api.html#capabilities-that-can-be-enabled-on-vcpus Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP [email protected]
These calls are relevant for live-migration and state save/resume when nested virtualization is used. I tested everything with a nested guest in Cloud Hypervisor, but these patches are not yet upstream. Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP [email protected]
This commit upgrades kvm-bindings from the default Rust edition 2015 to edition 2024, addressing the need for explicit unsafe blocks and proper module path resolution. Changes: - Add \`edition = \"2024\"\` to kvm-bindings/Cargo.toml - Wrap unsafe function calls in explicit unsafe blocks in bindings.rs - from_raw_parts, from_raw_parts_mut, transmute calls - Fix import paths in fam_wrappers.rs and nested.rs: - \`use x86_64::bindings::*\` → \`use crate::x86_64::bindings::*\` - Add explicit \`crate::\` prefix for module imports - Remove \`extern crate core;\` (automatic in edition 2024) All tests pass with no warnings. Fixes rust-vmm#329 Signed-off-by: SteelCrab <[email protected]>
- Fix import paths: use bindings:: → use crate::bindings:: - Resolve zerocopy trait conflicts for union types - Add comprehensive serde support for KVM structures - Fix cross-platform compilation for x86_64, ARM64, RISC-V64 - Ensure MUSL compatibility Signed-off-by: SteelCrab <[email protected]>
- Add safety comments for unsafe blocks to satisfy clippy - Fix test module imports with crate:: prefix Signed-off-by: SteelCrab <[email protected]>
Signed-off-by: SteelCrab <[email protected]>
- Add safety comments for unsafe blocks to satisfy clippy Signed-off-by: SteelCrab <[email protected]>
Hey @SteelCrab, sorrry, this isn't quite what I had in mind. The nested state stuff we'll merge through #322, so please don't include them in your PR. Instead please just start with the current |
Hey @SteelCrab, now that #322 is merged, can you rebase this on top of main? |
Any update here? @SteelCrab |
superceded by #335 |
Summary
This PR adds KVM Nested State functionality and upgrades the project to Rust edition 2024.
Changes
New Features
Infrastructure
Modified Components
Testing
Breaking Changes
None - all changes are additive and maintain backward compatibility.