Hide Forgot
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>
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>
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>
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.