Bug 1165029

Summary: need to expose PCI address of ivshmem device
Product: Red Hat Enterprise Linux 7 Reporter: Jincheng Miao <jmiao>
Component: libvirtAssignee: Martin Kletzander <mkletzan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, honzhang, mzhan, rbalakri
Target Milestone: rcKeywords: Upstream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.17-4.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 05:56:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Jincheng Miao 2014-11-18 07:32:17 UTC
Description of problem:
Currently, libvirt doesn't expose PCI address of ivshmem device,
so that it causes many problem of hot-(un)plug PCI devices.
For example, failed to attach interface for the guest connected to ivshmem server.

version:
libvirt-1.2.8-6.el7.x86_64
qemu-kvm-rhev-2.1.2-7.el7.x86_64

How reproducible:
100%

Step to reproduce:
1. start guest with ivshmem
# virsh dumpxml r70
...
 <devices>
  ...
  <shmem name='shmem0'>
      <size unit='M'>4</size>
  </shmem>
  ...
</devices>
...

# virsh start r70

2. query guest's PCI devices
# virsh qemu-monitor-command r70 --hmp info pci
...
  Bus  0, device   9, function 0:
    RAM controller: PCI device 1af4:1110
      IRQ 10.
      BAR0: 32 bit memory at 0xfc05a000 [0xfc05a0ff].
      BAR2: 64 bit prefetchable memory at 0xfd000000 [0xfdffffff].
      id ""

3. hot-plug a vNIC
# virsh attach-interface r70 network default
error: Failed to attach interface
error: internal error: unable to execute QEMU command 'device_add': Device initialization failed.

4. check from libvirtd.log
2014-11-17 08:49:58.121+0000: 29931: debug : qemuMonitorSend:976 : QEMU_MONITOR_SEND_MSG: mon=0x7f2c94002b50 msg={"execute":"getfd","arguments":{"fdname":"fd-net10"},"id":"libvirt-12"}
...
2014-11-17 08:49:58.123+0000: 29929: debug : qemuMonitorJSONIOProcessLine:201 : QEMU_MONITOR_RECV_REPLY: mon=0x7f2c94002b50 reply={"return": {}, "id": "libvirt-12"}
...
2014-11-17 08:49:58.123+0000: 29931: debug : qemuMonitorSend:976 : QEMU_MONITOR_SEND_MSG: mon=0x7f2c94002b50 msg={"execute":"netdev_add","arguments":{"type":"tap","fd":"fd-net10","id":"hostnet1"},"id":"libvirt-13"}
...
2014-11-17 08:49:58.125+0000: 29929: debug : qemuMonitorJSONIOProcessLine:201 : QEMU_MONITOR_RECV_REPLY: mon=0x7f2c94002b50 reply={"return": {}, "id": "libvirt-13"}
...
2014-11-17 08:49:58.126+0000: 29931: debug : qemuMonitorSend:976 : QEMU_MONITOR_SEND_MSG: mon=0x7f2c94002b50 msg={"execute":"device_add","arguments":{"driver":"rtl8139","netdev":"hostnet1","id":"net1","mac":"52:54:00:cd:5e:12","bus":"pci.0","addr":"0x9"},"id":"libvirt-14"}
...
2014-11-17 08:49:58.129+0000: 29929: debug : qemuMonitorJSONIOProcessLine:201 : QEMU_MONITOR_RECV_REPLY: mon=0x7f2c94002b50 reply={"id": "libvirt-14", "error": {"class": "GenericError", "desc": "Device initialization failed."}}
...
2014-11-17 08:49:58.130+0000: 29931: debug : qemuMonitorSend:976 : QEMU_MONITOR_SEND_MSG: mon=0x7f2c94002b50 msg={"execute":"netdev_del","arguments":{"id":"hostnet1"},"id":"libvirt-15"}
...
2014-11-17 08:49:58.143+0000: 29929: debug : qemuMonitorJSONIOProcessLine:201 : QEMU_MONITOR_RECV_REPLY: mon=0x7f2c94002b50 reply={"return": {}, "id": "libvirt-15"}
...

