Bug 1031062 - Hotpluging second SCSI hostdev fails with duplicate ID
Hotpluging second SCSI hostdev fails with duplicate ID
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.0
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Jiri Denemark
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-15 09:41 EST by Jiri Denemark
Modified: 2014-06-17 20:59 EDT (History)
6 users (show)

See Also:
Fixed In Version: libvirt-1.1.1-13.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-06-13 05:55:10 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jiri Denemark 2013-11-15 09:41:15 EST
Description of problem:

Libvirt always generates hostdev0 device alias when adding SCSI hostdev devices. Thus only one device can be plugged in and attempts to plug additional devices fail with "Duplicate ID 'hostdev0' for device".

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

libvirt-1.1.1-12.el7.x86_64

How reproducible:

100%

Steps to Reproduce:
1. start a domain with SCSI controller
2. virsh attach-device DOMAIN dev1.xml
3. virsh attach-device DOMAIN dev2.xml

Actual results:

error: internal error: unable to execute QEMU command 'device_add': Duplicate ID 'hostdev0' for device

Expected results:

It should just work.

Additional info:

Examples of dev[12].xml (change source addresses appropriately):

dev1.xml:

<hostdev mode='subsystem' type='scsi'>
  <source>
    <adapter name='scsi_host4'/>
    <address bus='0' target='0' unit='0'/>
  </source>
  <readonly/>
  <address type='drive' controller='0' bus='0' target='0' unit='0'/>
</hostdev>

dev2.xml

<hostdev mode='subsystem' type='scsi'>
  <source>
    <adapter name='scsi_host9'/>
    <address bus='0' target='0' unit='0'/>
  </source>
  <readonly/>
  <address type='drive' controller='0' bus='0' target='0' unit='1'/>
</hostdev>
Comment 1 Jiri Denemark 2013-11-15 09:42:44 EST
Fixed upstream by v1.1.1-84-gc4eb120:

commit c4eb12067e020b0b30c34b0f8d67943da654761d
Author: Eric Farman <farman@linux.vnet.ibm.com>
Date:   Thu Aug 8 13:26:50 2013 +0200

    qemu: Allow hotplug of multiple SCSI devices
    
    Hotplugging a single SCSI device works, but adding additional ones
    result in an error from QEMU:
    
    [root@gpok197 ~]# virsh attach-device guest01 blah.xml
    Device attached successfully
    [root@gpok197 ~]# virsh attach-device guest01 blah2.xml
    error: Failed to attach device from blah2.xml
    error: internal error unable to execute QEMU command 'device_add': Duplicate ID 'hostdev0' for device
    
    The hostdev ID that is created is always set to zero, regardless
    of the contents of the XML.  Changing the index in the hotplug case
    to a negative one so the next available index is used.
    
    Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
    Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Comment 4 Xuesong Zhang 2013-11-27 04:04:40 EST
Test with the latest libvirt build , this bug is fixed. Change the bug status to "verify".

Steps:
1. check the scsi device on the host.
#virsh nodedev-list --tree
......
  |   +- scsi_host0
  |   |   |
  |   |   +- scsi_target0_0_0
  |   |       |
  |   |       +- scsi_0_0_0_0
  |   |           |
  |   |           +- block_sda_SAMSUNG_HD502IJ_S1W3J9FZ101727
  |   |           +- scsi_generic_sg0
  |   |             
  |   +- scsi_host1
  |   |   |
  |   |   +- scsi_target1_0_0
  |   |       |
  |   |       +- scsi_1_0_0_0
  |   |           |
  |   |           +- block_sr0_hp_DDVDW_TS_H653R_R0626GAZ11057400
  |   |           +- scsi_generic_sg1
  |   |             
  |   +- scsi_host2
  |   |   |
  |   |   +- scsi_target2_0_0
  |   |       |
  |   |       +- scsi_2_0_0_0
  |   |           |
  |   |           +- block_sdb_ST3500418AS_9VMGHLCY
  |   |           +- scsi_generic_sg2
  |   |             
......

2. prepare the following 2 scsi device xml for the hot-plug.
]# cat scsi-device.xml 
<hostdev mode='subsystem' type='scsi' managed='no'>
    <source>
      <adapter name='scsi_host0'/>
      <address bus='0' target='0' unit='0'/>
    </source>
  </hostdev>
[root@sriov1 xuzhang]# cat scsi-device2.xml 
<hostdev mode='subsystem' type='scsi' managed='no'>
    <source>
      <adapter name='scsi_host1'/>
      <address bus='0' target='0' unit='0'/>
    </source>
  </hostdev>

3. hot-plug the scsi device to one running guest.
# virsh attach-device a scsi-device.xml 
Device attached successfully

[root@sriov1 xuzhang]# virsh attach-device a scsi-device2.xml 
Device attached successfully


4. check the guest xml.
# virsh dumpxml a|grep hostdev -A 4
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host0'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host1'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <alias name='hostdev1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </hostdev>
Comment 5 Ludek Smid 2014-06-13 05:55:10 EDT
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.

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