build: upgrade whole* workspace to Rust edition 2024
This upgrades the Cargo workspace to Rust edition 2024 to keep the code base clean and up to date. The commit only contains the adjustments to the Cargo.toml files and basic compiler error fixes. Also, this commit includes new SAFETY comments as discussed in [1]. The changes were not automatically fixed by `cargo fix --edition` but needed manual adjustments. Apart from that, all formatting and clippy adjustments follow in subsequent commits. * As only exception, workspace member net_gen sticks to edition 2021 for now as discussed in [0]. [0] https://github.com/cloud-hypervisor/cloud-hypervisor/pull/7295#discussion_r2310851041 [1] https://github.com/cloud-hypervisor/cloud-hypervisor/pull/7256#issuecomment-3271888674 Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de> On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
parent
5790bcefee
commit
061351d82d
31 changed files with 54 additions and 41 deletions
|
|
@ -3,7 +3,7 @@ authors = ["The Cloud Hypervisor Authors"]
|
|||
build = "build.rs"
|
||||
default-run = "cloud-hypervisor"
|
||||
description = "Open source Virtual Machine Monitor (VMM) that runs on top of KVM & MSHV"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
homepage = "https://github.com/cloud-hypervisor/cloud-hypervisor"
|
||||
license = "Apache-2.0 AND BSD-3-Clause"
|
||||
name = "cloud-hypervisor"
|
||||
|
|
@ -102,6 +102,7 @@ members = [
|
|||
"vm-virtio",
|
||||
"vmm",
|
||||
]
|
||||
package.edition = "2024"
|
||||
|
||||
[workspace.dependencies]
|
||||
# rust-vmm crates
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "api_client"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Chromium OS Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "arch"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Chromium OS Authors", "The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "block"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Chromium OS Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "devices"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,8 @@ impl PvmemcontrolTransport {
|
|||
}
|
||||
|
||||
unsafe fn as_register(self) -> PvmemcontrolTransportRegister {
|
||||
self.payload.register
|
||||
// SAFETY: We access initialized data.
|
||||
unsafe { self.payload.register }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "event_monitor"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["Microsoft Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0 OR BSD-3-Clause"
|
||||
name = "hypervisor"
|
||||
version = "0.1.0"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[package]
|
||||
authors = ["The Chromium OS Authors"]
|
||||
edition = "2021"
|
||||
#edition.workspace = true
|
||||
name = "net_gen"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Chromium OS Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "net_util"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,8 @@ impl Tap {
|
|||
/// The caller should ensure to pass a valid file descriptor and valid
|
||||
/// arguments for the `ioctl()` syscall.
|
||||
unsafe fn ioctl_with_mut_ref<F: AsRawFd, T>(fd: &F, req: c_ulong, arg: &mut T) -> Result<()> {
|
||||
let ret = ioctl_with_mut_ref(fd, req, arg);
|
||||
// SAFETY: file descriptor is valid and return value is checked
|
||||
let ret = unsafe { ioctl_with_mut_ref(fd, req, arg) };
|
||||
if ret < 0 {
|
||||
return Err(Error::IoctlError(req, IoError::last_os_error()));
|
||||
}
|
||||
|
|
@ -145,7 +146,8 @@ impl Tap {
|
|||
/// The caller should ensure to pass a valid file descriptor and valid
|
||||
/// arguments for the `ioctl()` syscall.
|
||||
unsafe fn ioctl_with_ref<F: AsRawFd, T>(fd: &F, req: c_ulong, arg: &T) -> Result<()> {
|
||||
let ret = ioctl_with_ref(fd, req, arg);
|
||||
// SAFETY: file descriptor is valid and return value is checked
|
||||
let ret = unsafe { ioctl_with_ref(fd, req, arg) };
|
||||
if ret < 0 {
|
||||
return Err(Error::IoctlError(req, IoError::last_os_error()));
|
||||
}
|
||||
|
|
@ -157,7 +159,8 @@ impl Tap {
|
|||
/// The caller should ensure to pass a valid file descriptor and valid
|
||||
/// arguments for the `ioctl()` syscall.
|
||||
unsafe fn ioctl_with_val<F: AsRawFd>(fd: &F, req: c_ulong, arg: c_ulong) -> Result<()> {
|
||||
let ret = ioctl_with_val(fd, req, arg);
|
||||
// SAFETY: file descriptor is valid and return value is checked
|
||||
let ret = unsafe { ioctl_with_val(fd, req, arg) };
|
||||
if ret < 0 {
|
||||
return Err(Error::IoctlError(req, IoError::last_os_error()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "option_parser"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["Samuel Ortiz <sameo@linux.intel.com>"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "pci"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ pub(crate) struct Interrupt {
|
|||
|
||||
impl Interrupt {
|
||||
fn update_msi(&mut self, offset: u64, data: &[u8]) -> Option<InterruptUpdateAction> {
|
||||
if let Some(ref mut msi) = &mut self.msi {
|
||||
if let Some(msi) = &mut self.msi {
|
||||
let action = msi.update(offset, data);
|
||||
return action;
|
||||
}
|
||||
|
|
@ -199,7 +199,7 @@ impl Interrupt {
|
|||
}
|
||||
|
||||
fn update_msix(&mut self, offset: u64, data: &[u8]) -> Option<InterruptUpdateAction> {
|
||||
if let Some(ref mut msix) = &mut self.msix {
|
||||
if let Some(msix) = &mut self.msix {
|
||||
let action = msix.update(offset, data);
|
||||
return action;
|
||||
}
|
||||
|
|
@ -237,7 +237,7 @@ impl Interrupt {
|
|||
}
|
||||
|
||||
fn msix_write_table(&mut self, offset: u64, data: &[u8]) {
|
||||
if let Some(ref mut msix) = &mut self.msix {
|
||||
if let Some(msix) = &mut self.msix {
|
||||
let offset = offset - u64::from(msix.cap.table_offset());
|
||||
msix.bar.write_table(offset, data)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
build = "../build.rs"
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "performance-metrics"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "rate_limiter"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "serial_buffer"
|
||||
version = "0.1.0"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "test_infra"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "tracer"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
build = "../build.rs"
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "vhost_user_block"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
build = "../build.rs"
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "vhost_user_net"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "virtio-devices"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -489,7 +489,7 @@ impl Request {
|
|||
.write()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|(_, &d)| d == domain_id)
|
||||
.filter(|&(_, &d)| d == domain_id)
|
||||
.map(|(&e, _)| e)
|
||||
.collect();
|
||||
|
||||
|
|
@ -553,7 +553,7 @@ impl Request {
|
|||
.write()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|(_, &d)| d == domain_id)
|
||||
.filter(|&(_, &d)| d == domain_id)
|
||||
.map(|(&e, _)| e)
|
||||
.collect();
|
||||
|
||||
|
|
@ -669,7 +669,7 @@ fn detach_endpoint_from_domain(
|
|||
.write()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|(_, &d)| d == domain_id)
|
||||
.filter(|&(_, &d)| d == domain_id)
|
||||
.count()
|
||||
== 0
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Chromium OS Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "vm-allocator"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "vm-device"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "vm-migration"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "vm-virtio"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
authors = ["The Cloud Hypervisor Authors"]
|
||||
edition = "2021"
|
||||
edition.workspace = true
|
||||
name = "vmm"
|
||||
version = "0.1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -33,5 +33,6 @@ pub struct clone_args {
|
|||
/// - On error: `-1` and `errno` is set
|
||||
#[must_use]
|
||||
pub unsafe fn clone3(args: &mut clone_args, size: size_t) -> c_long {
|
||||
syscall(SYS_clone3, args, size)
|
||||
// SAFETY: parameters are assumed to be valid
|
||||
unsafe { syscall(SYS_clone3, args, size) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3373,7 +3373,7 @@ impl DeviceManager {
|
|||
let mut devices = Vec::new();
|
||||
|
||||
let mut vsock = self.config.lock().unwrap().vsock.clone();
|
||||
if let Some(ref mut vsock_cfg) = &mut vsock {
|
||||
if let Some(vsock_cfg) = &mut vsock {
|
||||
devices.push(self.make_virtio_vsock_device(vsock_cfg)?);
|
||||
}
|
||||
self.config.lock().unwrap().vsock = vsock;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ unsafe fn close_fds_fallback(keep_fds: &BTreeSet<RawFd>) {
|
|||
.collect();
|
||||
|
||||
for fd in open_fds.difference(keep_fds) {
|
||||
close(*fd);
|
||||
// SAFETY: The FD is valid
|
||||
unsafe { close(*fd) };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -108,12 +109,14 @@ unsafe fn close_unused_fds(keep_fds: &mut [RawFd]) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if syscall(SYS_close_range, first, last, 0) == -1 {
|
||||
// SAFETY: FDs are valid
|
||||
if unsafe { syscall(SYS_close_range, first, last, 0) } == -1 {
|
||||
// The kernel might be too old to have close_range, in
|
||||
// which case we need to fall back to an uglier method.
|
||||
let e = io::Error::last_os_error();
|
||||
if e.raw_os_error() == Some(ENOSYS) {
|
||||
return close_fds_fallback(&keep_fds.iter().copied().collect());
|
||||
// SAFETY: FDs are valid
|
||||
return unsafe { close_fds_fallback(&keep_fds.iter().copied().collect()) };
|
||||
}
|
||||
|
||||
panic!("close_range: {e}");
|
||||
|
|
@ -212,7 +215,8 @@ unsafe fn clone_clear_sighand() -> io::Result<u64> {
|
|||
..Default::default()
|
||||
};
|
||||
args.flags |= CLONE_CLEAR_SIGHAND;
|
||||
let r = clone3(&mut args, size_of::<clone_args>());
|
||||
// SAFETY: parameters are assumed to be valid
|
||||
let r = unsafe { clone3(&mut args, size_of::<clone_args>()) };
|
||||
if r != -1 {
|
||||
return Ok(r.try_into().unwrap());
|
||||
}
|
||||
|
|
@ -223,13 +227,15 @@ unsafe fn clone_clear_sighand() -> io::Result<u64> {
|
|||
|
||||
// If CLONE_CLEAR_SIGHAND isn't available, fall back to resetting
|
||||
// all the signal handlers one by one.
|
||||
let r = fork();
|
||||
// SAFETY: trivially safe, and we check the return value.
|
||||
let r = unsafe { fork() };
|
||||
if r == -1 {
|
||||
return Err(io::Error::last_os_error());
|
||||
}
|
||||
if r == 0 {
|
||||
for signum in 1.._NSIG {
|
||||
let _ = signal(signum, SIG_DFL);
|
||||
// SAFETY: trivially safe, we unset the user-space signal handler
|
||||
let _ = unsafe { signal(signum, SIG_DFL) };
|
||||
}
|
||||
}
|
||||
Ok(r.try_into().unwrap())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue