Bug 781562

Summary: [RFE] Support for qemu PCI romfile option
Product: Red Hat Enterprise Linux 6 Reporter: Alex Williamson <alex.williamson>
Component: libvirtAssignee: Laine Stump <laine>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.3CC: acathrow, ajia, dallan, dyuan, juzhang, mzhan, rwu, weizhan
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.9.10-1.el6 Doc Type: Enhancement
Doc Text:
Along with the "rombar" option that controls whether or not a boot rom is made visible to the guest, qemu also has a "romfile" option that allows specifying a binary file to present as the ROM BIOS of any emulated or passthrough PCI device. This patch adds support for specifying romfile to both passthrough PCI devices, and emulated network devices that attach to the guest's PCI bus (just about everything other than ne2k_isa). One example of the usefulness of this option is described in the bugzilla report: 82576 sriov network adapters don't provide a ROM BIOS for the cards virtual functions (VF), but an image of such a ROM is available, and with this ROM visible to the guest, it can PXE boot. In libvirt's xml, the new option is configured like this: <hostdev> ... <rom file='/etc/fake/boot.bin'/> ... </hostdev (similarly for <interface>).
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 06:46:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Alex Williamson 2012-01-13 18:08:10 UTC
Description of problem:
Qemu has a romfile option for emulated and assigned PCI devices to specify a file from which to load the ROM.  This is useful for using a non-standard ROM, for instance SR-IOV VFs do not have physical ROM space, but option ROMs are available for some that can be used to support boot (ex. igbvf has an gpxe/ipxe boot ROM).  We should be able to specify <rom file='my file'/> in the xml.

Version-Release number of selected component (if applicable):
RHEL6.2

How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 2 Laine Stump 2012-01-25 18:01:33 UTC
I just posted patches upstream which should satisfy this:

  https://www.redhat.com/archives/libvir-list/2012-January/msg01031.html

If you're up to doing a build yourself, please give them a test.

Comment 3 Laine Stump 2012-02-01 20:53:51 UTC
The above patches have been committed upstream, so they will be in libvirt-0.9.10:

commit 3801831cdf64cb040047b579d02942fe34ff31b5
Author: Laine Stump <laine@laine.org>
Date:   Wed Jan 25 11:20:49 2012 -0500

    qemu: add "romfile" support to specify device boot ROM

commit 3284ac046fedc5b21c2bd153aa0f621a19a52e96
Author: Laine Stump <laine@laine.org>
Date:   Tue Jan 24 19:54:12 2012 -0500

    qemu: (and conf) support rombar for network devices

commit c01ba1a48f54e99e60c8cde4299aa21e908ba323
Author: Laine Stump <laine@laine.org>
Date:   Tue Jan 24 14:11:05 2012 -0500

    conf: relocate rombar and boot order parse/format
   
commit 159f4d0b30ca9916a1b541a9ebcf560ffeca5330
Author: Laine Stump <laine@laine.org>
Date:   Tue Jan 24 12:53:59 2012 -0500

    conf: put all guest-related HostdevDef data in one object

Comment 6 Alex Jia 2012-02-15 07:32:20 UTC
The SRIOV is just a special PCI device, I tested the bug on a normal PCI device instead:

1. virsh edit the following xml into guest configuration:

    <interface type='user'>
      <mac address='52:54:00:24:a5:9f'/>
      <model type='virtio'/>
      <rom file='/etc/fake/bootrom.bin'/>
    </interface>
    <interface type='user'>
      <mac address='52:54:00:63:79:db'/>
      <model type='virtio'/>
      <rom bar='on'/>
    </interface>
    <interface type='user'>
      <mac address='52:54:00:ac:b5:23'/>
      <model type='virtio'/>
      <rom bar='off'/>
    </interface>

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x19' function='0x0'/>
      </source>
      <rom file='/etc/fake/bootrom.bin'/>
    </hostdev>

Notes: remember to replace your NICs address.

2. create a fake rom file
# mkdir /etc/fake && touch /etc/fake/bootrom.bin

3. start the guest
# virsh start <domain>

