How do I disable unwanted iPXE boot attempt in Libvirt/qemu-kvm?

22,666

Solution 1

Short answer

Upgrade to libvirt 0.9.10+ (available in Quantal) and add the <rom bar='off'/> option to the interface configuration of the machine's XML definition.

Long answer

Now that I'm actually using the iPXE boot option I see that the delay occurring in the SeaBIOS screen is not an actual boot attempt. It's just loading the Virtio network option ROM and that takes a few annoying seconds, i.e. it's not yet doing an iPXE boot attempt. This lead me to read the libvirt documentation again, and I made an interesting discovery.

As far as I could find, since libvirt 0.9.7 the behaviour has changed to load interface's option ROMs by default. Ubuntu 11.10 shipped with 0.9.2, Ubuntu 12.04 comes with 0.9.8. This definitely makes sense as to why I see this happening since the upgrade to 12.04.

Moreover, this has become configurable in libvirt version 0.9.10 with the <rom bar='off'/> option in the XML! (see here) However, that version of libvirt is not available in Ubuntu 12.04 and I'll have to upgrade to 12.10 or backport it. This makes Ubuntu 12.04 fall between two stools.

Other workarounds are removing the option ROM files as pointed out by @A.H.' and changing the SeaBIOS 'filesystem' as pointed out by @NlightNFotis. However, both ways will basically disable iPXE completely and it's not configurable (if sticking to virtio network devices only). As I have a mixed setup of iPXE machines and non-PXE machines, I really need this to be configurable.

Solution 2

My experiments on the same issue gave me some hints:

The package kvm-ipxe installs several PXE option ROMs into /usr/share/qemu/:

pxe-e1000.rom
pxe-ne2k_isa.rom
pxe-pcnet32.rom
pxe-rtl8139.rom
pxe-virtio.rom

Somehow these are automatically found and used by seabios when booting with one of these NICs. When I do a chmod a= pxe*.rom on these files and start the virtual machine I get the "error" message

kvm: pci_add_option_rom: failed to find romfile "pxe-rtl8139.rom"

but it boots cleanly and without PXE.

Solution 3

I was able to get around this in Ubuntu 12.04 by passing the following options to qemu-kvm on the command-line (setting the romfile to blank is the trick):

-netdev user,id=hostnet0 -device virtio-net-pci,romfile=,netdev=hostnet0

Solution 4

I was able to prevent this using "-net none":

# qemu-system-i386 -net none
Share:
22,666

Related videos on Youtube

gertvdijk
Author by

gertvdijk

FOSS enthousiast, Developer, Debian GNU/Linux (and Ubuntu) user, DevOps with Ansible/Pupppet powers, Coding in C/C++/Python. Keywords: Linux, KVM/Libvirt, Kubernetes, Ansible, Docker, Python, a bit of C/C++/Kotlin, Debian, Ubuntu, Apache, Kopano, Postfix, MySQL, PostgreSQL, Kafka, security, KDE, SSL/TLS. Every now and then I'll write an article on those topics my blog. Other sites I'm active on: Launchpad, Tweakers.net, Twitter, LinkedIn

Updated on September 18, 2022

Comments

  • gertvdijk
    gertvdijk over 1 year

    Somehow after upgrading to 12.04, my virtual machines always boot with an attempt to boot from the network first. See this:

    virt-manager screenshot

    while I don't have any PXE configuration set:

    PXE boot configuration

    I've tried:

    • to disable SPICE, by changing the emulator to /usr/bin/kvm from /usr/bin/kvm-spice by editing the XML.
    • Ctrl+B to configure the iPXE, but it doesn't let disable this as a boot option.
    • setting another type of NIC - not an option, I need virtio for performance reasons. However, e1000e doesn't work either.
    • removing the NIC: works. However, I need network.
    • Googling around. Hard. Lots of result is about failing configured PXE boots.

    Not a big issue, but it increases boot times by 50-100% here (booting from SSD), so it's relatively long and annoys me.

    How can I disable this and boot from virtual hard disk directly?

  • gertvdijk
    gertvdijk over 11 years
    How can I enter the VM's BIOS? Wikipedia about SeaBIOS tells me I should try F12 at boot time, but that only triggers skipping the iPXE attempt once.
  • NlightNFotis
    NlightNFotis over 11 years
    @gertvdijk I am currently looking into it. I will get back to you as soon as I find out.
  • NlightNFotis
    NlightNFotis over 11 years
    @gertvdijk This seems somehow related: seabios.org/pipermail/seabios/2012-March/003526.html
  • gertvdijk
    gertvdijk over 11 years
    Thanks, learned new stuff today. However, this seems to apply system-wide and about building a new CBFS (core boot filesystem). As far as I can see, it also disables PXE booting altogether. I don't like this approach and I think it should be possible to prevent iPXE booting attempts runtime as is possible in virt-manager GUI.
  • NlightNFotis
    NlightNFotis over 11 years
    @gertvdijk How do you know it disables it? All I can see is to set up the boot order, meaning something gets booted prior to something else.
  • gertvdijk
    gertvdijk over 11 years
    Well, I guess it won't be possible to have one VM doing PXE booting and another one having it disabled. Additionally, I am not familiar with building these CBFSs and I assume there must be a better solution (or bugfix).
  • NlightNFotis
    NlightNFotis over 11 years
    @gertvdijk I see. Have it your way mate. =) One last thing: Please consider upvoting this answer if it has been any useful.
  • gertvdijk
    gertvdijk over 11 years
    Thanks. That gives me a bit of a workaround: using virtio for general networking devices and e1000e for VMs that need PXE. However, I still think it's a bug. Somehow Libvirt does not successfully pass the right boot parameters to SeaBIOS.
  • gertvdijk
    gertvdijk almost 11 years
    Cool, but can I specify this in my Libvirt XML machine definition?
  • gertvdijk
    gertvdijk over 10 years
    But then you don't have any networking at all! I consider this not really an answer.
  • Catalin P
    Catalin P over 10 years
    Sorry, I missed the fact that OP still needed networking. In my case running with no network was acceptable.
  • i336_
    i336_ about 8 years
    If you're doing ad-hoc repeated rebooting from the commandline, this is the way to go. It adds a bit of noise, but instantaneously kills iPXE without requiring you to edit XML files, nuke all of networking, or similar.
  • Bryce Guinta
    Bryce Guinta almost 7 years
    What does chmod a= do?
  • Bryce Guinta
    Bryce Guinta almost 7 years
    Where is the machine's XML definition?
  • gertvdijk
    gertvdijk almost 7 years
    @BryceGuinta Create a VM first, then edit its XML definition (advanced) using the command virsh edit <domain>
  • Jarda Pavlíček
    Jarda Pavlíček over 2 years
    This also helped me with my case