Bug 1369311

Summary: Scsi-hd device have no free target when add it's command after the usb-storage device's
Product: Red Hat Enterprise Linux 7 Reporter: Xujun Ma <xuma>
Component: qemu-kvm-rhevAssignee: Gerd Hoffmann <kraxel>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.3CC: chayang, juzhang, knoel, qzhang, virt-maint, xfu, yduan
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-01-09 15:11:12 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 Xujun Ma 2016-08-23 06:13:50 UTC
Description of problem:
Scsi-hd device have no free target when add it's cmdline after the usb-storage device's

Version-Release number of selected component (if applicable):
qemu-img-rhev-2.6.0-22.el7.ppc64le

How reproducible:
100%

Steps to Reproduce:
1.Boot vm with command:
/usr/libexec/qemu-kvm \
 -name vm \
 -smp 4 \
 -m 8192 \
 -monitor stdio \
 -vnc 0:59 \
 -qmp tcp:0:9999,server,nowait \
 -device virtio-scsi-pci,bus=pci.0\
 -device nec-usb-xhci,id=controller \
 -device usb-tablet,id=usbtablet \
 -drive file=data.qcow2,if=none,id=driveusb,media=disk,format=qcow2,cache=none \
 -device usb-storage,drive=driveusb,id=usbdisk,bus=controller.0,removable=on \
 -device scsi-hd,id=scsi-hd0,drive=scsi-hd-dr0,bootindex=0 \
 -drive file=/home/RHEL-Server-7.3-ppc64le-virtio.qcow2,if=none,id=scsi-hd-dr0,format=qcow2,cache=none \
2.
3.

Actual results:
Booting vm failed with error as following:
(qemu) qemu-kvm: -device scsi-hd,id=scsi-hd0,drive=scsi-hd-dr0,bootindex=0: no free target

Expected results:
Booting vm succeed without any error

Additional info:
x86 has this issue too.

Comment 2 Gerd Hoffmann 2017-01-09 15:11:12 UTC
(In reply to Xujun Ma from comment #0)
> Description of problem:
> Scsi-hd device have no free target when add it's cmdline after the
> usb-storage device's

usb-storage is a scsi host adapter too, so you now have two of them in the system.  Which in turn implies that you have to explicitly tell qemu which adapter you want attach your scsi devices to.

>  -device virtio-scsi-pci,bus=pci.0\

Use "id=${name}" to attach a name to the controller.

>  -device scsi-hd,id=scsi-hd0,drive=scsi-hd-dr0,bootindex=0 \

Use "bus=${name}.0" to tell which host controller should be used.