From 56b8ad995b843b2bf3813ffb879fe637950fb3bc Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Wed, 10 Jun 2020 11:21:48 +0100 Subject: [PATCH 1/2] build: Fold long clean line Folded the overly long clean rule across multiple lines. Signed-off-by: James O. D. Hunt --- src/runtime/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/runtime/Makefile b/src/runtime/Makefile index b496ee906..ea81aeef2 100644 --- a/src/runtime/Makefile +++ b/src/runtime/Makefile @@ -705,7 +705,13 @@ install-completions: $(QUIET_INST)install --mode 0644 -D $(BASH_COMPLETIONS) $(DESTDIR)/$(BASH_COMPLETIONSDIR)/$(notdir $(BASH_COMPLETIONS)); clean: - $(QUIET_CLEAN)rm -f $(TARGET) $(SHIMV2) $(NETMON_TARGET) $(CONFIGS) $(GENERATED_FILES) .git-commit .git-commit.tmp + $(QUIET_CLEAN)rm -f \ + $(CONFIGS) \ + $(GENERATED_FILES) \ + $(NETMON_TARGET) \ + $(SHIMV2) \ + $(TARGET) \ + .git-commit .git-commit.tmp show-usage: show-header @printf "• Overview:\n" From f3a37bc67afcf50cd8765048343e92e6ccbf1082 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Wed, 10 Jun 2020 11:24:46 +0100 Subject: [PATCH 2/2] shimv2: Add a "--version" cli option All components should support a `--version` option to allow clear identification of the version of the component being used. Note that the build changes are required to allow the shim binary to access the golang code generated by the build (such as the `version` variable). Fixes: #307. Signed-off-by: James O. D. Hunt --- src/runtime/Makefile | 5 ++++- src/runtime/cli/containerd-shim-kata-v2/main.go | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/runtime/Makefile b/src/runtime/Makefile index ea81aeef2..819833e03 100644 --- a/src/runtime/Makefile +++ b/src/runtime/Makefile @@ -553,14 +553,16 @@ define MAKE_KERNEL_VIRTIOFS_NAME $(if $(findstring uncompressed,$1),vmlinux-virtiofs.container,vmlinuz-virtiofs.container) endef +GENERATED_CONFIG = $(abspath $(CLI_DIR)/config-generated.go) -GENERATED_FILES += $(CLI_DIR)/config-generated.go +GENERATED_FILES += $(GENERATED_CONFIG) GENERATED_FILES += pkg/katautils/config-settings.go $(TARGET_OUTPUT): $(SOURCES) $(GENERATED_FILES) $(MAKEFILE_LIST) | show-summary $(QUIET_BUILD)(cd $(CLI_DIR) && go build $(KATA_LDFLAGS) $(BUILDFLAGS) -o $@ .) $(SHIMV2_OUTPUT): $(SOURCES) $(GENERATED_FILES) $(MAKEFILE_LIST) + $(QUIET_BUILD)(cd $(SHIMV2_DIR)/ && ln -fs $(GENERATED_CONFIG)) $(QUIET_BUILD)(cd $(SHIMV2_DIR)/ && go build $(KATA_LDFLAGS) $(BUILDFLAGS) -o $@ .) .PHONY: \ @@ -710,6 +712,7 @@ clean: $(GENERATED_FILES) \ $(NETMON_TARGET) \ $(SHIMV2) \ + $(SHIMV2_DIR)/$(notdir $(GENERATED_CONFIG)) \ $(TARGET) \ .git-commit .git-commit.tmp diff --git a/src/runtime/cli/containerd-shim-kata-v2/main.go b/src/runtime/cli/containerd-shim-kata-v2/main.go index b04412d1d..7ffa0dff6 100644 --- a/src/runtime/cli/containerd-shim-kata-v2/main.go +++ b/src/runtime/cli/containerd-shim-kata-v2/main.go @@ -6,15 +6,26 @@ package main import ( + "fmt" + "os" + "github.com/containerd/containerd/runtime/v2/shim" "github.com/kata-containers/kata-containers/src/runtime/containerd-shim-v2" ) +const shim_id = "io.containerd.kata.v2" + func shimConfig(config *shim.Config) { config.NoReaper = true config.NoSubreaper = true } func main() { - shim.Run("io.containerd.kata.v2", containerdshim.New, shimConfig) + + if len(os.Args) == 2 && os.Args[1] == "--version" { + fmt.Printf("%s containerd shim: id: %q, version: %s, commit: %v\n", project, shim_id, version, commit) + os.Exit(0) + } + + shim.Run(shim_id, containerdshim.New, shimConfig) }