Skip to content

Instantly share code, notes, and snippets.

@mcastelino
Last active June 14, 2022 07:09
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mcastelino/7ab9dba51b0dbb230bd18c448d935312 to your computer and use it in GitHub Desktop.
Save mcastelino/7ab9dba51b0dbb230bd18c448d935312 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