Bug 982224

Summary: Attaching of the Virtio-scsi [qcow2] drives fails with "error: internal error No more available PCI addresses"
Product: [Community] Virtualization Tools Reporter: chandrashekar shastri <cshastri>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: crobinso, rbalakri
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-10 00:11:50 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 chandrashekar shastri 2013-07-08 12:18:36 UTC
Description of problem:

If we try to attach the 256 Virtio-scsi [qcow2] drives it fails with an error as 

 "error: Failed to attach disk"
 "error: internal error No more available PCI addresses"

I reckon any linux machine supports 256 luns. 

Please refer to the below link:
https://community.emc.com/thread/90269

I have checked this issue on rhel and sles guests. I could add only 214 devices 
and started getting from 215th lun:

formatting '/home/images/virtio-scsi215.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 lazy_refcounts=off 
error: Failed to attach disk
error: internal error No more available PCI addresses

26 scsi controllers were added for these 214 devices.

<controller type='scsi' index='23'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1c' function='0x0'/>
    </controller>
    <controller type='scsi' index='24'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x0'/>
    </controller>
    <controller type='scsi' index='25'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
    </controller>
    <controller type='scsi' index='26'>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x01' function='0x0'/>
    </controller>

Comment 1 chandrashekar shastri 2013-07-09 06:11:07 UTC
Script to create 256 volumes and attach to the guest.

####################################################

#!/usr/bin/bash
if [ x$1 != x ]; then
cmd=$1
c=1
while [ $c -le 256 ]
do
qemu-img create -f qcow2 /home/virtio-scsi$c.qcow2 1G
#sleep 1
i="`cat file | head -$c | tail -1`"
virsh attach-disk $cmd /home/images/virtio-scsi$c.qcow2 $i --persistent  --cache writethrough --sourcetype file --driver qemu --subdriver qcow2
#virsh detach-disk $cmd $i
 ((c++))
done
else
echo "enter the vm name"
fi

####################################################

Comment 2 Cole Robinson 2016-04-10 00:11:50 UTC
There's some more info here about scsi controller limitations:

https://www.redhat.com/archives/libvir-list/2013-November/msg01122.html

And FWIW running your script, but using virt-xml instead of virsh, works fine:

Domain 'scsi-test' defined successfully.
Disk #256
Domain 'scsi-test' defined successfully.