From 5c6c4f9d26e7eb44cafaa5181622e1424f0d5844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Fr=C3=A9con?= Date: Sat, 6 Apr 2024 19:04:51 +0200 Subject: [PATCH] Add support for other podman runtimes While the podman runtime is still enforced, the script now supports several other runtimes. The KRUNVM_RUNNER_RUNTIME variable should contain the word podman, followed by the plus sign, followed by the runtime to use, e.g. podman+krun will pass the value of krun to the --runtime option of podman create/run. --- lib/microvm.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/microvm.sh b/lib/microvm.sh index 30f23fe..15b8b77 100644 --- a/lib/microvm.sh +++ b/lib/microvm.sh @@ -16,6 +16,12 @@ run_krunvm() { buildah unshare krunvm "$@" } +_podman_runtime() { + _runtime=${KRUNVM_RUNNER_RUNTIME#podman+} + [ -z "$_runtime" ] && _runtime="krun" + printf %s\\n "$_runtime" +} + # Automatically select a microVM runtime based on the available commands. Set # the KRUNVM_RUNNER_RUNTIME variable. @@ -48,7 +54,7 @@ microvm_runtime() { case "$KRUNVM_RUNNER_RUNTIME" in podman*) check_command podman - check_command krun + check_command "$(_podman_runtime)" ;; krunvm) check_command krunvm @@ -143,7 +149,7 @@ microvm_run() { case "$KRUNVM_RUNNER_RUNTIME" in podman*) set -- \ - --runtime "krun" \ + --runtime "$(_podman_runtime)" \ --rm \ --tty \ --name "$KRUNVM_RUNNER_NAME" \