From 444395050a0ec00cb6f0cb57ab6a7e70dc42cbf9 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Thu, 31 Aug 2023 17:06:31 +0100 Subject: [PATCH 01/12] versions: Bump rust version Bump rust to 1.72.0 to test what extra warnings/issues we get Fixes: #7902 Signed-off-by: stevenhorsman --- versions.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.yaml b/versions.yaml index d37e206fc9..c7cafb0797 100644 --- a/versions.yaml +++ b/versions.yaml @@ -356,12 +356,12 @@ languages: rust: description: "Rust language" notes: "'version' is the default minimum version used by this project." - version: "1.69.0" + version: "1.72.0" meta: description: | 'newest-version' is the latest version known to work when building Kata - newest-version: "1.69.0" + newest-version: "1.72.0" golangci-lint: description: "golangci-lint" From 9e423bd3d61f29c30d24366e3709094dcfaf7ac2 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 5 Sep 2023 10:01:59 +0100 Subject: [PATCH 02/12] libs: Fix clippy unnecesary hashes error - Fix error: unnecessary hashes around raw string literal Fixes: #7902 Signed-off-by: stevenhorsman --- src/libs/safe-path/src/scoped_path_resolver.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/safe-path/src/scoped_path_resolver.rs b/src/libs/safe-path/src/scoped_path_resolver.rs index 4d06f00627..d9815f5296 100644 --- a/src/libs/safe-path/src/scoped_path_resolver.rs +++ b/src/libs/safe-path/src/scoped_path_resolver.rs @@ -245,7 +245,7 @@ mod tests { fn test_scoped_resolve_invalid() { scoped_resolve("./root_is_not_absolute_path", ".").unwrap_err(); scoped_resolve("C:", ".").unwrap_err(); - scoped_resolve(r#"\\server\test"#, ".").unwrap_err(); + scoped_resolve(r"\\server\test", ".").unwrap_err(); scoped_resolve(r#"http://localhost/test"#, ".").unwrap_err(); // Chinese Unicode characters scoped_resolve(r#"您好"#, ".").unwrap_err(); From f3a0fd5907b91e01456ba28d70d84f3726608e74 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 5 Sep 2023 12:01:12 +0100 Subject: [PATCH 03/12] agent: config: Fix useles-vec warning Fix clippy::useless-vec warning Fixes: #7902 Signed-off-by: stevenhorsman --- src/agent/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/agent/src/config.rs b/src/agent/src/config.rs index b503dc8491..a58cc3ff93 100644 --- a/src/agent/src/config.rs +++ b/src/agent/src/config.rs @@ -1392,7 +1392,7 @@ Caused by: assert_eq!(config.server_addr, "vsock://8:2048"); assert_eq!( config.endpoints.allowed, - vec!["CreateContainer".to_string(), "StartContainer".to_string()] + ["CreateContainer".to_string(), "StartContainer".to_string()] .iter() .cloned() .collect() From 75cfdd5d59d4f8b7beef085b0911d2922626d640 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 5 Sep 2023 13:24:21 +0100 Subject: [PATCH 04/12] agent: config: Allow clippy lint - Allow `clippy::redundant-closure-call` in `from_cmdline` which has issues with the guard function passed into the `parse_cmdline_param` macro Fixes: #7902 Signed-off-by: stevenhorsman --- src/agent/src/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/agent/src/config.rs b/src/agent/src/config.rs index a58cc3ff93..36bdf66c86 100644 --- a/src/agent/src/config.rs +++ b/src/agent/src/config.rs @@ -195,6 +195,7 @@ impl FromStr for AgentConfig { impl AgentConfig { #[instrument] + #[allow(clippy::redundant_closure_call)] pub fn from_cmdline(file: &str, args: Vec) -> Result { // If config file specified in the args, generate our config from it let config_position = args.iter().position(|a| a == "--config" || a == "-c"); From bbf19195165d5da5f72aa8de08a02e5b566a545a Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 5 Sep 2023 14:10:50 +0100 Subject: [PATCH 05/12] dragonball: Resolve non-minimal-cfg warning - In rust 1.72, clippy warned clippy::non-minimal-cfg as the cfg has only one condition, so doesn't need to be wrapped in the all combinators. Fixes: #7902 Signed-off-by: stevenhorsman --- src/dragonball/src/vcpu/vcpu_manager.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dragonball/src/vcpu/vcpu_manager.rs b/src/dragonball/src/vcpu/vcpu_manager.rs index 41200d0107..dff3aefc3b 100644 --- a/src/dragonball/src/vcpu/vcpu_manager.rs +++ b/src/dragonball/src/vcpu/vcpu_manager.rs @@ -832,7 +832,7 @@ mod hotplug { #[cfg(all(target_arch = "x86_64", feature = "dbs-upcall"))] use dbs_boot::mptable::APIC_VERSION; - #[cfg(all(target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] const APIC_VERSION: u8 = 0; #[cfg(feature = "dbs-upcall")] From 16fbc27b09d1f98ea87d6b1e17c2d8c8acf40e8a Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 16:49:35 +0100 Subject: [PATCH 06/12] dragonball: Allow ambiguous-glob-reexports The bindgen generated code is triggering lots of ambiguous-glob-reexports warnings in rust 1.70+ Fixes: #7902 Signed-off-by: stevenhorsman --- src/dragonball/src/dbs_utils/src/net/net_gen/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dragonball/src/dbs_utils/src/net/net_gen/mod.rs b/src/dragonball/src/dbs_utils/src/net/net_gen/mod.rs index 30758f3514..ba0f62c13a 100644 --- a/src/dragonball/src/dbs_utils/src/net/net_gen/mod.rs +++ b/src/dragonball/src/dbs_utils/src/net/net_gen/mod.rs @@ -10,6 +10,7 @@ #![allow(non_snake_case)] #![allow(missing_docs)] #![allow(deref_nullptr)] +#![allow(ambiguous_glob_reexports)] // generated with bindgen /usr/include/linux/if.h --no-unstable-rust // --constified-enum '*' --with-derive-default -- -D __UAPI_DEF_IF_IFNAMSIZ -D From 99f3d69e948669033a7eddfc005f56e34e429cff Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 17:38:47 +0100 Subject: [PATCH 07/12] runtime-rs: Remove mut Fix `error: variable does not need to be mutable` Fixes: #7902 Signed-off-by: stevenhorsman --- src/runtime-rs/crates/resource/src/volume/spdk_volume.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime-rs/crates/resource/src/volume/spdk_volume.rs b/src/runtime-rs/crates/resource/src/volume/spdk_volume.rs index f0ea125da7..85bd645a9f 100644 --- a/src/runtime-rs/crates/resource/src/volume/spdk_volume.rs +++ b/src/runtime-rs/crates/resource/src/volume/spdk_volume.rs @@ -75,7 +75,7 @@ impl SPDKVolume { let block_driver = get_block_driver(d).await; - let mut vhu_blk_config = &mut VhostUserConfig { + let vhu_blk_config = &mut VhostUserConfig { socket_path: device, device_type: VhostUserType::Blk("vhost-user-blk-pci".to_owned()), driver_option: block_driver, From 1d8b78959d019996669ddcbcb71f225e3849a824 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 18:09:54 +0100 Subject: [PATCH 08/12] runtime-rs: Fix useless-vec warning Fix clippy::useless-vec warning Fixes: #7902 Signed-off-by: stevenhorsman --- src/runtime-rs/crates/resource/src/network/utils/address.rs | 4 ++-- src/runtime-rs/crates/resource/src/volume/block_volume.rs | 2 +- src/runtime-rs/crates/resource/src/volume/shm_volume.rs | 2 +- src/runtime-rs/crates/resource/src/volume/spdk_volume.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/runtime-rs/crates/resource/src/network/utils/address.rs b/src/runtime-rs/crates/resource/src/network/utils/address.rs index 792c4fbb5f..a9a4c75002 100644 --- a/src/runtime-rs/crates/resource/src/network/utils/address.rs +++ b/src/runtime-rs/crates/resource/src/network/utils/address.rs @@ -148,7 +148,7 @@ mod tests { #[test] fn test_parse_ip_cidr() { - let test_cases = vec![ + let test_cases = [ ("127.0.0.1/32", ("127.0.0.1", 32u8)), ("2001:4860:4860::8888/32", ("2001:4860:4860::8888", 32u8)), ("2001:4860:4860::8888/128", ("2001:4860:4860::8888", 128u8)), @@ -158,7 +158,7 @@ mod tests { assert_eq!(ipaddr.to_string(), tc.1 .0); assert_eq!(mask, tc.1 .1); } - let test_cases = vec![ + let test_cases = [ "127.0.0.1/33", "2001:4860:4860::8888/129", "2001:4860:4860::8888/300", diff --git a/src/runtime-rs/crates/resource/src/volume/block_volume.rs b/src/runtime-rs/crates/resource/src/volume/block_volume.rs index ded162bd08..d0e361b243 100644 --- a/src/runtime-rs/crates/resource/src/volume/block_volume.rs +++ b/src/runtime-rs/crates/resource/src/volume/block_volume.rs @@ -181,7 +181,7 @@ impl Volume for BlockVolume { } pub(crate) fn is_block_volume(m: &oci::Mount) -> Result { - let vol_types = vec![KATA_MOUNT_BIND_TYPE, KATA_DIRECT_VOLUME_TYPE]; + let vol_types = [KATA_MOUNT_BIND_TYPE, KATA_DIRECT_VOLUME_TYPE]; if !vol_types.contains(&m.r#type.as_str()) { return Ok(false); } diff --git a/src/runtime-rs/crates/resource/src/volume/shm_volume.rs b/src/runtime-rs/crates/resource/src/volume/shm_volume.rs index fb12b36145..ea769b2dc1 100644 --- a/src/runtime-rs/crates/resource/src/volume/shm_volume.rs +++ b/src/runtime-rs/crates/resource/src/volume/shm_volume.rs @@ -68,7 +68,7 @@ impl ShmVolume { r#type: "tmpfs".to_string(), destination: m.destination.clone(), source: "shm".to_string(), - options: vec![ + options: [ "noexec", "nosuid", "nodev", diff --git a/src/runtime-rs/crates/resource/src/volume/spdk_volume.rs b/src/runtime-rs/crates/resource/src/volume/spdk_volume.rs index 85bd645a9f..6789d6d371 100644 --- a/src/runtime-rs/crates/resource/src/volume/spdk_volume.rs +++ b/src/runtime-rs/crates/resource/src/volume/spdk_volume.rs @@ -183,7 +183,7 @@ impl Volume for SPDKVolume { pub(crate) fn is_spdk_volume(m: &oci::Mount) -> bool { // spdkvol or spoolvol will share the same implementation - let vol_types = vec![KATA_SPDK_VOLUME_TYPE, KATA_SPOOL_VOLUME_TYPE]; + let vol_types = [KATA_SPDK_VOLUME_TYPE, KATA_SPOOL_VOLUME_TYPE]; if vol_types.contains(&m.r#type.as_str()) { return true; } From 3eaf68d954da458972b06979eb91f67864d6777e Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 19:26:14 +0100 Subject: [PATCH 09/12] agent-ctl: Allow clippy lint - Allow `clippy::redundant-closure-call` which has issues with the guard function passed into the `run_if_auto_values` macro Fixes: #7902 Signed-off-by: stevenhorsman --- src/tools/agent-ctl/src/client.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/agent-ctl/src/client.rs b/src/tools/agent-ctl/src/client.rs index 802bc79669..0c4485103b 100644 --- a/src/tools/agent-ctl/src/client.rs +++ b/src/tools/agent-ctl/src/client.rs @@ -1199,6 +1199,7 @@ fn agent_cmd_container_start( Ok(()) } +#[allow(clippy::redundant_closure_call)] fn agent_cmd_sandbox_get_guest_details( ctx: &Context, client: &AgentServiceClient, @@ -2015,6 +2016,7 @@ fn agent_cmd_sandbox_update_container( Ok(()) } +#[allow(clippy::redundant_closure_call)] fn agent_cmd_sandbox_mem_hotplug_by_probe( ctx: &Context, client: &AgentServiceClient, From c8419fc3bb2211c8ae77757c4f31604f5f9ac7a6 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 19:59:59 +0100 Subject: [PATCH 10/12] kata-ctl: Resolve non-minimal-cfg warning - In rust 1.72, clippy warned clippy::non-minimal-cfg as the cfg has only one condition, so doesn't need to be wrapped in the any combinator. Fixes: #7902 Signed-off-by: stevenhorsman --- src/tools/kata-ctl/src/check.rs | 12 ++++++------ src/tools/kata-ctl/src/utils.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tools/kata-ctl/src/check.rs b/src/tools/kata-ctl/src/check.rs index 3bf899ad2e..b579be1766 100644 --- a/src/tools/kata-ctl/src/check.rs +++ b/src/tools/kata-ctl/src/check.rs @@ -5,7 +5,7 @@ // Contains checks that are not architecture-specific -#[cfg(any(target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] use crate::types::KernelModule; use anyhow::{anyhow, Result}; @@ -17,7 +17,7 @@ use reqwest::header::{CONTENT_TYPE, USER_AGENT}; use serde::{Deserialize, Serialize}; use slog::{info, o}; -#[cfg(any(target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] use std::process::{Command, Stdio}; #[derive(Debug, Deserialize, Serialize, PartialEq)] @@ -84,7 +84,7 @@ pub fn check_cpu_flags( Ok(missing_flags) } -#[cfg(any(target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] pub fn check_cpu_attribs( cpu_info: &str, required_attribs: &'static [&'static str], @@ -236,7 +236,7 @@ pub fn check_official_releases() -> Result<()> { Ok(()) } -#[cfg(any(target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] pub fn check_kernel_module_loaded(kernel_module: &KernelModule) -> Result<(), String> { const MODPROBE_PARAMETERS_DRY_RUN: &str = "--dry-run"; const MODPROBE_PARAMETERS_FIRST_TIME: &str = "--first-time"; @@ -305,7 +305,7 @@ pub fn check_kernel_module_loaded(kernel_module: &KernelModule) -> Result<(), St #[cfg(test)] mod tests { use super::*; - #[cfg(any(target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] use crate::types::{KernelModule, KernelParam, KernelParamType}; use kata_sys_util::cpu::{get_cpu_flags, get_single_cpu_info}; use semver::Version; @@ -509,7 +509,7 @@ mod tests { assert!(!v.patch.to_string().is_empty()); } - #[cfg(any(target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] #[test] fn check_module_loaded() { #[allow(dead_code)] diff --git a/src/tools/kata-ctl/src/utils.rs b/src/tools/kata-ctl/src/utils.rs index f020a077e5..27183fbe4c 100644 --- a/src/tools/kata-ctl/src/utils.rs +++ b/src/tools/kata-ctl/src/utils.rs @@ -239,7 +239,7 @@ mod tests { assert!(res.is_ok()); } - #[cfg(any(target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] #[test] fn get_generic_cpu_details_system() { let res = get_generic_cpu_details(crate::check::PROC_CPUINFO); From a31c14517262730847f3253db88e6d55a279fa05 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 20:39:54 +0100 Subject: [PATCH 11/12] kata-ctl: useless-vec warning - Fix clippy::useless-vec warning Fixes: #7902 Signed-off-by: stevenhorsman --- src/tools/kata-ctl/src/ops/exec_ops.rs | 2 +- src/tools/kata-ctl/src/utils.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/kata-ctl/src/ops/exec_ops.rs b/src/tools/kata-ctl/src/ops/exec_ops.rs index f7ad0170cb..f14da80e06 100644 --- a/src/tools/kata-ctl/src/ops/exec_ops.rs +++ b/src/tools/kata-ctl/src/ops/exec_ops.rs @@ -123,7 +123,7 @@ impl EpollContext { } fn do_process_handler(&mut self) -> Result<()> { - let mut events = vec![epoll::Event::new(epoll::Events::empty(), 0); EPOLL_EVENTS_LEN]; + let mut events = [epoll::Event::new(epoll::Events::empty(), 0); EPOLL_EVENTS_LEN]; let epoll_raw_fd = self.epoll_raw_fd; let debug_console_sock = self.debug_console_sock.as_mut().unwrap(); diff --git a/src/tools/kata-ctl/src/utils.rs b/src/tools/kata-ctl/src/utils.rs index 27183fbe4c..9c4ef4d5a5 100644 --- a/src/tools/kata-ctl/src/utils.rs +++ b/src/tools/kata-ctl/src/utils.rs @@ -60,7 +60,7 @@ fn get_field_fn(line: &str, delimiter: &str, file_name: &str) -> Result } // Ref: https://www.freedesktop.org/software/systemd/man/os-release.html pub fn get_distro_details(os_release: &str, os_release_clr: &str) -> Result<(String, String)> { - let files = vec![os_release, os_release_clr]; + let files = [os_release, os_release_clr]; let mut name = String::new(); let mut version = String::new(); From a75fd5eb811b93f1bf5398b1dff07ad19b22d8af Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 21:16:31 +0100 Subject: [PATCH 12/12] runk: Fix rust unecessary mut error - Fix `error: variable does not need to be mutable` in rust 1.72 Fixes: #7902 Signed-off-by: stevenhorsman --- src/tools/runk/libcontainer/src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/runk/libcontainer/src/utils.rs b/src/tools/runk/libcontainer/src/utils.rs index b5e9d83770..ec1a71254a 100644 --- a/src/tools/runk/libcontainer/src/utils.rs +++ b/src/tools/runk/libcontainer/src/utils.rs @@ -36,7 +36,7 @@ pub fn create_dir_with_mode>(path: P, mode: Mode, recursive: bool /// If root in spec is a relative path, make it absolute. pub fn canonicalize_spec_root(spec: &mut Spec, bundle_canon: &Path) -> Result<()> { - let mut spec_root = spec + let spec_root = spec .root .as_mut() .ok_or_else(|| anyhow!("root config was not present in the spec file"))?;