Ubuntu 18.04 Server UEFI install has garbled screen during debian-install

Hi all, I have been using Packer to build 18.04 server images using qemu and it worked fine using BIOS for the boot method. Im now trying to switch over to using UEFI, however the boot screen gets garbled after booting from the grub menu as shown below. I have UEFI working similarly in 20.04/22.04 without these problems so i dont really know whats going on here.

These are my boot options:

      "boot_command":                 [
        "c",
        "<wait3>",
        "set gfxpayload=keep<enter><wait3>",
        "linux /install/vmlinuz <wait3>",
        " auto<wait>",
        " console-setup/ask_detect=false<wait3>",
        " debian-installer/country=US<wait3>",
        " debian-installer/language=en<wait3>",
        " debian-installer/locale=en_US.UTF-8<wait3>",
        " DEBCONF_DEBUG=5<wait3>",
        " initrd=/install/initrd.gz<wait3>",
        " keyboard-configuration/layout=USA<wait3>",
        " keyboard-configuration/layoutcode=us<wait3>",
        " netcfg/get_domain=vm<wait3>",
        " netcfg/get_hostname=tvision<wait3>",
        " preseed/url=http://{{.HTTPIP}}:{{.HTTPPort}}/ubuntu/ubuntu-18.04-amd64-qemu.cfg<wait3>",
        " --- <enter><wait3>",
        "initrd /install/<wait3>initrd.gz<wait3>",
        "<enter><wait3>",
        "boot<enter><wait3>"
      ],

I have tried adding nomodeset and vga=788 and it makes no difference here.

Ok, i figured out the issue. For whatever reason when using UEFI, qemu now needs -vga virtio option to not mess up the graphics although this wasnt needed when doing the same thing using BIOS.

That’s right. I assume Debian embed VirtIO drivers so there’s no configuration to have. But for Windows ISO user, you should add virtio drivers into your boot.wim and install.wim that compose your Windows ISO, else UEFI may not boot but also, disk controller as well as network adapter might not be recognized at all.