4. check qemu-kvm cmdline
# ps -ef|grep qemu-kvm
qemu     16159     1 11 15:25 ?        00:00:01 /usr/libexec/qemu-kvm -S -M rhel6.2.0 -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name foo -uuid d93dae01-6865-d193-39f3-c62773b83417 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/foo.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/foo.qcow2,if=none,id=drive-virtio-disk0,format=qcow2 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=22,id=hostnet0,vhost=on,vhostfd=23 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:7e:ef:a6,bus=pci.0,addr=0x3 -netdev user,id=hostnet1 -device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:24:a5:9f,bus=pci.0,addr=0x7,romfile=/etc/fake/bootrom.bin -netdev user,id=hostnet2 -device virtio-net-pci,netdev=hostnet2,id=net2,mac=52:54:00:63:79:db,bus=pci.0,addr=0x9,rombar=1 -netdev user,id=hostnet3 -device virtio-net-pci,netdev=hostnet3,id=net3,mac=52:54:00:ac:b5:23,bus=pci.0,addr=0xa,rombar=0 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -vnc 127.0.0.1:0 -k en-us -vga cirrus -device AC97,id=sound0,bus=pci.0,addr=0x4 -device pci-assign,host=00:19.0,id=hostdev0,configfd=24,bus=pci.0,addr=0x8,romfile=/etc/fake/bootrom.bin -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

Notes, rom bar=off ==> rombar=0, rom bar=on ==> rombar=1, rom file=/etc/fake/bootrom.bin ==> romfile=/etc/fake/bootrom.bin.

5. separately to check rom bar=on|off case for PCI device:
1) virsh edit the following xml into a new guest configuration
<hostdev mode='subsystem' type='pci' managed='yes'>
  <source>
    <address domain='0x0000' bus='0x00' slot='0x19' function='0x0'/>
  </source>
  <rom bar='off'/>
</hostdev>
2) start the new guest
# virsh start <new domain>
3) check qemu-kvm cmdline
# ps -ef|grep qemu-kvm
qemu     13531     1 73 15:03 ?        00:00:11 /usr/libexec/qemu-kvm -S -M rhel6.2.0 -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name foo -uuid d93dae01-6865-d193-39f3-c62773b83417 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/foo.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/foo.qcow2,if=none,id=drive-virtio-disk0,format=qcow2 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=22,id=hostnet0,vhost=on,vhostfd=23 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:7e:ef:a6,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -vnc 127.0.0.1:0 -k en-us -vga cirrus -device AC97,id=sound0,bus=pci.0,addr=0x4 -device pci-assign,host=00:19.0,id=hostdev0,configfd=24,bus=pci.0,addr=0x7,rombar=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

repeat 1)-3) and replace 'off' to 'on'.

Notes, rom bar=off ==> rombar=0, rom bar=on ==> rombar=1

I can see romfile argument is correctly passed from libvirt to qemu-kvm on libvirt-0.9.10-1.el6.x86_64, so the bug has been verified.

Comment 7 weizhang 2012-02-17 06:33:56 UTC
I try with 82576 nic and test with following steps
1. Start guest with 
...
          <hostdev mode='subsystem' type='pci' managed='yes'>
            <source>
              <address bus='0x03' slot='0x10' function='0x05'/>
            </source>         
            <boot order='1'/>         
           <rom bar='on' file='/usr/share/seabios/ipxe-808610ca.rom'/>
          </hostdev>
...
Then the guest may booting from ROM, entry the ipxe start process

2.  Start guest with 
...
          <hostdev mode='subsystem' type='pci' managed='yes'>
            <source>
              <address bus='0x03' slot='0x10' function='0x05'/>
            </source>         
            <boot order='1'/>         
           <rom bar='off' file='/usr/share/seabios/ipxe-808610ca.rom'/>
          </hostdev>
...
The guest just boot from hard disk

Both rombar and romfile work well

Comment 8 Laine Stump 2012-05-08 18:19:18 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Along with the "rombar" option that controls whether or not a boot rom is made visible to the guest, qemu also has a "romfile" option that allows specifying a binary file to present as the ROM BIOS of any emulated or passthrough PCI device. This patch adds support for specifying romfile to both passthrough PCI devices, and emulated network devices that attach to the guest's PCI bus (just about everything other than ne2k_isa).

One example of the usefulness of this option is described in the bugzilla report: 82576 sriov network adapters don't provide a ROM BIOS for the cards virtual functions (VF), but an image of such a ROM is available, and with this ROM visible to the guest, it can PXE boot.

In libvirt's xml, the new option is configured like this:

   <hostdev>
     ...
     <rom file='/etc/fake/boot.bin'/>
     ...
   </hostdev

(similarly for <interface>).

Comment 10 errata-xmlrpc 2012-06-20 06:46:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2012-0748.html