-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a little helper script to boot a Micro VM, as we build them for Kata bare-metal, via QEMU.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
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
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" | ||
''; | ||
} |