Skip to content

Conversation

lbajolet-hashicorp
Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp commented Oct 17, 2022

BIOS and (U)EFI are two standard for booting machines. BIOS being legacy, which is still supported by several OSes, but is getting phased out little-by-little, in favour of EFI.

EFI requires several components to boot a machine: a GPT-backed disk, a firmware to load the bootloaders, and efivars to keep persistent data in NVRAM between boots.

This is translated in qemu as a collection of a code file that contains the firmware, and a vars file that holds a template efivars, which may have some keys or properties setup.

This commit adds new configuration values to enable this. At its simplest, this might be just enabling efi_enabled to boot with EFI support.

In practice, YMMV, as some protocols (typically Secure Boot) will require more setup before being able to get something to work as expected.

The EFI CODE and VARS files are automatically loaded from /usr/share/OVMF if available, otherwise they need to be specified manually.

The docs for Qemu are updated to reflect these changes.

Related to: #97

Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a couple of suggestions on the code but otherwise looks good.

Comment on lines +357 to +342
// NOTE: when booting a UEFI machine with Secure Boot enabled, this has
// to be a q35 derivative.
Copy link
Contributor

@nywilken nywilken Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be some validation or warning in Prepare to let the user know that they have enabled EFI with a non-q35 derivative machine type?

I'm not sure if this is a simple check. So I would be cool if you tell me there are too many combinations to validate; its better for the user to see the failure 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EFI on a non-q35 machine is fine, the problem is Secure-Boot, which is only supported on q35 machines (can't fine the docs to refer to that, but other machine types AFAIK will result in a blank screen).
Not sure we can reliably validate that, maybe by checking the name for the OVMF_*fd, but that's a stretch as a user might rename them, and the check will not bump the error.

BIOS and (U)EFI are two standard for booting machines. BIOS being
legacy, which is still supported by several OSes, but is getting phased
out little-by-little, in favour of EFI.

EFI requires several components to boot a machine: a GPT-backed disk, a
firmware to load the bootloaders, and efivars to keep persistent data in
NVRAM between boots.

This is translated in qemu as a collection of a code file that contains
the firmware, and a vars file that holds a template efivars, which may
have some keys or properties setup.

This commit adds new configuration values to enable this. At its
simplest, this might be just enabling `efi_enabled` to boot with EFI
support.

In practice, YMMV, as some protocols (typically Secure Boot) will
require more setup before being able to get something to work as
expected.

The EFI CODE and VARS files are automatically loaded from
/usr/share/OVMF if available, otherwise they need to be specified
manually.

The docs for Qemu are updated to reflect these changes.
Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@lbajolet-hashicorp lbajolet-hashicorp merged commit 4076d6d into main Nov 8, 2022
@lbajolet-hashicorp lbajolet-hashicorp deleted the efi_boot_args branch November 8, 2022 18:45
LKHN added a commit to LKHN/cloud-images that referenced this pull request Dec 5, 2022
In 1.0.7 - hashicorp/packer-plugin-qemu#100 version of
the QEMU Packer plugin, it's possible to boot and build images in
UEFI and with Secure Boot enabled

Signed-off-by: Elkhan Mammadli <elkhan.mammadli@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants