@@ -36,8 +36,10 @@ export GO_CACHE_VOLUME_NAME?=gocache
36
36
host_arch =$(shell uname -m)
37
37
ifeq ($(host_arch ) ,x86_64)
38
38
kernel_sha256sum="ea5e7d5cf494a8c4ba043259812fc018b44880d70bcbbfc4d57d2760631b1cd6"
39
+ kernel_config_pattern=x86
39
40
else ifeq ($(host_arch),aarch64)
40
41
kernel_sha256sum="e2d7c3d6cc123de9e6052d1f434ca7b47635a1f630d63f7fcc1b7164958375e4"
42
+ kernel_config_pattern=arm64
41
43
else
42
44
$(error "$(host_arch) is not supported by Firecracker")
43
45
endif
@@ -48,6 +50,18 @@ FIRECRACKER_BIN=$(FIRECRACKER_DIR)/build/cargo_target/$(FIRECRACKER_TARGET)/rele
48
50
FIRECRACKER_BUILDER_NAME? =firecracker-builder
49
51
CARGO_CACHE_VOLUME_NAME? =cargocache
50
52
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
+
51
65
RUNC_DIR =$(SUBMODULES ) /runc
52
66
RUNC_BIN =$(RUNC_DIR ) /runc
53
67
RUNC_BUILDER_NAME? =runc-builder
@@ -313,6 +327,17 @@ $(FIRECRACKER_BIN): $(FIRECRACKER_DIR)/Cargo.toml
313
327
firecracker-clean :
314
328
- $(FIRECRACKER_DIR ) /tools/devtool distclean
315
329
- 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 )
316
341
317
342
# #########################
318
343
# RunC submodule
0 commit comments