UEFI-based virtual machines

UEFI-based virtual machines can be started by the parameters -l,bootrom,<efi-rom>[,<efi-vars>]. For <efi-rom>, the path to an EFI ROM file must be specified. Optionally, the path to a file can be specified at <efi-vars>, which in turn serves as a location for EFI virtual machine variables.

Files with EFI variables should be created per VM instance. The following command creates a copy of the file BHYVE_BHF_UEFI_VARS.fd to be used for the VM instance samplevm.

doas cp /usr/local/share/uefi-firmware/BHYVE_BHF_UEFI_VARS.fd /vms/samplevm/EFI_VARS.fd

The file EFI_VARS.fd is then passed as <efi-vars> parameter to the bhyve call.

Additionally, the parameter fwcfg=qemu should be appended. This allows the firmware to access bhyve's dynamically generated ACPI tables.

doas bhyve \
-c sockets=1,cores=1,threads=1 \
-m 2G \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_BHF_UEFI.fd,/vms/samplevm/EFI_VARS.fd,fwcfg=qemu \
-l com1,stdio \
-s 0:0,hostbridge \
-s 31:0,lpc \
-A -H -P \
samplevm