Ondrej Famera - top logo

fast-vm 1.0 and UEFI boot support with OVMF

One of the noticable features of the fast-vm 1.0 is support for UEFI booting. From technical point of view only change on fast-vm side needed was automatic deletion of nvram file. To get some UEFI image working we will first need to provide UEFI firmware to libvirt. Libivrt needs actually 2 files for UEFI: UEFI firmware itself and UEFI variables template file. On first VM start libvirt will make a writable copy of UEFI variable template file and provide it to VM as EUFI variables store. On VM deletion fast-vm instructs libvirt to delete this UEFI variables store file. Below is example on how to add the OVMF firmware to libvirt that can be used also with fast-vm.

Get the OVMF UEFI firmware

  • For Fedora the package containing OVMF UEFI formware is available in standard repositories under name edk2-ovmf. If you use older release check repository described on site Using UEFI with QEMU.
  • For other distributions you can download the OVMF generated RPMs and unpack them to obtain the OVMF UEFI firmware. (x86_64 UEFI firmware can be found in edk2.git-ovmf-x64-xxxxx.noarch.rpm RPM)

OVMF UEFI firmware placement

In both approaches in getting UEFI firmware (installing RPM or unpacking RPM) the files needed by libvirt will not be in proper place. Default expected places for OVMF UEFI firmware are defined in /etc/libvirt/qemu.conf config file by nvram variable. Default (on Fedora 24 and Gentoo) is shown below.

nvram = [
   "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd",
   "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd"
]

OVMF provides several flavours of UEFI firmware which are described in the README provided by RPM. If unsure which to choose you can use '-pure-efi.fd' version which provides UEFI-only boot. To use this one you can link the needed files to locations described in libvirt's nvram variable. Below example of linking this in Fedora 24.

mkdir /usr/share/OVMF  # as this directory is usually not present on system
ln -s /usr/share/edk2/ovmf/OVMF_CODE.fd /usr/share/OVMF/OVMF_CODE.fd
ln -s /usr/share/edk2/ovmf/OVMF_VARS.fd /usr/share/OVMF/OVMF_VARS.fd

Testing it out

To test out that your setup works, try importing some UEFI enabled fast-vm image (currently centos 7.2-UEFI) and start it directly into serial console (fast-vm start XX console). You should notice the serial console to black out and if you hit 'ESC' button you will get into UEFI firmware menu. If VM failed to start the most probable issue is with UEFI firmware placement. For that check the /etc/libvirt/qemu.conf if the default paths mentioned earlier are present there. The placement of UEFI firmware is defined also in the libvirt XML files so if you decide to use alternative location for them, please check also the libvirt XML file of machine.

Last change .