Bug 597968 - Should not allow one physical NIC card to be assigned to one guest for many times
Summary: Should not allow one physical NIC card to be assigned to one guest for many t...
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
(Show other bugs)
Version: 6.0
Hardware: All Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Alex Williamson
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-05-31 06:21 UTC by Qunfang Zhang
Modified: 2013-01-09 22:38 UTC (History)
7 users (show)

Fixed In Version: qemu-kvm-0.12.1.2-2.87.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-07-06 05:16:19 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Qunfang Zhang 2010-05-31 06:21:14 UTC
Description of problem:
Boot a guest with physical NIC card assigned and then do many times hot-plug,assigning the same device to the guest,"info pci" tells me there are too many same device.

In fact, the first time I hot plug the NIC card, there's prompt:
Failed to assign device "02:00.0" : File exists
Device 'pci-assign' could not be initialized
failed to add host=02:00.0

BUT I do the same operation again, device is hot-plugged.
OK domain 0, bus 0, slot 10, function 0


Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.68.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
1.Boot a guest with physical NIC card assigned.
/usr/libexec/qemu-kvm -no-hpet -usbdevice tablet -rtc-td-hack -no-kvm-pit-reinjection -startdate now -drive file=win2003-32-virtio.qcow2,media=disk,if=virtio,boot=on,cache=off,index=0 -net nic,vlan=0,macaddr=10:1a:4a:10:90:8f,model=e1000 -net tap,vlan=0,script=/etc/qemu-ifup -cpu qemu64,+sse2 -balloon none -uuid `uuidgen` -monitor stdio -m 2G -smp 2 -boot c -spice port=5930,disable-ticketing -vga qxl -pcidevice host=02:00.0
2.After guest boot up, hot plug the pci device again in the qemu monitor.
(qemu)pci_add pci_addr=auto host host=02:00.0
3.Repeat step 2 for many times.
4.(qemu)info pci
  
Actual results:
The same device will be assigned for many times.

Expected results:
One device should be only assigned for one time.

Additional info:

Comment 2 Markus Armbruster 2010-06-05 06:18:14 UTC
Does the problem exist with device_add instead of pci_add as well?  To test, try something like "pci-assign,host=ADDR,iommu=IOMMU,id=ID".