Expect results:
expose PCI address of ivshmem device, and make hot-plugging devices working.

Comment 2 Martin Kletzander 2015-07-08 14:33:04 UTC
Fixed upstream with v1.2.17-44-ge309ea665807:

commit e309ea66580798860154c70f275c56236702c7dc
Author:     Luyao Huang <lhuang>
AuthorDate: Wed Jun 17 11:56:12 2015 +0800

    qemu: Auto assign pci addresses for shared memory devices

Comment 5 hongming 2015-09-02 06:15:35 UTC
Verify it as follows. The result is expected. Move its status to VERIFIED.


# rpm -q libvirt
libvirt-1.2.17-6.el7.x86_64

# virsh edit r7.1
.....
  <shmem name='shmem0'>
      <size unit='M'>4</size>
  </shmem>
......

Domain r7.1 XML configuration edited.

# virsh start r7.1
Domain r7.1 started

# virsh dumpxml r7.1|grep /shmem -B4
    <shmem name='shmem0'>
      <size unit='M'>4</size>
      <alias name='shmem0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </shmem>

# virsh qemu-monitor-command r7.1 --hmp 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 0xc1c0 [0xc1cf].
      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 1b36:0100
      IRQ 10.
      BAR0: 32 bit memory at 0xf4000000 [0xf7ffffff].
      BAR1: 32 bit memory at 0xf8000000 [0xfbffffff].
      BAR2: 32 bit memory at 0xfc054000 [0xfc055fff].
      BAR3: I/O at 0xc100 [0xc11f].
      BAR6: 32 bit memory at 0xffffffffffffffff [0x0000fffe].
      id "video0"
  Bus  0, device   3, function 0:
    Ethernet controller: PCI device 10ec:8139
      IRQ 11.
      BAR0: I/O at 0xc000 [0xc0ff].
      BAR1: 32 bit memory at 0xfc056000 [0xfc0560ff].
      BAR6: 32 bit memory at 0xffffffffffffffff [0x0003fffe].
      id "net0"
  Bus  0, device   4, function 0:
    Audio controller: PCI device 8086:2668
      IRQ 11.
      BAR0: 32 bit memory at 0xfc050000 [0xfc053fff].
      id "sound0"
  Bus  0, device   5, function 0:
    Class 1920: PCI device 1af4:1003
      IRQ 10.
      BAR0: I/O at 0xc120 [0xc13f].
      BAR1: 32 bit memory at 0xfc057000 [0xfc057fff].
      id "virtio-serial0"
  Bus  0, device   6, function 0:
    USB controller: PCI device 8086:2934
      IRQ 10.
      BAR4: I/O at 0xc140 [0xc15f].
      id ""
  Bus  0, device   6, function 1:
    USB controller: PCI device 8086:2935
      IRQ 11.
      BAR4: I/O at 0xc160 [0xc17f].
      id ""
  Bus  0, device   6, function 2:
    USB controller: PCI device 8086:2936
      IRQ 11.
      BAR4: I/O at 0xc180 [0xc19f].
      id ""
  Bus  0, device   6, function 7:
    USB controller: PCI device 8086:293a
      IRQ 10.
      BAR0: 32 bit memory at 0xfc058000 [0xfc058fff].
      id "usb"
  Bus  0, device   7, function 0:
    Class 0255: PCI device 1af4:1002
      IRQ 11.
      BAR0: I/O at 0xc1a0 [0xc1bf].
      id "balloon0"
  Bus  0, device   9, function 0:
    RAM controller: PCI device 1af4:1110
      IRQ 10.
      BAR0: 32 bit memory at 0xfc059000 [0xfc0590ff].
      BAR2: 64 bit prefetchable memory at 0xfe800000 [0xfebfffff].
      id ""


# virsh attach-interface r7.1 network default
Interface attached successfully

Comment 7 errata-xmlrpc 2015-11-19 05:56:08 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.

https://rhn.redhat.com/errata/RHBA-2015-2202.html