Skip to content

Instantly share code, notes, and snippets.

@Ilgrim
Forked from mcastelino/qemu_optionrom.md
Created March 2, 2020 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ilgrim/edd49bd6529b950630d4126eb05d1c1f to your computer and use it in GitHub Desktop.
Save Ilgrim/edd49bd6529b950630d4126eb05d1c1f to your computer and use it in GitHub Desktop.
QEMU Option ROMS and booting from option rom

With seabios

  1. QEMU includes bundled option ROMs which are loaded by default unless a device is specifically setup with --romfile="".
  2. These options roms are bundled as binaries. The source code for the same can be found at http://ipxe.org/
  3. These options roms are useful for example when you want to PXE boot over a virtio-net device.

Here is an example of booting via Network PXE using the option ROM

qemu-system-x86_64 \
    -machine pc,accel=kvm,kernel_irqchip \
    -enable-kvm \
    -smp sockets=1,cpus=4,cores=2 -cpu host \
    -m 1024 \
    -netdev user,id=mynet0,hostfwd=tcp::${VMN}0022-:22,hostfwd=tcp::${VMN}2375-:2375 \
    -device virtio-net-pci,netdev=mynet0,bootindex=1 \
    -device virtio-rng-pci \
    -monitor telnet:127.0.0.1:55555,server,nowait \
    -debugcon file:debug.log -global isa-debugcon.iobase=0x402 $@

From the boot log you will observer that the PXE boot is initiated over the virtio network device.

Now if you specify romfile=""

-device virtio-net-pci,netdev=mynet0,bootindex=1,romfile="" \

you will notice that the PXE boot over the network device is skipped.

With OVMF

However with OVMF/EDK2 the firmware include PXE support and the option rom is not needed. This can be quickly verified by launching QEMU with OVMF but without the option rom and the PXE boot will work.

qemu-system-x86_64 \
    -machine pc,accel=kvm,kernel_irqchip \
    -bios ovmf.fd \
    -enable-kvm \
    -smp sockets=1,cpus=4,cores=2 -cpu host \
    -m 1024 \
    -netdev user,id=mynet0,hostfwd=tcp::${VMN}0022-:22,hostfwd=tcp::${VMN}2375-:2375 \
    -device virtio-net-pci,netdev=mynet0,bootindex=1,romfile="" \
    -monitor telnet:127.0.0.1:55555,server,nowait \
    -debugcon file:debug.log -global isa-debugcon.iobase=0x402 $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment