Last active
August 21, 2024 17:59
-
-
Save mariapana/90ab2e61715e812def0c7582c9482626 to your computer and use it in GitHub Desktop.
Multiboot2 nginx example script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APP_NAME=nginx_qemu-x86_64 | |
# TODO: Add path | |
APP_DIR= | |
UK_DIR=${APP_DIR}/workdir/unikraft | |
UK_SCRIPTS_DIR=workdir/unikraft/support/scripts | |
# NOTE: This is a workaround for qemu's -append option | |
# The contents of cmdline_params.txt will be passed to the mkukimg script | |
touch cmdline_params.txt | |
echo netdev.ip=172.44.0.2/24:172.44.0.1:8.8.8.8 -- > cmdline_params.txt | |
CMD_SRC=$PWD/cmdline_params.txt | |
ISO_OUT=$PWD/mb2_test.iso | |
# Clean and Build | |
cd ${APP_DIR} | |
make clean | |
make -j $(nproc) | |
# Rebuild initrd.cpio | |
rm initrd.cpio | |
./${UK_SCRIPTS_DIR}/mkcpio initrd.cpio rootfs | |
# Build .iso image | |
./${UK_SCRIPTS_DIR}/mkukimg \ | |
-k ${APP_DIR}/workdir/build/${APP_NAME} \ | |
-b grubmb2 \ | |
-c ${CMD_SRC} \ | |
-i ${APP_DIR}/initrd.cpio \ | |
-a X64 \ | |
-o ${ISO_OUT} | |
# Remove previously created network interfaces. | |
{ | |
sudo ip link set dev tap0 down | |
sudo ip link del dev tap0 | |
sudo ip link set dev virbr0 down | |
sudo ip link del dev virbr0 | |
} > /dev/null 2>&1 | |
# Create bridge interface for QEMU networking. | |
sudo ip link add dev virbr0 type bridge | |
sudo ip address add 172.44.0.1/24 dev virbr0 | |
sudo ip link set dev virbr0 up | |
# Launch qemu | |
sudo qemu-system-x86_64 \ | |
-cdrom ${ISO_OUT} \ | |
-boot d \ | |
--no-reboot \ | |
-nographic \ | |
-enable-kvm \ | |
-cpu max \ | |
-m 8M \ | |
--netdev bridge,id=en0,br=virbr0 \ | |
-device virtio-net-pci,netdev=en0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment