From 798390fb62a9529d8c4a51d74ce5dce0c8c119a1 Mon Sep 17 00:00:00 2001 From: Amulyam24 Date: Wed, 6 Dec 2023 14:30:49 +0530 Subject: [PATCH] Add static checks for ppc64le --- .github/workflows/static-checks.yaml | 1 + src/agent/src/random.rs | 6 ++++++ src/agent/src/rpc.rs | 12 ++++++++++-- src/dragonball/Makefile | 4 ++-- .../cmd/kata-runtime/kata-env_ppc64le_test.go | 2 +- src/tools/agent-ctl/Makefile | 2 +- src/tools/kata-ctl/Cargo.toml | 4 ++-- src/tools/kata-ctl/Makefile | 10 ++++++++++ src/tools/kata-ctl/src/arch/mod.rs | 10 +++++----- .../src/arch/{powerpc64le => powerpc64}/mod.rs | 2 +- src/tools/runk/Makefile | 2 +- src/tools/trace-forwarder/Makefile | 2 +- 12 files changed, 41 insertions(+), 16 deletions(-) rename src/tools/kata-ctl/src/arch/{powerpc64le => powerpc64}/mod.rs (96%) diff --git a/.github/workflows/static-checks.yaml b/.github/workflows/static-checks.yaml index 1687af9bb775..8278066d9509 100644 --- a/.github/workflows/static-checks.yaml +++ b/.github/workflows/static-checks.yaml @@ -78,6 +78,7 @@ jobs: - "ubuntu-20.04" - "arm-no-k8s" - "s390x" + - "ppc64le" runs-on: ${{ matrix.instance }} steps: - name: Adjust a permission for repo diff --git a/src/agent/src/random.rs b/src/agent/src/random.rs index f97f0f0334b4..6e1e87c3d447 100644 --- a/src/agent/src/random.rs +++ b/src/agent/src/random.rs @@ -12,7 +12,13 @@ use std::os::unix::io::{AsRawFd, FromRawFd}; use tracing::instrument; pub const RNGDEV: &str = "/dev/random"; +#[cfg(target_arch = "powerpc64")] +pub const RNDADDTOENTCNT: libc::c_uint = 0x80045201; +#[cfg(target_arch = "powerpc64")] +pub const RNDRESEEDCRNG: libc::c_int = 0x20005207; +#[cfg(not(target_arch = "powerpc64"))] pub const RNDADDTOENTCNT: libc::c_int = 0x40045201; +#[cfg(not(target_arch = "powerpc64"))] pub const RNDRESEEDCRNG: libc::c_int = 0x5207; // Handle the differing ioctl(2) request types for different targets diff --git a/src/agent/src/rpc.rs b/src/agent/src/rpc.rs index 955588625ce7..b9c2803c8b36 100644 --- a/src/agent/src/rpc.rs +++ b/src/agent/src/rpc.rs @@ -2718,8 +2718,16 @@ OtherField:other fs::write(mount_dir.path().join("file.dat"), "foobar").unwrap(); stats = get_volume_capacity_stats(mount_dir.path().to_str().unwrap()).unwrap(); - assert_eq!(stats.used, 4 * 1024); - assert_eq!(stats.available, available - 4 * 1024); + let size = get_block_size(mount_dir.path().to_str().unwrap()).unwrap(); + + assert_eq!(stats.used, size); + assert_eq!(stats.available, available - size); + } + + fn get_block_size(path: &str) -> Result { + let stat = statfs::statfs(path)?; + let block_size = stat.block_size() as u64; + Ok(block_size) } #[tokio::test] diff --git a/src/dragonball/Makefile b/src/dragonball/Makefile index 4df695072b5f..40bb7f915ba5 100644 --- a/src/dragonball/Makefile +++ b/src/dragonball/Makefile @@ -6,9 +6,9 @@ include ../../utils.mk PROJECT_DIRS := $(shell find . -name Cargo.toml -printf '%h\n' | sort -u) -ifeq ($(ARCH), s390x) +ifeq ($(ARCH), $(filter $(ARCH), s390x ppc64le)) default build check test clippy vendor: - @echo "s390x not support currently" + @echo "$(ARCH) is not support currently" exit 0 else diff --git a/src/runtime/cmd/kata-runtime/kata-env_ppc64le_test.go b/src/runtime/cmd/kata-runtime/kata-env_ppc64le_test.go index a794ba338c31..16415bfcbdd4 100644 --- a/src/runtime/cmd/kata-runtime/kata-env_ppc64le_test.go +++ b/src/runtime/cmd/kata-runtime/kata-env_ppc64le_test.go @@ -9,7 +9,7 @@ import "testing" func getExpectedHostDetails(tmpdir string) (HostInfo, error) { expectedVendor := "" - expectedModel := "POWER8" + expectedModel := "POWER9" expectedVMContainerCapable := true return genericGetExpectedHostDetails(tmpdir, expectedVendor, expectedModel, expectedVMContainerCapable) } diff --git a/src/tools/agent-ctl/Makefile b/src/tools/agent-ctl/Makefile index fe56fa098241..a49f88e6b01b 100644 --- a/src/tools/agent-ctl/Makefile +++ b/src/tools/agent-ctl/Makefile @@ -7,7 +7,7 @@ include ../../../utils.mk ifeq ($(ARCH), ppc64le) override ARCH = powerpc64le - endif +endif .DEFAULT_GOAL := default default: build diff --git a/src/tools/kata-ctl/Cargo.toml b/src/tools/kata-ctl/Cargo.toml index 7d4661693c9b..406101eeaf58 100644 --- a/src/tools/kata-ctl/Cargo.toml +++ b/src/tools/kata-ctl/Cargo.toml @@ -59,10 +59,10 @@ csv = "1.2" serde_with = "2.3" chrono = { version = "0.4", features = ["serde"]} -[target.'cfg(target_arch = "s390x")'.dependencies] +[target.'cfg(target_arch = "powerpc64")'.dependencies] reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "native-tls"] } -[target.'cfg(not(target_arch = "s390x"))'.dependencies] +[target.'cfg(not(target_arch = "powerpc64"))'.dependencies] reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "rustls-tls"] } [dev-dependencies] diff --git a/src/tools/kata-ctl/Makefile b/src/tools/kata-ctl/Makefile index 546f0783adfd..28c58b219d2a 100644 --- a/src/tools/kata-ctl/Makefile +++ b/src/tools/kata-ctl/Makefile @@ -5,6 +5,10 @@ include ../../../utils.mk +ifeq ($(ARCH), ppc64le) + override ARCH = powerpc64le +endif + PROJECT_NAME = Kata Containers PROJECT_URL = https://github.com/kata-containers PROJECT_COMPONENT = kata-ctl @@ -21,6 +25,12 @@ export COMMIT := $(if $(shell git status --porcelain --untracked-files=no 2>/dev # Exported to allow cargo to see it export KATA_CTL_VERSION := $(if $(COMMIT),$(VERSION)-$(COMMIT),$(VERSION)) +ifeq ($(ARCH), ppc64le) +default build check test vendor: + @echo "Building kata-ctl on $(ARCH) is currently being skipped" + exit 0 +else + GENERATED_CODE = src/ops/version.rs GENERATED_REPLACEMENTS= \ diff --git a/src/tools/kata-ctl/src/arch/mod.rs b/src/tools/kata-ctl/src/arch/mod.rs index b0010955d699..aa6a527ffcc4 100644 --- a/src/tools/kata-ctl/src/arch/mod.rs +++ b/src/tools/kata-ctl/src/arch/mod.rs @@ -8,10 +8,10 @@ pub mod aarch64; #[cfg(target_arch = "aarch64")] pub use aarch64 as arch_specific; -#[cfg(target_arch = "powerpc64le")] -pub mod powerpc64le; -#[cfg(target_arch = "powerpc64le")] -pub use powerpc64le as arch_specific; +#[cfg(target_arch = "powerpc64")] +pub mod powerpc64; +#[cfg(target_arch = "powerpc64")] +pub use powerpc64 as arch_specific; #[cfg(target_arch = "s390x")] pub mod s390x; @@ -25,7 +25,7 @@ pub use x86_64 as arch_specific; #[cfg(not(any( target_arch = "aarch64", - target_arch = "powerpc64le", + target_arch = "powerpc64", target_arch = "s390x", target_arch = "x86_64" )))] diff --git a/src/tools/kata-ctl/src/arch/powerpc64le/mod.rs b/src/tools/kata-ctl/src/arch/powerpc64/mod.rs similarity index 96% rename from src/tools/kata-ctl/src/arch/powerpc64le/mod.rs rename to src/tools/kata-ctl/src/arch/powerpc64/mod.rs index bf5822c041d6..f47e436d0690 100644 --- a/src/tools/kata-ctl/src/arch/powerpc64le/mod.rs +++ b/src/tools/kata-ctl/src/arch/powerpc64/mod.rs @@ -4,7 +4,7 @@ // use crate::types::*; -#[cfg(target_arch = "powerpc64le")] +#[cfg(target_arch = "powerpc64")] pub use arch_specific::*; mod arch_specific { diff --git a/src/tools/runk/Makefile b/src/tools/runk/Makefile index cd9a24a8b178..18695567971a 100644 --- a/src/tools/runk/Makefile +++ b/src/tools/runk/Makefile @@ -10,7 +10,7 @@ include ../../../utils.mk ifeq ($(ARCH), ppc64le) override ARCH = powerpc64le - endif +endif TARGET = runk TARGET_PATH = target/$(TRIPLE)/$(BUILD_TYPE)/$(TARGET) diff --git a/src/tools/trace-forwarder/Makefile b/src/tools/trace-forwarder/Makefile index 3bdd5d53a52c..5d9f718561c4 100644 --- a/src/tools/trace-forwarder/Makefile +++ b/src/tools/trace-forwarder/Makefile @@ -7,7 +7,7 @@ include ../../../utils.mk ifeq ($(ARCH), ppc64le) override ARCH = powerpc64le - endif +endif .DEFAULT_GOAL := default default: build