Bug 1341610 - PCI: QEMU must check function 0 is present for multi-function devices
Summary: PCI: QEMU must check function 0 is present for multi-function devices
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev
Version: 7.3
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: ---
Assignee: Amnon Ilan
QA Contact: yduan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-01 11:01 UTC by Yang Yang
Modified: 2018-11-05 07:53 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-07-19 18:46:01 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Yang Yang 2016-06-01 11:01:07 UTC
Description of problem:
If setting the function of a device's address to be !=0, the device cannot be detected in guest. The issue can be reproduced with virtio blk, virtio scsi controller, virtio serial controller, pci bridge and usb controller

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

How reproducible:
100%

Steps to Reproduce:
1. boot a guest. I have 2 virtio blk in guest, 1st is plugged into pci:0.0.0xf.0, 2nd is plugged into pci:0.0.0x10.0x2, and 2 virtio scsi controllers, 1st is plugged into pci:0.0.0x1f.01, 2nd is plugged into pci:0.0.1e.0, and 2 virtio-serial controllers, 1st is plugged into pci:0.0.05.0
2nd is plugged into pci:0.0.0x14.0x2, and 1 pci bridge, plugged into pci:0.0.0x6.0x2

/usr/libexec/qemu-kvm \
-drive file=/mnt/nfs2/RHEL-7.3-latest.qcow2,format=qcow2,if=none,id=drive-virtio-disk0 \
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0xf,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
-drive file=/mnt/nfs2/virtio1.img,format=qcow2,if=none,id=drive-virtio-disk1 \
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x10.0x2,drive=drive-virtio-disk1,id=virtio-disk1 \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
-device piix3-usb-uhci,id=usb1,bus=pci.0,addr=0x13.0x2 \
-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x1f.0x2 \ 
-device virtio-scsi-pci,id=scsi1,bus=pci.0,addr=0x1e \
-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 \
-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0x14.0x2 \
-device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x6.0x2 \
-monitor stdio -spice port=5931,disable-ticketing -boot menu=on -m 2G -qmp tcp:0:6666,server,nowait

2.(qemu) info pci
  Bus  0, device   0, function 0:
    Host bridge: PCI device 8086:1237
      id ""
  Bus  0, device   1, function 0:
    ISA bridge: PCI device 8086:7000
      id ""
  Bus  0, device   1, function 1:
    IDE controller: PCI device 8086:7010
      BAR4: I/O at 0xc100 [0xc10f].
      id ""
  Bus  0, device   1, function 2:
    USB controller: PCI device 8086:7020
      IRQ 11.
      BAR4: I/O at 0xc0c0 [0xc0df].
      id "usb"
  Bus  0, device   1, function 3:
    Bridge: PCI device 8086:7113
      IRQ 9.
      id ""
  Bus  0, device   2, function 0:
    VGA controller: PCI device 1234:1111
      BAR0: 32 bit prefetchable memory at 0xfd000000 [0xfdffffff].
      BAR2: 32 bit memory at 0xfebf0000 [0xfebf0fff].
      BAR6: 32 bit memory at 0xffffffffffffffff [0x0000fffe].
      id ""
  Bus  0, device   3, function 0:
    Ethernet controller: PCI device 8086:100e
      IRQ 11.
      BAR0: 32 bit memory at 0xfebc0000 [0xfebdffff].
      BAR1: I/O at 0xc000 [0xc03f].
      BAR6: 32 bit memory at 0xffffffffffffffff [0x0003fffe].
      id ""
  Bus  0, device   5, function 0:
    Class 1920: PCI device 1af4:1003
      IRQ 10.
      BAR0: I/O at 0xc0e0 [0xc0ff].
      BAR1: 32 bit memory at 0xfebf1000 [0xfebf1fff].
      id "virtio-serial0"
  Bus  0, device   6, function 2:
    PCI bridge: PCI device 1b36:0001
      IRQ 0.
      BUS 0.
      secondary bus 0.
      subordinate bus 0.
      IO range [0x0000, 0x0fff]
      memory range [0x00000000, 0x000fffff]
      prefetchable memory range [0x00000000, 0x000fffff]
      BAR0: 64 bit memory at 0xffffffffffffffff [0x000000fe].
      id "pci.1"
  Bus  0, device  15, function 0:
    SCSI controller: PCI device 1af4:1001
      IRQ 11.
      BAR0: I/O at 0xc040 [0xc07f].
      BAR1: 32 bit memory at 0xfebf2000 [0xfebf2fff].
      id "virtio-disk0"
  Bus  0, device  16, function 2:
    SCSI controller: PCI device 1af4:1001
      IRQ 0.
      BAR0: I/O at 0xffffffffffffffff [0x003e].
      BAR1: 32 bit memory at 0xffffffffffffffff [0x00000ffe].
      id "virtio-disk1"
  Bus  0, device  19, function 2:
    USB controller: PCI device 8086:7020
      IRQ 0.
      BAR4: I/O at 0xffffffffffffffff [0x001e].
      id "usb1"
  Bus  0, device  20, function 2:
    Class 1920: PCI device 1af4:1003
      IRQ 0.
      BAR0: I/O at 0xffffffffffffffff [0x001e].
      BAR1: 32 bit memory at 0xffffffffffffffff [0x00000ffe].
      id "virtio-serial1"
  Bus  0, device  30, function 0:
    SCSI controller: PCI device 1af4:1004
      IRQ 10.
      BAR0: I/O at 0xc080 [0xc0bf].
      BAR1: 32 bit memory at 0xfebf3000 [0xfebf3fff].
      id "scsi1"
  Bus  0, device  31, function 2:
    SCSI controller: PCI device 1af4:1004
      IRQ 0.
      BAR0: I/O at 0xffffffffffffffff [0x003e].
      BAR1: 32 bit memory at 0xffffffffffffffff [0x00000ffe].
      id "scsi0"

