Skip to content

Commit f6100fd

Browse files
committed
Add make targets for linux kernel
Firecracker-containerd requires a linux kerenl which is provided precompiled by default. For most use-cases, this is acceptable however it prevents us from enabling additional features (e.g. FUSE for remote snapshotters) and from updating kernel versions in a timely manner. This change adds optional `make kernel` and `make install-kernel` targets which compile a 4.14 kernel by default with FUSE enabled. 5.10 can be compiled instead with `KERNEL_VERSION=5.10 make install-kernel`. The `install-kernel` target overwrites any previously installed kernel (either the default pre-built or a previous `make install-kernel`) Signed-off-by: Kern Walster <[email protected]>
1 parent dada9a4 commit f6100fd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ export GO_CACHE_VOLUME_NAME?=gocache
3636
host_arch=$(shell uname -m)
3737
ifeq ($(host_arch),x86_64)
3838
kernel_sha256sum="ea5e7d5cf494a8c4ba043259812fc018b44880d70bcbbfc4d57d2760631b1cd6"
39+
kernel_config_pattern=x86
3940
else ifeq ($(host_arch),aarch64)
4041
kernel_sha256sum="e2d7c3d6cc123de9e6052d1f434ca7b47635a1f630d63f7fcc1b7164958375e4"
42+
kernel_config_pattern=arm64
4143
else
4244
$(error "$(host_arch) is not supported by Firecracker")
4345
endif
@@ -48,6 +50,18 @@ FIRECRACKER_BIN=$(FIRECRACKER_DIR)/build/cargo_target/$(FIRECRACKER_TARGET)/rele
4850
FIRECRACKER_BUILDER_NAME?=firecracker-builder
4951
CARGO_CACHE_VOLUME_NAME?=cargocache
5052

53+
KERNEL_VERSIONS=4.14 5.10
54+
KERNEL_VERSION?=4.14
55+
ifeq ($(filter $(KERNEL_VERSION),$(KERNEL_VERSIONS)),)
56+
$(error "Kernel version $(KERNEL_VERSION) is not supported. Supported versions are $(KERNEL_VERSIONS)")
57+
endif
58+
59+
KERNEL_CONFIG=tools/kernel-configs/microvm-kernel-$(host_arch)-$(KERNEL_VERSION).config
60+
# Copied from https://github.com/firecracker-microvm/firecracker/blob/v1.0.0/tools/devtool#L2015
61+
# This allows us to specify a kernel without the patch version, but still get the correct build path to reference the kernel binary
62+
KERNEL_FULL_VERSION=$(shell cat "$(KERNEL_CONFIG)" | grep -Po "^\# Linux\/$(kernel_config_pattern) (([0-9]+.){2}[0-9]+)" | cut -d ' ' -f 3)
63+
KERNEL_BIN=$(FIRECRACKER_DIR)/build/kernel/linux-$(KERNEL_FULL_VERSION)/vmlinux-$(KERNEL_FULL_VERSION)-$(host_arch).bin
64+
5165
RUNC_DIR=$(SUBMODULES)/runc
5266
RUNC_BIN=$(RUNC_DIR)/runc
5367
RUNC_BUILDER_NAME?=runc-builder
@@ -313,6 +327,17 @@ $(FIRECRACKER_BIN): $(FIRECRACKER_DIR)/Cargo.toml
313327
firecracker-clean:
314328
- $(FIRECRACKER_DIR)/tools/devtool distclean
315329
- rm $(FIRECRACKER_BIN)
330+
- rm $(KERNEL_BIN)
331+
332+
.PHONY: kernel
333+
kernel: $(KERNEL_BIN)
334+
335+
$(KERNEL_BIN): $(KERNEL_CONFIG)
336+
$(FIRECRACKER_DIR)/tools/devtool build_kernel --config $(KERNEL_CONFIG)
337+
338+
.PHONY: install-kernel
339+
install-kernel: $(KERNEL_BIN)
340+
install -D -o root -g root -m400 $(KERNEL_BIN) $(DEFAULT_VMLINUX_INSTALLPATH)
316341

317342
##########################
318343
# RunC submodule

0 commit comments

Comments
 (0)