Skip to content

feat: upgrade kvm-bindings to Rust edition 2024 #330

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

Closed
wants to merge 4 commits into from

Conversation

SteelCrab
Copy link

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 #329

phip1611 and others added 4 commits June 10, 2025 09:23
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]
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 #329
Copy link
Member

@RuoqingHe RuoqingHe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your commits are beyond the topic of this PR, and lacking your SoB, please double check.

And please take a look into other archs too 🙂

@roypat
Copy link
Member

roypat commented Jun 17, 2025

Your commits are beyond the topic of this PR

I think the commits are from #322 - please just rebase on top of main :)

And please take a look into other archs too 🙂

+1 to this, and let's also do kvm-ioctls as well! :D

@SteelCrab
Copy link
Author

Got it! I'll rebase on main to clean up those #322 commits and check other archs too.

+1 on adding kvm-ioctls - I'll include that as well!

@SteelCrab SteelCrab closed this Jun 17, 2025
@SteelCrab SteelCrab deleted the nested-state branch June 17, 2025 22:58
@SteelCrab SteelCrab restored the nested-state branch June 18, 2025 00:43
@SteelCrab SteelCrab deleted the nested-state branch June 18, 2025 00:43
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.

Update Rust Edition
4 participants