(qemu) info block
drive-virtio-disk0 (#block138): /mnt/nfs2/RHEL-7.3-latest.qcow2 (qcow2)
    Cache mode:       writeback

drive-virtio-disk1 (#block346): /mnt/nfs2/virtio1.img (qcow2)
    Cache mode:       writeback

ide1-cd0: [not inserted]
    Removable device: not locked, tray closed

floppy0: [not inserted]
    Removable device: not locked, tray closed

sd0: [not inserted]
    Removable device: not locked, tray closed

3. check in guest
guest]# lspci 
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:01.2 USB controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II] (rev 01)
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
00:02.0 VGA compatible controller: Cirrus Logic GD 5446
00:03.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8100/8101L/8139 PCI Fast Ethernet Adapter (rev 20)
00:05.0 Communication controller: Red Hat, Inc Virtio console
00:0f.0 SCSI storage controller: Red Hat, Inc Virtio block device
00:1e.0 SCSI storage controller: Red Hat, Inc Virtio SCSI

guest]# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda           252:0    0   10G  0 disk 
├─vda1        252:1    0  500M  0 part /boot
└─vda2        252:2    0  9.5G  0 part 
  ├─rhel-root 253:0    0  8.5G  0 lvm  /
  └─rhel-swap 253:1    0    1G  0 lvm  [SWAP]


Actual results:
pci bridge, 2nd virtio blk, 1st virtio scsi controller and 2nd virtio serial cannot be detected in guest.
If the function of a device's address is set to be !=0, it cannot be detected in guest

Expected results:
If the function of a device's address can be set to be !=0, device should work
If the function of a device's address can NOT be set to be !=0, provide proper error

Additional info:

Comment 2 Marcel Apfelbaum 2016-06-23 10:24:23 UTC
You cannot have a multi-function device without function 0.
Please try to add both functions 0 and 1 or 0,1,2.

Please let me know if that works.
Thanks,
Marcel

Comment 3 Yang Yang 2016-06-24 03:32:33 UTC
Multi-function device works if multifunction is enabled on function 0.

However, what confused me is that no messages are prompted when I use multi-function device without enabling multifunction on function 0. Do you think qemu, maybe libvirt should check whether multifunction is enabled on function 0 and provide prompt messages to users

Thanks
Yang

Comment 4 Marcel Apfelbaum 2016-06-24 15:22:16 UTC
(In reply to yangyang from comment #3)
> Multi-function device works if multifunction is enabled on function 0.
> 
> However, what confused me is that no messages are prompted when I use
> multi-function device without enabling multifunction on function 0. Do you
> think qemu, maybe libvirt should check whether multifunction is enabled on
> function 0 and provide prompt messages to users
> 
> Thanks
> Yang

Libvirt should definitely check function 0 is defined. For QEMU will not hurt either, but it is a minor bug. Please ensure Libvirt does it right and I'll keep this BZ as low priority.

Comment 5 Yang Yang 2016-06-27 10:30:11 UTC
Thanks Marcel,

I opened a bz against libvirt, Bug 1350391


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