pmb.qemu.run: add support for EFI on aarch64

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2560
This commit is contained in:
Clayton Craft 2025-02-28 00:26:43 -08:00 committed by Oliver Smith
parent 4a7ec11f4c
commit b214fa6c4a
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -9,6 +9,7 @@ from pmb.helpers import logging
from pmb.helpers.exceptions import NonBugError from pmb.helpers.exceptions import NonBugError
import os import os
from pathlib import Path from pathlib import Path
import platform
import re import re
import signal import signal
import shlex import shlex
@ -258,10 +259,20 @@ def command_qemu(
raise RuntimeError(f"Architecture {arch} not supported by this command yet.") raise RuntimeError(f"Architecture {arch} not supported by this command yet.")
if args.efi: if args.efi:
command += [ host_arch = platform.machine().lower()
"-drive", match host_arch:
f"if=pflash,format=raw,readonly=on,file={chroot_native.path}/usr/share/OVMF/OVMF.fd", case "aarch64":
] command += [
"-drive",
f"if=pflash,format=raw,readonly=on,file={chroot_native.path}/usr/share/AAVMF/AAVMF_CODE.fd",
]
case "amd64":
command += [
"-drive",
f"if=pflash,format=raw,readonly=on,file={chroot_native.path}/usr/share/OVMF/OVMF.fd",
]
case _:
raise RuntimeError(f"Architecture {host_arch} not configured for EFI support.")
# Kernel Virtual Machine (KVM) support # Kernel Virtual Machine (KVM) support
native = pmb.parse.deviceinfo().arch.is_native() native = pmb.parse.deviceinfo().arch.is_native()
@ -368,7 +379,14 @@ def install_depends(args: PmbArgs, arch: Arch) -> None:
depends.remove("qemu-ui-opengl") depends.remove("qemu-ui-opengl")
if args.efi: if args.efi:
depends.append("ovmf") host_arch = platform.machine().lower()
match host_arch:
case "aarch64":
depends.append("aavmf")
case "amd64":
depends.append("ovmf")
case _:
raise RuntimeError(f"Architecture {host_arch} not configured for EFI support.")
chroot = Chroot.native() chroot = Chroot.native()
pmb.chroot.init(chroot) pmb.chroot.init(chroot)