# QEMU-libvirt UEFI VM? [Solved]

## eccerr0r

Is there a Gentoo sanctioned way of using libvirt to setup a QEMU VM that boots UEFI firmware, so I can experiment with efibootmgr on a VM?

My host machine does not support UEFI, though this theoretically shouldn't matter...

----------

## szatox

Host machine does not matter. AFAIK you have to patch UEFI mode into qemu though.

It's been this way for a long time.

----------

## eccerr0r

Is it just a maintainer issue or is this due to licensing issues?  Probably the latter?

----------

## mutiny

Not sure what "Gentoo sanctioned" would imply, but isn't this what you can do with OVMF? It seems OVMF got its own ebuild in gentoo recently so you don't need to build from edk on your own. If you use virsh to edit a domain, you would have the OVMF binary in <loader type='pflash'>OVMF_CODE.fd</loader> under <os> I think.

----------

## eccerr0r

Ah, I see a lot of other distros want to install the ovmf firmware separately, did not know that it got added to portage recently.  I'll have to try it then...  For searchers it's sys-firmware/edk2-ovmf ...

Hopefully now I have a throwaway UEFI "machine" to play with now :D

---

Information for those interested for those using libvirt:

Apparently the UEFI firmware requires that you're using the Q35 emulated chipset instead of the 440FX.  However the libvirt config file is kind of detailed so you can't easily switch from from 440FX to Q35, so it's easiest to create a new VM.  Anyway:

# emerge sys-firmware/edk2-ovmf

# ln -s /usr/share/edk2-ovmf /usr/share/OVMF

# restart libvirtd

Now using virt-manager you can create a new virtual machine.  Customize before install and there should be an option to switch to Q35 chipset, and also specify the uefi firmware.

Then just start the machine.  Upon successful firmware start... this is what I'm stoked about: EFI-SHELL is built in the OVMF firmware!  I wish more real hardware has it installed in firmware.

(or follow what Portage says):

Run via command line

$ qemu-system-x86_64 		-drive file=/usr/share/edk2-ovmf/OVMF.fd,if=pflash,format=raw,unit=0,readonly=on 		...

Or using libvirt:

 * You can register the firmware for use in libvirt by adding to /etc/libvirt/qemu.conf:

 * nvram = [

 * "/usr/share/edk2-ovmf/OVMF_CODE.fd:/usr/share/edk2-ovmf/OVMF_VARS.fd"

 * ]

----------

## Fitap

Hi, did you see this link?

https://fedoraproject.org/wiki/Using_UEFI_with_QEMU

Regards.

----------

