diff --git a/bin/mock-server/src/lib/lib.rs b/bin/mock-server/src/lib/lib.rs index 6f034f94c..345738a43 100644 --- a/bin/mock-server/src/lib/lib.rs +++ b/bin/mock-server/src/lib/lib.rs @@ -12,7 +12,7 @@ use dropshot::{ TypedBody, WebsocketConnection, }; use futures::SinkExt; -use slog::{error, o, Logger}; +use slog::{o, Logger}; use std::collections::BTreeMap; use thiserror::Error; use tokio::sync::{watch, Mutex}; diff --git a/bin/propolis-server/src/lib/migrate/codec.rs b/bin/propolis-server/src/lib/migrate/codec.rs index c4ef64ae9..d34afa9b9 100644 --- a/bin/propolis-server/src/lib/migrate/codec.rs +++ b/bin/propolis-server/src/lib/migrate/codec.rs @@ -23,7 +23,6 @@ use super::MigrateError; use bytes::{Buf, BufMut, Bytes}; -use slog::error; use strum::FromRepr; use thiserror::Error; use tokio_tungstenite::tungstenite; diff --git a/bin/propolis-server/src/lib/migrate/destination.rs b/bin/propolis-server/src/lib/migrate/destination.rs index 26a297d04..26b8f59c6 100644 --- a/bin/propolis-server/src/lib/migrate/destination.rs +++ b/bin/propolis-server/src/lib/migrate/destination.rs @@ -749,7 +749,7 @@ impl RonV0 { if count != 0 { return Err(MigrateError::DeviceState(format!( "Found {} unconsumed payload(s) for device {}", - count, &device.instance_name, + count, device.instance_name, ))); } } diff --git a/bin/propolis-server/src/lib/migrate/mod.rs b/bin/propolis-server/src/lib/migrate/mod.rs index 2145dd3c3..858e6846e 100644 --- a/bin/propolis-server/src/lib/migrate/mod.rs +++ b/bin/propolis-server/src/lib/migrate/mod.rs @@ -7,7 +7,6 @@ use dropshot::HttpError; use propolis::migrate::MigrateStateError; use propolis_api_types::migration::MigrationState; use serde::{Deserialize, Serialize}; -use slog::error; use thiserror::Error; use tokio::io::{AsyncRead, AsyncWrite}; diff --git a/bin/propolis-server/src/lib/spec/api_spec_v0.rs b/bin/propolis-server/src/lib/spec/api_spec_v0.rs index 4aa0d3e21..e9c1f1959 100644 --- a/bin/propolis-server/src/lib/spec/api_spec_v0.rs +++ b/bin/propolis-server/src/lib/spec/api_spec_v0.rs @@ -94,7 +94,7 @@ impl From for v1::instance_spec::InstanceSpec { assert!( !spec.components.contains_key(&key), "component name {} already exists in output spec", - &key + key ); spec.components.insert(key, val); } diff --git a/bin/propolis-server/src/lib/vcpu_tasks.rs b/bin/propolis-server/src/lib/vcpu_tasks.rs index d2b2d4dd7..3870033c3 100644 --- a/bin/propolis-server/src/lib/vcpu_tasks.rs +++ b/bin/propolis-server/src/lib/vcpu_tasks.rs @@ -65,7 +65,7 @@ impl VcpuTasks { let mut tasks = Vec::new(); for (vcpu, bind_cpu) in - machine.vcpus.iter().map(Arc::clone).zip(bindings.into_iter()) + machine.vcpus.iter().map(Arc::clone).zip(bindings) { let (task, ctrl) = propolis::tasks::TaskHdl::new_held(Some(vcpu.barrier_fn())); diff --git a/bin/propolis-standalone/Cargo.toml b/bin/propolis-standalone/Cargo.toml index 41df0cb0b..f0e005f4d 100644 --- a/bin/propolis-standalone/Cargo.toml +++ b/bin/propolis-standalone/Cargo.toml @@ -3,7 +3,7 @@ name = "propolis-standalone" version = "0.1.0" license = "MPL-2.0" edition = "2021" -rust-version = "1.73" +rust-version = "1.93" [[bin]] name = "propolis-standalone" diff --git a/bin/propolis-standalone/src/main.rs b/bin/propolis-standalone/src/main.rs index 68bfd4901..a2e2b6c44 100644 --- a/bin/propolis-standalone/src/main.rs +++ b/bin/propolis-standalone/src/main.rs @@ -130,14 +130,13 @@ impl EventQueue { let mut inner = self.inner.lock().unwrap(); while let Some((ev, ctx)) = inner.events.pop_front() { match cur { - Some(cur_ev) => { - if cur_ev.supersedes(&ev) { - // queued event is superseded by current one, so discard - // it and look for another which may be relevant. - continue; - } else { - return Some((ev, ctx)); - } + Some(cur_ev) if cur_ev.supersedes(&ev) => { + // queued event is superseded by current one, so discard + // it and look for another which may be relevant. + continue; + } + Some(_) => { + return Some((ev, ctx)); } None => return Some((ev, ctx)), } @@ -327,7 +326,7 @@ impl Instance { }; for (vcpu, bind_cpu) in - machine.vcpus.iter().map(Arc::clone).zip(bind_cpus.into_iter()) + machine.vcpus.iter().map(Arc::clone).zip(bind_cpus) { let (task, ctrl) = propolis::tasks::TaskHdl::new_held(Some(vcpu.barrier_fn())); @@ -406,14 +405,14 @@ impl Instance { match state { State::Run if first_boot => { tokio::runtime::Handle::current().block_on(async { - for (_name, be) in guard.inventory.block.iter() { + for be in guard.inventory.block.values() { be.start().await.expect("blockdev start succeeds"); } }); } State::Halt => { tokio::runtime::Handle::current().block_on(async { - for (_name, be) in guard.inventory.block.iter() { + for be in guard.inventory.block.values() { be.stop().await; be.attachment().detach(); } @@ -1419,11 +1418,7 @@ fn setup_instance( } _ => { slog::error!(log, "unrecognized driver {driver}"; "name" => name); - return Err(Error::new( - ErrorKind::Other, - "Unrecognized driver", - ) - .into()); + return Err(Error::other("Unrecognized driver").into()); } }; Ok(()) diff --git a/crates/cpuid-utils/src/host.rs b/crates/cpuid-utils/src/host.rs index 3e79011d5..3ed323078 100644 --- a/crates/cpuid-utils/src/host.rs +++ b/crates/cpuid-utils/src/host.rs @@ -80,10 +80,8 @@ impl Drop for Vm { /// Queries the supplied CPUID leaf on the caller's machine. #[cfg(target_arch = "x86_64")] pub fn query(leaf: CpuidIdent) -> CpuidValues { - unsafe { - core::arch::x86_64::__cpuid_count(leaf.leaf, leaf.subleaf.unwrap_or(0)) - } - .into() + core::arch::x86_64::__cpuid_count(leaf.leaf, leaf.subleaf.unwrap_or(0)) + .into() } #[cfg(not(target_arch = "x86_64"))] diff --git a/lib/propolis/Cargo.toml b/lib/propolis/Cargo.toml index 786013d7b..180f1ae31 100644 --- a/lib/propolis/Cargo.toml +++ b/lib/propolis/Cargo.toml @@ -3,7 +3,7 @@ name = "propolis" version = "0.1.0" license = "MPL-2.0" edition = "2021" -rust-version = "1.90" +rust-version = "1.93" [dependencies] libc.workspace = true diff --git a/lib/propolis/src/hw/virtio/queue.rs b/lib/propolis/src/hw/virtio/queue.rs index 9c9925505..4d50489c2 100644 --- a/lib/propolis/src/hw/virtio/queue.rs +++ b/lib/propolis/src/hw/virtio/queue.rs @@ -520,7 +520,6 @@ impl VirtQueue { false => ChainBuf::Readable(GuestAddr(desc.addr), desc.len), }; - count += 1; len += desc.len; chain.push_buf(buf); diff --git a/lib/propolis/src/vcpu.rs b/lib/propolis/src/vcpu.rs index c2010fa33..ae2f0f2cf 100644 --- a/lib/propolis/src/vcpu.rs +++ b/lib/propolis/src/vcpu.rs @@ -76,7 +76,7 @@ impl Vcpu { ) -> Arc { #[cfg(target_arch = "x86_64")] fn query_hardware_vendor() -> CpuidVendor { - let res = unsafe { core::arch::x86_64::__cpuid(0) }; + let res = core::arch::x86_64::__cpuid(0); propolis_types::CpuidValues::from(res) .try_into() .expect("CPU vendor is recognized") diff --git a/lib/propolis/src/vsock/poller.rs b/lib/propolis/src/vsock/poller.rs index 5f4302c0f..7d2b9d918 100644 --- a/lib/propolis/src/vsock/poller.rs +++ b/lib/propolis/src/vsock/poller.rs @@ -1064,29 +1064,6 @@ impl VsockGuestAddr { } } -// TODO this can become `[VecDeque::pop_front_if]` when we update to Rust 1.93, -// until then the impl is shamelessly borrowed. -trait VecDequeExt { - fn pop_front_if( - &mut self, - predicate: impl FnOnce(&mut T) -> bool, - ) -> Option; -} - -impl VecDequeExt for VecDeque { - fn pop_front_if( - &mut self, - predicate: impl FnOnce(&mut T) -> bool, - ) -> Option { - let first = self.front_mut()?; - if predicate(first) { - self.pop_front() - } else { - None - } - } -} - #[cfg(test)] mod test { use std::io::{Read, Write}; @@ -1495,9 +1472,8 @@ mod test { let num_chunks = (CONN_TX_BUF_SIZE / 2) / chunk_size + 1; let payload = vec![0xAB_u8; chunk_size]; let total_sent = num_chunks * chunk_size; - let mut tx_consumed = 1u16; // REQUEST was consumed - for _ in 0..num_chunks { + for tx_consumed in (1u16..).take(num_chunks) { // Reuse descriptor slots each iteration harness.reset_tx_cursors(); @@ -1519,7 +1495,6 @@ mod test { harness.publish_tx(d_hdr); notify.queue_notify(VSOCK_TX_QUEUE).unwrap(); - tx_consumed += 1; wait_for_condition(|| harness.tx_used_idx() >= tx_consumed, 5000); } diff --git a/phd-tests/framework/src/disk/crucible.rs b/phd-tests/framework/src/disk/crucible.rs index 843f0d9b5..2c5cf4cc2 100644 --- a/phd-tests/framework/src/disk/crucible.rs +++ b/phd-tests/framework/src/disk/crucible.rs @@ -323,7 +323,7 @@ impl Inner { // Spawn the downstairs processes that will serve requests from guest // VMs. let mut downstairs_instances = vec![]; - for (port, dir) in downstairs_ports.iter().zip(data_dirs.into_iter()) { + for (port, dir) in downstairs_ports.iter().zip(data_dirs) { let addr = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), *port); let dir_arg = dir.path.to_string_lossy(); let crucible_args = [ diff --git a/phd-tests/framework/src/lib.rs b/phd-tests/framework/src/lib.rs index 69257f810..7c12af978 100644 --- a/phd-tests/framework/src/lib.rs +++ b/phd-tests/framework/src/lib.rs @@ -273,7 +273,7 @@ impl Framework { .with_context(|| { format!( "adding Propolis server '{}' from options", - ¶ms.propolis_server_path + params.propolis_server_path ) })?; diff --git a/phd-tests/framework/src/test_vm/mod.rs b/phd-tests/framework/src/test_vm/mod.rs index 3f580e6da..6514d46c7 100644 --- a/phd-tests/framework/src/test_vm/mod.rs +++ b/phd-tests/framework/src/test_vm/mod.rs @@ -87,11 +87,13 @@ struct MigrationInfo { } /// Specifies the timeout to apply to an attempt to migrate. +#[derive(Default)] pub enum MigrationTimeout { /// Time out after the specified duration. Explicit(std::time::Duration), /// Allow MIGRATION_SECS_PER_GUEST_GIB seconds per GiB of guest memory. + #[default] InferFromMemorySize, } @@ -99,12 +101,6 @@ pub enum MigrationTimeout { /// the migrating VM. const MIGRATION_SECS_PER_GUEST_GIB: u64 = 90; -impl Default for MigrationTimeout { - fn default() -> Self { - Self::InferFromMemorySize - } -} - impl From for MigrationTimeout { fn from(value: std::time::Duration) -> Self { Self::Explicit(value) diff --git a/phd-tests/tests/src/boot_order/efi_utils.rs b/phd-tests/tests/src/boot_order/efi_utils.rs index 9c88a02fe..880bd6fb7 100644 --- a/phd-tests/tests/src/boot_order/efi_utils.rs +++ b/phd-tests/tests/src/boot_order/efi_utils.rs @@ -198,7 +198,7 @@ impl DevicePath { } (ty, subtype) => { bail!( - "Device path type/subtype unsupported: ({ty:#02x}/{subtype:#02x})" + "Device path type/subtype unsupported: ({ty:#x}/{subtype:#x})" ); } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 43010dda7..18ea51900 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -2,5 +2,5 @@ # We choose a specific toolchain (rather than "stable") for repeatability. The # intent is to keep this up-to-date with recently-released stable Rust. -channel = "1.90.0" +channel = "1.97.1" profile = "default"