qemu/run: add support for EFI boot

This add support for EFI boot in pmb qemu, it can be enabled by
specifying the --efi option.

Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Reviewed-by: Caleb Connolly <kc@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230316192838.21431-3-clayton@craftyguy.net%3E
This commit is contained in:
Clayton Craft 2023-03-16 12:28:37 -07:00 committed by Oliver Smith
parent 6c66bfb8aa
commit d957710b49
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
1 changed files with 14 additions and 3 deletions

View File

@ -161,9 +161,13 @@ def command_qemu(args, arch, img_path, img_path_2nd=None):
command += ["-L", rootfs_native + "/usr/share/qemu/"]
command += ["-nodefaults"]
command += ["-kernel", kernel]
command += ["-initrd", rootfs + "/boot/initramfs" + flavor_suffix]
command += ["-append", shlex.quote(cmdline)]
# Only boot a kernel/initramfs directly when not doing EFI boot. This
# allows us to load/execute an EFI application on boot, and support
# a wide variety of boot loaders.
if not args.efi:
command += ["-kernel", kernel]
command += ["-initrd", rootfs + "/boot/initramfs" + flavor_suffix]
command += ["-append", shlex.quote(cmdline)]
command += ["-smp", str(ncpus)]
@ -200,6 +204,10 @@ def command_qemu(args, arch, img_path, img_path_2nd=None):
raise RuntimeError(f"Architecture {arch} not supported by this command"
" yet.")
if args.efi:
command += ["-drive",
"if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF.fd"]
# Kernel Virtual Machine (KVM) support
native = pmb.config.arch_native == args.deviceinfo["arch"]
if args.qemu_kvm and native and os.path.exists("/dev/kvm"):
@ -304,6 +312,9 @@ def install_depends(args, arch):
depends.remove("qemu-hw-display-virtio-vga")
depends.remove("qemu-ui-opengl")
if args.efi:
depends.append("ovmf")
pmb.chroot.apk.install(args, depends)