From 495b9825e5a5fb92ce4df164b694492c670819ad Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 5 Sep 2023 10:01:59 +0100 Subject: [PATCH 01/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 4d06f0062..d9815f529 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 3416e104b869a7f88f226100fca4c3648fb211bc Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 5 Sep 2023 12:01:12 +0100 Subject: [PATCH 02/12] agent: config: Fix useles-vec warning Fix clippy::useless-vec warning Fixes: #7902 Signed-off-by: stevenhorsman --- src/agent/src/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/agent/src/config.rs b/src/agent/src/config.rs index c454f642e..4f2f72bbb 100644 --- a/src/agent/src/config.rs +++ b/src/agent/src/config.rs @@ -1696,7 +1696,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() @@ -1744,7 +1744,7 @@ Caused by: // Should be from agent config assert_eq!( config.endpoints.allowed, - vec!["CreateContainer".to_string(), "StartContainer".to_string()] + ["CreateContainer".to_string(), "StartContainer".to_string()] .iter() .cloned() .collect() From d1d49675a0243910905feb715279931fd743f0f3 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 5 Sep 2023 13:24:21 +0100 Subject: [PATCH 03/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 4f2f72bbb..068955a54 100644 --- a/src/agent/src/config.rs +++ b/src/agent/src/config.rs @@ -253,6 +253,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 91916ed118313433bc19d6bbf244e6a212430e4d Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 5 Sep 2023 14:10:50 +0100 Subject: [PATCH 04/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 41200d010..dff3aefc3 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 6e508ae3220c2f80868d70698cd327e01f757906 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 16:49:35 +0100 Subject: [PATCH 05/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 30758f351..ba0f62c13 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 cb7cc1d708f54cc4017d048fe01f1c25a9d2c032 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 17:38:47 +0100 Subject: [PATCH 06/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 f0ea125da..85bd645a9 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 48465d0547ab16868c79bbf9697e5b265654756d Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 18:09:54 +0100 Subject: [PATCH 07/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 792c4fbb5..a9a4c7500 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 ded162bd0..d0e361b24 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 fb12b3614..ea769b2dc 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 85bd645a9..6789d6d37 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 0a33d27c30bd1018fbb4e9ef6ebb0acbbc34283f Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 19:26:14 +0100 Subject: [PATCH 08/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 bb21b8d62..ab2d95ed2 100644 --- a/src/tools/agent-ctl/src/client.rs +++ b/src/tools/agent-ctl/src/client.rs @@ -1247,6 +1247,7 @@ fn agent_cmd_container_start( Ok(()) } +#[allow(clippy::redundant_closure_call)] fn agent_cmd_sandbox_get_guest_details( ctx: &Context, client: &AgentServiceClient, @@ -2086,6 +2087,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 c0668ef7eb2e1530b3ab35f4072c1c293e420d77 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 19:59:59 +0100 Subject: [PATCH 09/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 3bf899ad2..b579be176 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 f020a077e..27183fbe4 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 f7fd2c1dfcc0534af98d8841bdb6192307e50ce0 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 20:39:54 +0100 Subject: [PATCH 10/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 f7ad0170c..f14da80e0 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 27183fbe4..9c4ef4d5a 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 9ebb91f94c3f239b8a3a61a0259fc1219d48eeb1 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Mon, 11 Sep 2023 21:16:31 +0100 Subject: [PATCH 11/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 b5e9d8377..ec1a71254 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"))?; From 36431de30f5eab565ef2a2f87d1e08411fe178cb Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Thu, 31 Aug 2023 17:06:31 +0100 Subject: [PATCH 12/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 d7b973176..2be645680 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"