Comment 3 Qunfang Zhang 2010-06-09 10:31:19 UTC
(In reply to comment #2)
> Does the problem exist with device_add instead of pci_add as well?  To test,
> try something like "pci-assign,host=ADDR,iommu=IOMMU,id=ID".    

Sorry for reply so late because I attend NHO on Monday and Tuesday.

Yes, this issue also exists with device_add.

BTW, Markus, could you tell me the 'host','iommu' and 'id' should take what values? (can you give me an example?)

(qemu) device_add pci-assign,host=02:00.0,iommu=IOMMU,id=host_dev
Property 'pci-assign.iommu' doesn't take value 'IOMMU'
 
So, I only test with the following options:
(qemu) device_add pci-assign,host=02:00.0

And this issue still exists

Comment 4 Markus Armbruster 2010-06-09 11:19:27 UTC
Thanks, that's fine.  I shouldn't have mentioned iommu, it's device_add's way to do old -pcidevice's dma=[none|iommu].

Comment 5 Alex Williamson 2010-06-10 16:35:38 UTC
Posted upstream patch http://www.spinics.net/lists/kvm/msg36376.html

Comment 9 juzhang 2010-07-06 05:14:46 UTC
Reproduced on qemu-kvm-0.12.1.2-2.82.el6.x86_64,pass

After executed "(qemu) device_add pci-assign,host=28:00.0"  3 times 

Results:
(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 0xc000 [0xc00f].
      id ""
  Bus  0, device   1, function 3:
    Bridge: PCI device 8086:7113
      IRQ 9.
      id ""
  Bus  0, device   2, function 0:
    VGA controller: PCI device 1013:00b8
      BAR0: 32 bit prefetchable memory at 0xf0000000 [0xf1ffffff].
      BAR1: 32 bit memory at 0xf2000000 [0xf2000fff].
      BAR6: 32 bit memory at 0xffffffffffffffff [0x0000fffe].
      id ""
  Bus  0, device   3, function 0:
    SCSI controller: PCI device 1af4:1001
      IRQ 11.
      BAR0: I/O at 0xc040 [0xc07f].
      BAR1: 32 bit memory at 0xf2020000 [0xf2020fff].
      id "virtio-disk0"
  Bus  0, device   4, function 0:
    Ethernet controller: PCI device 1af4:1000
      IRQ 11.
      BAR0: I/O at 0xc080 [0xc09f].
      BAR1: 32 bit memory at 0xf2021000 [0xf2021fff].
      BAR6: 32 bit memory at 0xffffffffffffffff [0x0000fffe].
      id "net0"
  Bus  0, device   5, function 0:
    RAM controller: PCI device 1af4:1002
      IRQ 10.
      BAR0: I/O at 0xc0a0 [0xc0bf].
      id ""
  Bus  0, device   6, function 0:
    Ethernet controller: PCI device 8086:10b9
      IRQ 10.
      BAR0: 32 bit memory at 0xf2040000 [0xf205ffff].
      BAR1: 32 bit memory at 0xf2060000 [0xf207ffff].
      BAR2: I/O at 0xc0c0 [0xc0df].
      BAR6: 32 bit prefetchable memory at 0xffffffffffffffff [0x0001fffe].
      id "28:00.0"
  Bus  0, device   7, function 0:
    Ethernet controller: PCI device 8086:10b9
      IRQ 3.
      BAR0: 32 bit memory at 0xe0000000 [0xe001ffff].
      BAR1: 32 bit memory at 0xe0020000 [0xe003ffff].
      BAR2: I/O at 0x1000 [0x101f].
      BAR6: 32 bit prefetchable memory at 0xffffffffffffffff [0x0001fffe].
      id ""
  Bus  0, device   8, function 0:
    Ethernet controller: PCI device 8086:10b9
      IRQ 3.
      BAR0: 32 bit memory at 0xe0060000 [0xe007ffff].
      BAR1: 32 bit memory at 0xe0080000 [0xe009ffff].
      BAR2: I/O at 0x1020 [0x103f].
      BAR6: 32 bit prefetchable memory at 0xffffffffffffffff [0x0001fffe].
      id ""

Please note: function 6,7,8

Verified on qemu-kvm-0.12.1.2-2.90.el6.x86_64,pass

1. Unbind device from host kernel driver (PCI device 28:00.0)
1.1 lspci | grep Ethernet
lspci | grep Ethernet
01:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5764M Gigabit Ethernet PCIe (rev 10)
03:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
03:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
28:00.0 Ethernet controller: Intel Corporation 82572EI Gigabit Ethernet Controller (Copper) (rev 06)
1.2. #lspci -n | grep 28:00.0
28:00.0 0200: 8086:10b9 (rev 06)
1.3 echo "8086 10b9" >/sys/bus/pci/drivers/pci-stub/new_id
1.4 echo 0000:28:00.0 >/sys/bus/pci/devices/0000\:28\:00.0/driver/unbind
1.5 echo 0000:28:00.0 >/sys/bus/pci/drivers/pci-stub/bind
2. Boot guest with virtual and physical NIC card.
/usr/libexec/qemu-kvm -m 4G -smp 4 -drive file=/root/zhangjunyi/rhel6.32.raw,if=none,id=drive-virtio-disk0,boot=on,cache=none,format=raw -device virtio-blk-pci,bus=pci.0,drive=drive-virtio-disk0,id=virtio-disk0 -netdev tap,id=hostnet0,vhost=on -device virtio-net-pci,netdev=hostnet0,id=net0,mac=22:11:22:45:66:97 -device virtio-balloon-pci -cpu qemu64,+sse2,+x2apic -monitor stdio -vnc :10 -qmp tcp:0:4445,server,nowait -drive file=/root/zhangjunyi/boot.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,drive=drive-ide0-1-0 -boot c -pcidevice host=28:00.0
3.Issue the following commands three times
(qemu) device_add pci-assign,host=28:00.0
4.Issue the following commands 
(qemu) info pci

results:

After step3,(qemu) device_add pci-assign,host=28:00.0
Failed to assign device "(null)" : File exists
Device 'pci-assign' could not be initialized

After step4

(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 0xc000 [0xc00f].
      id ""
  Bus  0, device   1, function 3:
    Bridge: PCI device 8086:7113
      IRQ 9.
      id ""
  Bus  0, device   2, function 0:
    VGA controller: PCI device 1013:00b8
      BAR0: 32 bit prefetchable memory at 0xf0000000 [0xf1ffffff].
      BAR1: 32 bit memory at 0xf2000000 [0xf2000fff].
      BAR6: 32 bit memory at 0xffffffffffffffff [0x0000fffe].
      id ""
  Bus  0, device   3, function 0:
    SCSI controller: PCI device 1af4:1001
      IRQ 11.
      BAR0: I/O at 0xc040 [0xc07f].
      BAR1: 32 bit memory at 0xf2020000 [0xf2020fff].
      id "virtio-disk0"
  Bus  0, device   4, function 0:
    Ethernet controller: PCI device 1af4:1000
      IRQ 11.
      BAR0: I/O at 0xc080 [0xc09f].
      BAR1: 32 bit memory at 0xf2021000 [0xf2021fff].
      BAR6: 32 bit memory at 0xffffffffffffffff [0x0000fffe].
      id "net0"
  Bus  0, device   5, function 0:
    RAM controller: PCI device 1af4:1002
      IRQ 10.
      BAR0: I/O at 0xc0a0 [0xc0bf].
      id ""
  Bus  0, device   6, function 0:
    Ethernet controller: PCI device 8086:10b9
      IRQ 10.
      BAR0: 32 bit memory at 0xf2040000 [0xf205ffff].
      BAR1: 32 bit memory at 0xf2060000 [0xf207ffff].
      BAR2: I/O at 0xc0c0 [0xc0df].
      BAR6: 32 bit prefetchable memory at 0xffffffffffffffff [0x0001fffe].
      id "28:00.0"

Please note just function6

Comment 10 juzhang 2010-07-06 05:16:19 UTC
according to comment9,close this issue.


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