Bug 1370093 - qemu or seabios cannot move the USB hostdev to correct position as the bootindex if only with nec-xhci
Summary: qemu or seabios cannot move the USB hostdev to correct position as the bootin...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: seabios
Version: 7.3
Hardware: x86_64
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Gerd Hoffmann
QA Contact: FuXiangChun
URL:
Whiteboard:
Depends On: 1470751
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-08-25 09:58 UTC by Pei Zhang
Modified: 2018-05-08 16:14 UTC (History)
10 users (show)

Fixed In Version: seabios 1.11
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-05-08 16:14:27 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Pei Zhang 2016-08-25 09:58:38 UTC
Description of problem:
Although libvirt can set bootindex=1 in the "-device usb-host" options, and although seabios is capable of booting from a device
plugged into a nec-usb-xhci controller, for some reason either qemu or seabios isn't properly moving the selection for the USB disk up to
position 1 only if the usb controller is nec-usb-xhci.

Version-Release number of selected component (if applicable):
seabios-1.9.1-4.el7.x86_64
qemu-kvm-rhev-2.6.0-21.el7.x86_64

How reproducible:
100%

Steps to Reproduce:

Steps : 
1.An bootable USB hostdev with bootindex=1 
2.An bootable virtual disk 
3.enable boot menu, start guest. 
4.Guest tried to start from the virtual disk but ignore the usb hostdev with bootindex=1

5. check boot menu when guest starts :

Select boot device :
1. Virtio disk PCI:0:7
2. USB MSC Drive USB DISK ... (it is the device with boot order =1 )

qemu cmd line : 

# ps -ef|grep qemu | sed 's/-device/\n-device/g'
qemu      6608     1  0 10:51 ?        00:00:02 /usr/libexec/qemu-kvm -name guest=vm2,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-35-vm2/master-key.aes -machine pc-i440fx-rhel7.3.0,accel=kvm,usb=off,vmport=off -cpu IvyBridge -bios /usr/share/seabios/bios-256k.bin 
......
-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive file=/var/lib/libvirt/images/vm2.qcow2,format=qcow2,if=none,id=drive-virtio-disk0 
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=2 
......
-device usb-host,hostbus=2,hostaddr=3,id=hostdev0,bootindex=1,bus=usb.0,port=4 

guest xml : 

# virsh dumpxml vm2 
......
<os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.3.0'>hvm</type>
    <loader type='rom'>/usr/share/seabios/bios-256k.bin</loader>
    <bootmenu enable='yes'/>
  </os>

   <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/vm2.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
......
  <controller type='usb' index='0' model='nec-xhci'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </controller>

...... 
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source startupPolicy='optional'>
        <vendor id='0x1005'/>
        <product id='0xb113'/>
        <address bus='2' device='3'/>
      </source>
      <boot order='1'/>
      <alias name='hostdev0'/>
      <address type='usb' bus='0' port='4'/>
    </hostdev>

Actual results:
As step 5, host usb with bootindex = 1 cannot be moved to the first place. 

Expected results:
List bootable devices as boot index. 

Additional info:

Comment 2 Gerd Hoffmann 2017-01-10 11:00:18 UTC
Underlying issue:  Each physical xhci port is two virtual ports, one for usb3 devices and one for usb1+usb2 devices.  So, the device plugged into physical port #1 can show up on virtual port #1 (usb3) or virtual port #5 (usb1+usb2).

The bootindex entry is created for the physical port numbering, i.e. port #1.  So it works for usb3 sticks (when plugged into a usb3 port on the host) and doesn't work for usb2 sticks.  Virtual sticks (aka usb-storage) support usb3 and work fine too.

I guess we should map those virtual port numbers back to physical port numbers in the firmware driver.

Reassigning to seabios.

Adding László to CC (clone for ovmf if needed).

Comment 3 Laszlo Ersek 2017-01-10 12:58:20 UTC
Thanks for the CC.

At the moment OVMF doesn't have any special handling for bootorder entries that describe assigned USB host devices. I seem to remember testing boot from physical USB sticks with OVMF, but I'm unsure if those tests used "-device usb-host", or SCSI LUN passthrough.

I also can't recall if this scenario was specifically covered in the last QE test plan for OVMF that I reviewed...

I suggest that, if we want to support this use case, QE please retest it with OVMF, and report a separate BZ if it doesn't work. That bug report should include the full OVMF debug log (as usual). From that log, I should be able to see the "bootorder" fw_cfg file, including the OpenFirmware devpath that needs special casing.

Furthermore, a comparison between OpenFirmware devpaths that only differ in the virtual port in use would be helpful.

Independently, what are the practical advantages of assigning a USB block device with <hostdev> over any other methods, for example LUN passthrough with virtio-scsi? I certainly see the point of <hostdev> assignment for a USB mouse or keyboard, but not so much for a block device. Even for optical media or tape writing, we've always suggested LUN passthrough, to my knowledge.

Comment 4 Gerd Hoffmann 2017-03-31 11:49:32 UTC
Not fixed yet upstream, deferring ...

Comment 5 Gerd Hoffmann 2017-09-26 09:26:49 UTC
Fix landed in upstream seabios (commit b404a5f417cbe5593f89c79954569b0e245fb80c).

Comment 6 Gerd Hoffmann 2017-10-20 11:22:57 UTC
> Fix landed in upstream seabios (commit
> b404a5f417cbe5593f89c79954569b0e245fb80c).

rebase will pick it up.

Comment 7 Gerd Hoffmann 2018-03-16 12:53:08 UTC
Please test rhel-7.5 seabios build.

Comment 8 Jeff Nelson 2018-03-16 14:16:11 UTC
Gard, please don't change BZ status like this. You are free to use NEW<->ASSIGNED<->POST. Maintainers will change the status from POST to MODIFIED to ON_QA so that we can make sure the BZ gets tracked properly in the advisory that goes to customers.

Mirek, can you please add the seabios build NVR to the BZ and add the BZ to the advisory?


Note You need to log in before you can comment on or make changes to this bug.