Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/mock-server/src/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion bin/propolis-server/src/lib/migrate/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion bin/propolis-server/src/lib/migrate/destination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ impl<T: MigrateConn> RonV0<T> {
if count != 0 {
return Err(MigrateError::DeviceState(format!(
"Found {} unconsumed payload(s) for device {}",
count, &device.instance_name,
count, device.instance_name,
)));
}
}
Expand Down
1 change: 0 additions & 1 deletion bin/propolis-server/src/lib/migrate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion bin/propolis-server/src/lib/spec/api_spec_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl From<Spec> 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);
}
Expand Down
2 changes: 1 addition & 1 deletion bin/propolis-server/src/lib/vcpu_tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
2 changes: 1 addition & 1 deletion bin/propolis-standalone/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
27 changes: 11 additions & 16 deletions bin/propolis-standalone/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
}
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

now that's a good lint

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();
}
Expand Down Expand Up @@ -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(())
Expand Down
6 changes: 2 additions & 4 deletions crates/cpuid-utils/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down
2 changes: 1 addition & 1 deletion lib/propolis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "propolis"
version = "0.1.0"
license = "MPL-2.0"
edition = "2021"
rust-version = "1.90"
rust-version = "1.93"

@papertigers papertigers Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without this we get the following at the pop_front_if call site

warning: current MSRV (Minimum Supported Rust Version) is `1.90.0` but this item is stable since `1.93.0`


[dependencies]
libc.workspace = true
Expand Down
1 change: 0 additions & 1 deletion lib/propolis/src/hw/virtio/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ impl VirtQueue {
false => ChainBuf::Readable(GuestAddr(desc.addr), desc.len),
};

count += 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this seems wrong, or at least an existing bug, where count == self.size() isn't considered past this point?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it is an existing bug, yeah

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

should we fix it here or in a PR stacked on top of this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The "fix" is here #1188, however we really need to go do #1190 to address all of the issues in this code path.

len += desc.len;
chain.push_buf(buf);

Expand Down
2 changes: 1 addition & 1 deletion lib/propolis/src/vcpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Vcpu {
) -> Arc<Self> {
#[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")
Expand Down
27 changes: 1 addition & 26 deletions lib/propolis/src/vsock/poller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
fn pop_front_if(
&mut self,
predicate: impl FnOnce(&mut T) -> bool,
) -> Option<T>;
}

impl<T> VecDequeExt<T> for VecDeque<T> {
fn pop_front_if(
&mut self,
predicate: impl FnOnce(&mut T) -> bool,
) -> Option<T> {
let first = self.front_mut()?;
if predicate(first) {
self.pop_front()
} else {
None
}
}
}

#[cfg(test)]
mod test {
use std::io::{Read, Write};
Expand Down Expand Up @@ -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();

Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion phd-tests/framework/src/disk/crucible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion phd-tests/framework/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl Framework {
.with_context(|| {
format!(
"adding Propolis server '{}' from options",
&params.propolis_server_path
params.propolis_server_path
)
})?;

Expand Down
8 changes: 2 additions & 6 deletions phd-tests/framework/src/test_vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,20 @@ 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,
}

/// The number of seconds to add to the migration timeout per GiB of memory in
/// the migrating VM.
const MIGRATION_SECS_PER_GUEST_GIB: u64 = 90;

impl Default for MigrationTimeout {
fn default() -> Self {
Self::InferFromMemorySize
}
}

impl From<std::time::Duration> for MigrationTimeout {
fn from(value: std::time::Duration) -> Self {
Self::Explicit(value)
Expand Down
2 changes: 1 addition & 1 deletion phd-tests/tests/src/boot_order/efi_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl DevicePath {
}
(ty, subtype) => {
bail!(
"Device path type/subtype unsupported: ({ty:#02x}/{subtype:#02x})"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i'm surprised by this one, does :#02x not format as 0x and "ty" as two hex digits padded with 0?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was actually curious about this one as well, because the output was not what I expected.

This is a rust 1.97 lint I believe and didn't trigger on macOS with 1.96

sherma scratch
❯ cat src/main.rs
fn main() {
    let ty = 4u8;
    println!("{:#x}", ty);
    println!("{:#0x}", ty);
    println!("{:#02x}", ty);
    println!("{:#04x}", ty);
}

sherma scratch
❯ cargo clippy
    Checking scratch v0.1.0 (/Users/link/src/scratch)
warning: format width has no effect on the output for this format trait
 --> src/main.rs:5:15
  |
5 |     println!("{:#02x}", ty);
  |               ^^^^^^^
  |
  = help: consider removing the width or increasing it to at least 4
  = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.97.0/index.html#unused_format_specs
  = note: `#[warn(clippy::unused_format_specs)]` on by default

warning: `scratch` (bin "scratch") generated 1 warning
    Finished [`dev` profile [unoptimized + debuginfo]](https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles) target(s) in 0.04s

sherma scratch
❯ cargo r
    Finished [`dev` profile [unoptimized + debuginfo]](https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles) target(s) in 0.03s
     Running `target/debug/scratch`
0x4
0x4
0x4
0x04

When used together with the # flag, a similar rule applies: padding zeros are inserted after the prefix but before the digits. The prefix is included in the total width.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So, this preserves the old behavior but we could change it if you want.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oh i've written so many buggy format statements then. lmao. either way you want to take this here is fine imo.

"Device path type/subtype unsupported: ({ty:#x}/{subtype:#x})"
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading