scsi: fix searching for an empty id
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 15 Feb 2012 08:22:54 +0000 (09:22 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 24 Feb 2012 13:54:51 +0000 (14:54 +0100)
commitd3d250bddb3f6aa6c26e9dadf10e82d9fd8bfce3
tree574b7eda22a6880e41830d9c4bc98e1f695aa1ec
parent9fac25bf6ee6e3291ccb27feb9ad9b63506c7a60
scsi: fix searching for an empty id

The conditions for detecting no free target or LUN were wrong.

The LUN loop was followed by an "if" condition that is never
true, because the loop is exited as soon as lun becomes equal
to bus->info->max_lun, and never becomes greater than it.

The target loop had a wrong condition (<= instead of <).  Once
this is fixed, the loop would fail in the same way as the LUN
loop.

The fix is to see whether scsi_device_find returned the device with the
last (channel, target, LUN) pair, and fail if so.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/scsi-bus.c