From 1b805afc4b9e43cb1c007518233dbfa1a6de54ac Mon Sep 17 00:00:00 2001 From: iximeow Date: Fri, 6 Sep 2024 01:18:03 +0000 Subject: [PATCH 1/5] fix new 1.81.0 warning and clippy error on 1.81, this expression caused rustc warning, and clippy error: ``` warning: this function depends on never type fallback being `()` --> bin/propolis-cli/src/main.rs:497:1 | 497 | / async fn migrate_instance( 498 | | src_client: Client, 499 | | dst_client: Client, 500 | | src_addr: SocketAddr, 501 | | dst_uuid: Uuid, 502 | | disks: Vec, 503 | | ) -> anyhow::Result<()> { | |_______________________^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #123748 = help: specify the types explicitly note: in edition 2024, the requirement `!: FromIterator<()>` will fail --> bin/propolis-cli/src/main.rs:598:20 | 598 | .collect::>()?; | ^^^^^^^^^^^^^^^^^ = note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default warning: `propolis-cli` (bin "propolis-cli") generated 1 warning ``` i am, honestly, entirely missing how the never type is involved here, or how changing the `collect`'s type from `anyhow::Result<_>` to `anyhow::Result<()>` changes things in a direction to satisfy rustc. but bounding the type further doesn't seem like it would cause a problem? --- bin/propolis-cli/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/propolis-cli/src/main.rs b/bin/propolis-cli/src/main.rs index ebf010858..e3224950b 100644 --- a/bin/propolis-cli/src/main.rs +++ b/bin/propolis-cli/src/main.rs @@ -595,7 +595,7 @@ async fn migrate_instance( .collect::, _>>()? // Then any errors from polling the source/destination .into_iter() - .collect::>()?; + .collect::>()?; Ok(()) } From 6e02d1dc2b7cc8d7a7880d6847c98684bec0fb9b Mon Sep 17 00:00:00 2001 From: iximeow Date: Fri, 6 Sep 2024 01:38:32 +0000 Subject: [PATCH 2/5] the unused pub(crate) struct warnings are new also, allow these cases --- lib/propolis/src/firmware/smbios/bits.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/propolis/src/firmware/smbios/bits.rs b/lib/propolis/src/firmware/smbios/bits.rs index 2a9918b95..028e59734 100644 --- a/lib/propolis/src/firmware/smbios/bits.rs +++ b/lib/propolis/src/firmware/smbios/bits.rs @@ -140,9 +140,11 @@ pub(crate) struct Type1 { } raw_table_impl!(Type1, 1); +// We don't create type 2 tables yet, but it's nice to have the definition on hand. /// Type 2 (Baseboard Information) #[derive(Copy, Clone)] #[repr(C, packed)] +#[allow(dead_code)] pub(crate) struct Type2 { pub header: StructureHeader, pub manufacturer: u8, @@ -159,9 +161,11 @@ pub(crate) struct Type2 { } raw_table_impl!(Type2, 2); +// We don't create type 2 tables yet, but it's nice to have the definition on hand. /// Type 3 (System Enclosure) - Version 2.7 #[derive(Copy, Clone)] #[repr(C, packed)] +#[allow(dead_code)] pub(crate) struct Type3 { pub header: StructureHeader, pub manufacturer: u8, From 98ef7166357bc9ac5f45997ad090847dd70985b8 Mon Sep 17 00:00:00 2001 From: iximeow Date: Fri, 6 Sep 2024 02:36:45 +0000 Subject: [PATCH 3/5] inspect_err is a new one to me! really don't like this clippy lint this is the clippy suggestion. i can't see a way to structure this otherwise that is not more difficult to read, so i'm going with it. --- bin/propolis-utils/src/bin/cpuid-gen.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/propolis-utils/src/bin/cpuid-gen.rs b/bin/propolis-utils/src/bin/cpuid-gen.rs index c41a5917c..ae4605262 100644 --- a/bin/propolis-utils/src/bin/cpuid-gen.rs +++ b/bin/propolis-utils/src/bin/cpuid-gen.rs @@ -16,17 +16,17 @@ fn create_vm() -> anyhow::Result { let ctl = VmmCtlFd::open()?; let _ = unsafe { ctl.ioctl(bhyve_api::VMM_CREATE_VM, &mut req) }?; - let vm = VmmFd::open(&name).map_err(|e| { + let vm = VmmFd::open(&name).inspect_err(|_e| { // Attempt to manually destroy the VM if we cannot open it let _ = ctl.vm_destroy(name.as_bytes()); - e })?; - vm.ioctl_usize(bhyve_api::ioctls::VM_SET_AUTODESTRUCT, 1).map_err(|e| { - // Destroy instance if auto-destruct cannot be set - let _ = vm.ioctl_usize(bhyve_api::VM_DESTROY_SELF, 0); - e - })?; + vm.ioctl_usize(bhyve_api::ioctls::VM_SET_AUTODESTRUCT, 1).inspect_err( + |_e| { + // Destroy instance if auto-destruct cannot be set + let _ = vm.ioctl_usize(bhyve_api::VM_DESTROY_SELF, 0); + }, + )?; Ok(vm) } From 2f1a4830467b902fe881f66aeb870597b4a468cf Mon Sep 17 00:00:00 2001 From: iximeow Date: Fri, 6 Sep 2024 02:44:46 +0000 Subject: [PATCH 4/5] fix copypaste in comment --- lib/propolis/src/firmware/smbios/bits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/propolis/src/firmware/smbios/bits.rs b/lib/propolis/src/firmware/smbios/bits.rs index 028e59734..09bcde2e2 100644 --- a/lib/propolis/src/firmware/smbios/bits.rs +++ b/lib/propolis/src/firmware/smbios/bits.rs @@ -161,7 +161,7 @@ pub(crate) struct Type2 { } raw_table_impl!(Type2, 2); -// We don't create type 2 tables yet, but it's nice to have the definition on hand. +// We don't create type 3 tables yet, but it's nice to have the definition on hand. /// Type 3 (System Enclosure) - Version 2.7 #[derive(Copy, Clone)] #[repr(C, packed)] From 7e80d6ed3b93faf2de0a6e44ea6d42451e604344 Mon Sep 17 00:00:00 2001 From: iximeow Date: Tue, 10 Sep 2024 23:11:54 +0000 Subject: [PATCH 5/5] try a different shade of paint --- bin/propolis-utils/src/bin/cpuid-gen.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/bin/propolis-utils/src/bin/cpuid-gen.rs b/bin/propolis-utils/src/bin/cpuid-gen.rs index ae4605262..9e8a49642 100644 --- a/bin/propolis-utils/src/bin/cpuid-gen.rs +++ b/bin/propolis-utils/src/bin/cpuid-gen.rs @@ -16,17 +16,23 @@ fn create_vm() -> anyhow::Result { let ctl = VmmCtlFd::open()?; let _ = unsafe { ctl.ioctl(bhyve_api::VMM_CREATE_VM, &mut req) }?; - let vm = VmmFd::open(&name).inspect_err(|_e| { - // Attempt to manually destroy the VM if we cannot open it - let _ = ctl.vm_destroy(name.as_bytes()); - })?; + let vm = match VmmFd::open(&name) { + Ok(vm) => vm, + Err(e) => { + // Attempt to manually destroy the VM if we cannot open it + let _ = ctl.vm_destroy(name.as_bytes()); + return Err(e.into()); + } + }; - vm.ioctl_usize(bhyve_api::ioctls::VM_SET_AUTODESTRUCT, 1).inspect_err( - |_e| { + match vm.ioctl_usize(bhyve_api::ioctls::VM_SET_AUTODESTRUCT, 1) { + Ok(_res) => {} + Err(e) => { // Destroy instance if auto-destruct cannot be set let _ = vm.ioctl_usize(bhyve_api::VM_DESTROY_SELF, 0); - }, - )?; + return Err(e.into()); + } + }; Ok(vm) }