Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions boot-qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ def get_efi_args(guest_arch):

for efi_img_location in efi_img_locations[guest_arch]:
if efi_img_location is None:
raise Exception(f"edk2 could not be found for {guest_arch}!")
raise FileNotFoundError(
f"edk2 could not be found for {guest_arch}!")
efi_img = Path("/usr/share", efi_img_location)
if efi_img.exists():
break
Expand All @@ -410,12 +411,14 @@ def get_efi_args(guest_arch):

efi_img_qemu = base_folder.joinpath("images", guest_arch, "efi.img")
shutil.copyfile(efi_img, efi_img_qemu)
efi_img_qemu.open(mode="r+b").truncate(efi_img_size)
with efi_img_qemu.open(mode="r+b") as file:
file.truncate(efi_img_size)

efi_vars_qemu = base_folder.joinpath("images", guest_arch,
"efivars.img")
efi_vars_qemu.unlink(missing_ok=True)
efi_vars_qemu.open(mode="xb").truncate(efi_img_size)
with efi_vars_qemu.open(mode="xb") as file:
file.truncate(efi_img_size)

elif guest_arch == "x86_64":
efi_img_qemu = efi_img # This is just usable, it is marked read only
Expand All @@ -428,7 +431,7 @@ def get_efi_args(guest_arch):
]
for efi_vars_location in efi_vars_locations:
if efi_vars_location is None:
raise Exception("OVMF_VARS.fd could not be found!")
raise FileNotFoundError("OVMF_VARS.fd could not be found!")
efi_vars = Path('/usr/share', efi_vars_location)
if efi_vars.exists():
break
Expand Down