From 35619b45aa2ba212383d4890210e9298b38cb592 Mon Sep 17 00:00:00 2001 From: Tim Zhang Date: Fri, 20 May 2022 14:55:51 +0800 Subject: [PATCH] runk: merge oci-kata-agent into runk Merge two bins into one. Fixes: #4291 Signed-off-by: Tim Zhang --- src/agent/rustjail/src/container.rs | 13 +------------ src/tools/runk/Makefile | 22 ++-------------------- src/tools/runk/README.md | 8 ++------ src/tools/runk/src/main.rs | 7 +++++++ 4 files changed, 12 insertions(+), 38 deletions(-) diff --git a/src/agent/rustjail/src/container.rs b/src/agent/rustjail/src/container.rs index 37ffa091d2..88c058868a 100644 --- a/src/agent/rustjail/src/container.rs +++ b/src/agent/rustjail/src/container.rs @@ -78,9 +78,6 @@ const HOME_ENV_KEY: &str = "HOME"; const PIDNS_FD: &str = "PIDNS_FD"; const CONSOLE_SOCKET_FD: &str = "CONSOLE_SOCKET_FD"; -#[cfg(feature = "standard-oci-runtime")] -const OCI_AGENT_BINARY: &str = "oci-kata-agent"; - #[derive(Debug)] pub struct ContainerStatus { pre_status: ContainerState, @@ -951,15 +948,7 @@ impl BaseContainer for LinuxContainer { let _ = unistd::close(pid); }); - cfg_if::cfg_if! { - if #[cfg(feature = "standard-oci-runtime")] { - let exec_path = PathBuf::from(OCI_AGENT_BINARY); - } - else { - let exec_path = std::env::current_exe()?; - } - } - + let exec_path = std::env::current_exe()?; let mut child = std::process::Command::new(exec_path); #[allow(unused_mut)] diff --git a/src/tools/runk/Makefile b/src/tools/runk/Makefile index cfd795fb6c..580aa39a0d 100644 --- a/src/tools/runk/Makefile +++ b/src/tools/runk/Makefile @@ -8,30 +8,16 @@ include ../../../utils.mk TARGET = runk TARGET_PATH = target/$(TRIPLE)/$(BUILD_TYPE)/$(TARGET) -AGENT_TARGET = oci-kata-agent -AGENT_TARGET_PATH = target/$(TRIPLE)/$(BUILD_TYPE)/$(AGENT_TARGET) -AGENT_SOURCE_PATH = ../../agent - # BINDIR is a directory for installing executable programs BINDIR := /usr/local/bin .DEFAULT_GOAL := default default: build -build: build-agent build-runk - -build-agent: - make -C $(AGENT_SOURCE_PATH) STANDARD_OCI_RUNTIME=yes - -build-runk: +build: @RUSTFLAGS="$(EXTRA_RUSTFLAGS) --deny warnings" cargo build --target $(TRIPLE) --$(BUILD_TYPE) -install: install-agent install-runk - -install-agent: - install -D $(AGENT_SOURCE_PATH)/$(AGENT_TARGET_PATH) $(BINDIR)/$(AGENT_TARGET) - -install-runk: +install: install -D $(TARGET_PATH) $(BINDIR)/$(TARGET) clean: @@ -47,11 +33,7 @@ check: standard_rust_check .PHONY: \ build \ - build-agent \ - build-runk \ install \ - install-agent \ - install-runk \ clean \ clippy \ format \ diff --git a/src/tools/runk/README.md b/src/tools/runk/README.md index 41663625a6..9d18e27bce 100644 --- a/src/tools/runk/README.md +++ b/src/tools/runk/README.md @@ -60,18 +60,14 @@ are welcome. Regarding features compared to `runc`, see the `Status of runk` section in the [issue](https://github.com/kata-containers/kata-containers/issues/2784). ## Building - -`runk` uses the modified the `kata-agent` binary, `oci-kata-agent`, which is an agent to be called from `runk`. -Therefore, you also need to build the `oci-kata-agent` to run `runk`. - -You can build both `runk` and `oci-kata-agent` as follows. +You can build `runk` as follows. ```bash $ cd runk $ make ``` -To install `runk` and `oci-kata-agent` into default directory for install executable program (`/usr/local/bin`): +To install `runk` into default directory for install executable program (`/usr/local/bin`): ```bash $ sudo make install diff --git a/src/tools/runk/src/main.rs b/src/tools/runk/src/main.rs index c73a22b093..8f464f4383 100644 --- a/src/tools/runk/src/main.rs +++ b/src/tools/runk/src/main.rs @@ -28,6 +28,7 @@ enum SubCommand { Common(CommonCmd), #[clap(flatten)] Custom(CustomCmd), + Init {}, } // Copy from https://github.com/containers/youki/blob/v0.0.3/crates/liboci-cli/src/lib.rs#L38-L44 @@ -84,6 +85,7 @@ async fn cmd_run(subcmd: SubCommand, root_path: &Path, logger: &Logger) -> Resul SubCommand::Custom(cmd) => match cmd { CustomCmd::Kill(kill) => commands::kill::run(kill, root_path, logger), }, + _ => unreachable!(), } } @@ -113,6 +115,11 @@ fn setup_logger( async fn real_main() -> Result<()> { let cli = Cli::parse(); + if let SubCommand::Init {} = cli.subcmd { + rustjail::container::init_child(); + exit(0); + } + let root_path = if let Some(path) = cli.global.root { path } else {