Skip to content

Commit

Permalink
Merge pull request #55 from mtjhrc/fix-aarch64
Browse files Browse the repository at this point in the history
Fix aarch64 i8/u8 mismatch and improve pipeline
  • Loading branch information
slp authored Nov 29, 2023
2 parents 101a402 + cbf34eb commit 27a6dfb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion src/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u32>() {
Err(_) => {
println!("Invalid value for \"cpus\"");
Expand Down
7 changes: 4 additions & 3 deletions src/start.rs
Original file line number Diff line number Diff line change
@@ -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")]
Expand Down Expand Up @@ -91,7 +92,7 @@ unsafe fn exec_vm(vmcfg: &VmConfig, rootfs: &str, cmd: Option<&str>, args: Vec<C
let map = format!("{}:{}", host_port, guest_port);
ports.push(CString::new(map).unwrap());
}
let mut ps: Vec<*const i8> = Vec::new();
let mut ps: Vec<*const c_char> = Vec::new();
for port in ports.iter() {
ps.push(port.as_ptr());
}
Expand All @@ -113,10 +114,10 @@ unsafe fn exec_vm(vmcfg: &VmConfig, rootfs: &str, cmd: Option<&str>, args: Vec<C

let hostname = CString::new(format!("HOSTNAME={}", vmcfg.name)).unwrap();
let home = CString::new("HOME=/root").unwrap();
let env: [*const i8; 3] = [hostname.as_ptr(), home.as_ptr(), std::ptr::null()];
let env: [*const c_char; 3] = [hostname.as_ptr(), home.as_ptr(), std::ptr::null()];

if let Some(cmd) = cmd {
let mut argv: Vec<*const i8> = Vec::new();
let mut argv: Vec<*const c_char> = Vec::new();
for a in args.iter() {
argv.push(a.as_ptr());
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub fn mount_container(cfg: &KrunvmConfig, vmcfg: &VmConfig) -> Result<String, s
let rootfs = std::str::from_utf8(&output.stdout).unwrap().trim();

#[cfg(target_os = "macos")]
fix_root_mode(&rootfs);
fix_root_mode(rootfs);

Ok(rootfs.to_string())
}
Expand Down

0 comments on commit 27a6dfb

Please sign in to comment.