From 0ef45a885a62f347e5ad32e7e5efae9c56ab531f Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Mon, 15 Apr 2024 18:43:00 +0100 Subject: [PATCH 1/2] create: Ignore first argument if it is "no-entrypoint" This makes crun-vm compatible with containerdisks that have such an entrypoint, which precludes the need to pass an empty "" argument to podman-run. Signed-off-by: Alberto Faria --- src/commands/create/custom_opts.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/commands/create/custom_opts.rs b/src/commands/create/custom_opts.rs index 79bc455..46e1296 100644 --- a/src/commands/create/custom_opts.rs +++ b/src/commands/create/custom_opts.rs @@ -67,14 +67,20 @@ pub struct CustomOptions { impl CustomOptions { pub fn from_spec(spec: &oci_spec::runtime::Spec, env: RuntimeEnv) -> Result { - let args = spec + let mut args: Vec<&String> = spec .process() .as_ref() .unwrap() .args() .iter() .flatten() - .filter(|arg| !arg.trim().is_empty()); + .collect(); + + if let Some(&first_arg) = args.first() { + if first_arg.trim().is_empty() || first_arg == "no-entrypoint" { + args.remove(0); + } + } // TODO: We currently assume that no entrypoint is given (either by being set by in the // container image or through --entrypoint). Must somehow find whether the first arg is the From 46628d817d696f8718d483bb5c4bab444c1b5a55 Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Mon, 15 Apr 2024 23:15:05 +0100 Subject: [PATCH 2/2] util/package-vm-image.sh: Set entrypoint to "no-entrypoint" Signed-off-by: Alberto Faria --- tests/env.sh | 3 +-- util/package-vm-image.sh | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/env.sh b/tests/env.sh index b13372e..fbcd1f4 100755 --- a/tests/env.sh +++ b/tests/env.sh @@ -237,8 +237,7 @@ start) --rm -dit \ -v "$temp_dir":/home/fedora/images:z \ -v "$repo_root/target":/home/fedora/target:z \ - "$env_image" \ - "" + "$env_image" # shellcheck disable=SC2317 __extra_cleanup() { diff --git a/util/package-vm-image.sh b/util/package-vm-image.sh index b614410..7ad0766 100755 --- a/util/package-vm-image.sh +++ b/util/package-vm-image.sh @@ -18,4 +18,5 @@ image_path_in_container=/disk/$( basename "${vm_image_file}" ) podman image build --file=- --tag="${container_image_tag}" / <