From 6b6ea504583b944902d0a3d11260a3e8e94413fa Mon Sep 17 00:00:00 2001 From: Matej Hrica Date: Thu, 2 Nov 2023 11:10:55 +0100 Subject: [PATCH 1/4] Fix compilation on aarch64 due to i8/u8 mismatch Signed-off-by: Matej Hrica --- src/start.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/start.rs b/src/start.rs index 7dc5f02..05375f3 100644 --- a/src/start.rs +++ b/src/start.rs @@ -1,6 +1,7 @@ // Copyright 2021 Red Hat, Inc. // SPDX-License-Identifier: Apache-2.0 +use libc::c_char; use std::ffi::CString; use std::fs::File; #[cfg(target_os = "linux")] @@ -91,7 +92,7 @@ unsafe fn exec_vm(vmcfg: &VmConfig, rootfs: &str, cmd: Option<&str>, args: Vec = Vec::new(); + let mut ps: Vec<*const c_char> = Vec::new(); for port in ports.iter() { ps.push(port.as_ptr()); } @@ -113,10 +114,10 @@ unsafe fn exec_vm(vmcfg: &VmConfig, rootfs: &str, cmd: Option<&str>, args: Vec = Vec::new(); + let mut argv: Vec<*const c_char> = Vec::new(); for a in args.iter() { argv.push(a.as_ptr()); } From ced22ac583f666b25fa4b9935d9386a160d0e6ae Mon Sep 17 00:00:00 2001 From: Matej Hrica Date: Thu, 2 Nov 2023 11:21:08 +0100 Subject: [PATCH 2/4] Run cargo clippy more times with each supported platform separately This seems to catch more problems, such as the u8/i8 mismatch on aarch64 platforms. Signed-off-by: Matej Hrica --- .github/workflows/code_quality.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index 89739b3..80f6ad1 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -26,8 +26,17 @@ jobs: - name: Install asciidoctor run: sudo apt-get install -y asciidoctor + - name: Install additional Rust rust targets + run: rustup target add aarch64-unknown-linux-gnu aarch64-apple-darwin + - name: Formatting (rustfmt) run: cargo fmt -- --check - - name: Clippy (all features) - run: cargo clippy --all-targets --all-features + - name: Clippy x86_64-unknown-linux-gnu (all features) + run: cargo clippy --all-features --target x86_64-unknown-linux-gnu + + - name: Clippy aarch64-unknown-linux-gnu (all features) + run: cargo clippy --all-features --target aarch64-unknown-linux-gnu + + - name: Clippy aarch64-apple-darwin (all features) + run: cargo clippy --all-features --target aarch64-apple-darwin From 38e1e5cffc9bb8f94022c4d7a3f913190d54dc78 Mon Sep 17 00:00:00 2001 From: Matej Hrica Date: Thu, 2 Nov 2023 11:41:10 +0100 Subject: [PATCH 3/4] Fix compilation for macOS target We need #[allow(unused_mut)], to disable warnings on other targets. Signed-off-by: Matej Hrica --- src/create.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/create.rs b/src/create.rs index 3b88f7e..17e9cd4 100644 --- a/src/create.rs +++ b/src/create.rs @@ -67,7 +67,8 @@ fn export_container_config( } pub fn create(cfg: &mut KrunvmConfig, matches: &ArgMatches) { - let cpus = match matches.value_of("cpus") { + #[allow(unused_mut)] + let mut cpus = match matches.value_of("cpus") { Some(c) => match c.parse::() { Err(_) => { println!("Invalid value for \"cpus\""); From cbf34eb064526cfa412265c6caa1738ff55d2273 Mon Sep 17 00:00:00 2001 From: Matej Hrica Date: Thu, 2 Nov 2023 11:42:56 +0100 Subject: [PATCH 4/4] Resolve clippy warning for macOS target Signed-off-by: Matej Hrica --- src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index 46bd2e4..220720e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -198,7 +198,7 @@ pub fn mount_container(cfg: &KrunvmConfig, vmcfg: &VmConfig) -> Result