From 66e795d03d4a670685b85736d63ebde150701033 Mon Sep 17 00:00:00 2001 From: RouxAntoine Date: Sat, 6 Jan 2024 15:44:14 +0100 Subject: [PATCH] One little whitespace gets its very own commit! Oh, life is so erratic! Signed-off-by: RouxAntoine --- cmd/main.go | 2 +- rootfs-kernel/Makefile | 6 ++++- rootfs-kernel/kernel.sh | 56 ++++++++++++++++++++--------------------- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 73c3e99..af7d704 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -93,7 +93,7 @@ func setupEnv() int { cfg := firecracker.Config{ SocketPath: socketPath, - KernelImagePath: "./out/vmlinux-5.10.204", + KernelImagePath: "./out/vmlinux", LogPath: "./out/firecracker.log", LogLevel: "Debug", KernelArgs: "console=ttyS0 reboot=k panic=1 pci=off", diff --git a/rootfs-kernel/Makefile b/rootfs-kernel/Makefile index 71cce6e..aa82d73 100644 --- a/rootfs-kernel/Makefile +++ b/rootfs-kernel/Makefile @@ -11,11 +11,15 @@ use-ubuntu: ../out/ubuntu-22.04.ext4 ../out/ubuntu-22.04.id_rsa ln -fs $< ../out/rootfs.ext4 kernel: ../out/vmlinux-5.10.204 - @echo "linux kernel retrieve" + ln -fs $< ../out/vmlinux ../out/vmlinux-5.10.204: wget -O $@ https://s3.amazonaws.com/spec.ccfc.min/firecracker-ci/v1.7/$(ARCH)/vmlinux-5.10.204 +CONFIG_FILE=$(wildcard ./kernel-config/*.config) +../out/vmvmlinux-custom: ./kernel.sh $(CONFIG_FILE) + bash ./kernel.sh + ../out/arch-rootfs.ext4: ./arch-rootfs.sh bash ./arch-rootfs.sh diff --git a/rootfs-kernel/kernel.sh b/rootfs-kernel/kernel.sh index d478053..2dbd9bc 100755 --- a/rootfs-kernel/kernel.sh +++ b/rootfs-kernel/kernel.sh @@ -2,46 +2,46 @@ # inspired by https://github.com/oraoto/archlinux-firecracker/blob/master/scripts/build-arch-kernel.sh -KERNEL_VERSION=5.11.2 +set -ex -mkdir -p build - -cd build +KERNEL_VERSION=v5.11 +WD=../out ## Install build tools # pacman -Syu base-devel bc pahole --ignore linux-firmware ## Get kernel source -curl -o linux.tar.xz "https://mirrors.tuna.tsinghua.edu.cn/kernel/v5.x/linux-$KERNEL_VERSION.tar.xz" -tar xf linux.tar.xz -cd linux-$KERNEL_VERSION/ +git clone https://github.com/torvalds/linux.git "$WD"/linux +git checkout $KERNEL_VERSION ## Get Archlinux kernel config -curl -o .config https://git.archlinux.org/svntogit/packages.git/plain/trunk/config?h=packages/linux +curl -o "$WD"/linux/.config https://git.archlinux.org/svntogit/packages.git/plain/trunk/config?h=packages/linux + +CONFIG_PATH="$WD"/linux/.config ## Disable modules -sed 's/\(.*\)=m/#\1 is not set/g' -i .config -sed 's/\(.*\)MOUSE\(.*\)=y/\1MOUSE\2=n/g' -i .config -sed 's/\(.*\)USB\(.*\)=y/\1USB\2=n/g' -i .config -sed 's/\(.*\)TOUCHSCREEN\(.*\)=y/\1TOUCHSCREEN\2=n/g' -i .config -sed 's/\(.*\)HID\(.*\)=y/\1HID\2=n/g' -i .config -sed 's/\(.*\)GPU\(.*\)=y/\1GPU\2=n/g' -i .config -sed 's/\(.*\)GPIO\(.*\)=y/\1GPIO\2=n/g' -i .config -sed 's/\(.*\)NVDIMM\(.*\)=y/\1NVDIMM\2=n/g' -i .config -sed 's/\(.*\)MFD\(.*\)=y/\1MFD\2=n/g' -i .config -sed 's/\(.*\)XEN\(.*\)=y/\1XEN\2=n/g' -i .config -sed 's/\(.*\)VIDEO\(.*\)=y/\1VIDEO\2=n/g' -i .config -# sed 's/\(.*\)PCI\(.*\)=y/\1PCI\2=n/g' -i .config -sed 's/\(.*\)WLAN\(.*\)=y/\1WLAN\2=n/g' -i .config -sed 's/\(.*\)DRM\(.*\)=y/\1DRM\2=n/g' -i .config +sed 's/\(.*\)=m/#\1 is not set/g' -i "$CONFIG_PATH" +sed 's/\(.*\)MOUSE\(.*\)=y/\1MOUSE\2=n/g' -i "$CONFIG_PATH" +sed 's/\(.*\)USB\(.*\)=y/\1USB\2=n/g' -i "$CONFIG_PATH" +sed 's/\(.*\)TOUCHSCREEN\(.*\)=y/\1TOUCHSCREEN\2=n/g' -i "$CONFIG_PATH" +sed 's/\(.*\)HID\(.*\)=y/\1HID\2=n/g' -i "$CONFIG_PATH" +sed 's/\(.*\)GPU\(.*\)=y/\1GPU\2=n/g' -i "$CONFIG_PATH" +sed 's/\(.*\)GPIO\(.*\)=y/\1GPIO\2=n/g' -i "$CONFIG_PATH" +sed 's/\(.*\)NVDIMM\(.*\)=y/\1NVDIMM\2=n/g' -i "$CONFIG_PATH" +sed 's/\(.*\)MFD\(.*\)=y/\1MFD\2=n/g' -i "$CONFIG_PATH" +sed 's/\(.*\)XEN\(.*\)=y/\1XEN\2=n/g' -i "$CONFIG_PATH" +sed 's/\(.*\)VIDEO\(.*\)=y/\1VIDEO\2=n/g' -i "$CONFIG_PATH" +# sed 's/\(.*\)PCI\(.*\)=y/\1PCI\2=n/g' -i "$CONFIG_PATH" +sed 's/\(.*\)WLAN\(.*\)=y/\1WLAN\2=n/g' -i "$CONFIG_PATH" +sed 's/\(.*\)DRM\(.*\)=y/\1DRM\2=n/g' -i "$CONFIG_PATH" -cat ../../config/virtio.config >> .config -cat ../../config/fs.config >> .config -cat ../../config/net.config >> .config +cat kernel-config/config/virtio.config >> "$CONFIG_PATH" +cat kernel-config/config/fs.config >> "$CONFIG_PATH" +cat kernel-config/config/net.config >> "$CONFIG_PATH" ## Add KVM guest support make kvm_guest.config -make -j$(nproc) - -./scripts/extract-vmlinux ./arch/x86_64/boot/bzImage > ../../output/arch-vmlinux.bin +#make -j$(nproc) +# +#./scripts/extract-vmlinux ./arch/x86_64/boot/bzImage > "$WD"/arch-vmlinux.bin