Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1031062

Summary: Hotpluging second SCSI hostdev fails with duplicate ID
Product: Red Hat Enterprise Linux 7 Reporter: Jiri Denemark <jdenemar>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, dyuan, gsun, honzhang, mzhan, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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 09:55:10 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:
Embargoed:

Description Jiri Denemark 2013-11-15 14:41:15 UTC
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 14:42:44 UTC
Fixed upstream by v1.1.1-84-gc4eb120:

commit c4eb12067e020b0b30c34b0f8d67943da654761d
Author: Eric Farman <farman.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.ibm.com>
    Reviewed-by: Viktor Mihajlovski <mihajlov.ibm.com>

Comment 4 Xuesong Zhang 2013-11-27 09:04:40 UTC
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 09:55:10 UTC
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.