mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
runk: merge oci-kata-agent into runk
Merge two bins into one. Fixes: #4291 Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
parent
856c8e81f1
commit
35619b45aa
@ -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)]
|
||||
|
@ -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 \
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user