QEMU fails to boot a UEFI guest install

Hey all,

I’m trying to run a VM with QEMU and I’m having some issues.

Here’s what I did:

  • created an image qemu-img create -f qcow2 nvme-image.qcow2 50G
  • booted the ubuntu installer:
(qemu-system-x86_64 -enable-kvm -m 16384 -smp 4
    -netdev user,id=mynet0,hostfwd=tcp::10022-:22
    -device virtio-net-pci,netdev=mynet0
    -drive file=nvme-image.qcow2,if=none,id=nvme0
    -device nvme,drive=nvme0,serial=1234
    -cdrom ~/Downloads/ubuntu-25.04-desktop-amd64.iso)
  • installed ubuntu using the graphical installer (which works well)
  • when finished, I shutdown the vm and ran it with:
(qemu-system-x86_64 -enable-kvm -m 16384 -smp 4
    -serial file:/tmp/serial.log
    -debugcon file:/tmp/debugcon.log
    -drive if=pflash,format=raw,readonly=on,file=/run/libvirt/nix-ovmf/OVMF_CODE.fd
    -drive if=pflash,format=raw,file=/run/libvirt/nix-ovmf/OVMF_VARS.fd
    -netdev user,id=mynet0,hostfwd=tcp::10022-:22
    -device virtio-net-pci,netdev=mynet0
    -drive file=nvme-image.qcow2,if=none,id=nvme0
    -device nvme,drive=nvme0,serial=1234
    -boot order=c)

At this point I expect the VM to boot from the image where I installed Ubuntu on, but it doesn’t. The QEMU window pops up, but I only see a message Guest has not initialized the display (yet).

When I remove the mounting of OVMF code and vars, I get a message Could not find a suitable boot device and the VM doesn’t boot as QEMU tries to boot using SeaBIOS

I’ve tried the same thing with installing a NixOS system, but I get the same result. With the NixOS VM I set boot.kernelParams = [ "console=ttyS0,115200n8" ]; and checked the boot entry to make sure it is there. So it doesn’t seem to be a problem that the console output isn’t sent.

QEMU itself doesn’t give any output either.

When I run QEMU with the OVMF files and do not attach a bootable device I get the same result.

(qemu-system-x86_64
 -drive if=pflash,format=raw,readonly=on,file=/run/libvirt/nix-ovmf/OVMF_CODE.fd
 -drive if=pflash,format=raw,file=./OVMF_VARS.fd)

I think I should see a boot menu, but I don’t. Hitting ESC or F2 doesn’t do anything either.

Not sure what to try next. Thank you.