Skip to content

Commit

Permalink
packages/boot-microvm: init
Browse files Browse the repository at this point in the history
This adds a little helper script to boot a Micro VM, as we build them for Kata bare-metal, via QEMU.
  • Loading branch information
msanft committed Nov 29, 2024
1 parent 7a57b4f commit 1e6e7fb
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions packages/by-name/boot-microvm/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2024 Edgeless Systems GmbH
# SPDX-License-Identifier: AGPL-3.0-only

{
writeShellApplication,
qemu,
OVMF,
}:

# Usage example:
# outPath=$(nix build .#kata.kata-image --print-out-paths); nix run .#boot-microvm -- "${outPath}/bzImage" "${outPath}/initrd" "${outPath}/image-podvm-gpu_1-rc1.raw" "$(nix eval --raw .#kata.kata-image.cmdline)"

writeShellApplication {
name = "boot-microvm";
runtimeInputs = [ qemu ];
text = ''
if [ $# -ne 4 ]; then
echo "Usage: $0 <kernel> <initrd> <rootfs> <cmdline>";
exit 1;
fi
tmpFile=$(mktemp)
cp "$3" "$tmpFile"
qemu-system-x86_64 \
-enable-kvm \
-m 3G \
-nographic \
-drive if=pflash,format=raw,readonly=on,file=${OVMF.firmware} \
-drive if=pflash,format=raw,readonly=on,file=${OVMF.variables} \
-kernel "$1" \
-initrd "$2" \
-append "$4" \
-drive "if=virtio,format=raw,file=$tmpFile"
'';
}

0 comments on commit 1e6e7fb

Please sign in to comment.