aboutsummaryrefslogtreecommitdiff
path: root/hw/spapr_vscsi.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2011-08-13 18:55:17 +0200
committerKevin Wolf <kwolf@redhat.com>2011-10-28 19:25:51 +0200
commit7e0380b9bbf7c40361e06e6e0d8675a55bd0dea0 (patch)
tree47c51c55182c17aaf6cdfc461ace0ef497c1a664 /hw/spapr_vscsi.c
parentba74307c5a3c2ff87d4596a10828faf7560d4552 (diff)
downloadqemu-7e0380b9bbf7c40361e06e6e0d8675a55bd0dea0.zip
qemu-7e0380b9bbf7c40361e06e6e0d8675a55bd0dea0.tar.gz
qemu-7e0380b9bbf7c40361e06e6e0d8675a55bd0dea0.tar.bz2
scsi: allow arbitrary LUNs
This only requires changes in two places: in SCSIBus, we need to look for a free LUN if somebody creates a device with a pre-existing scsi-id but the default LUN (-1, meaning "search for a free spot"); in vSCSI, we need to actually parse the LUN according to the SCSI spec. For vSCSI, max_target/max_lun are set according to the logical unit addressing format in SAM. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/spapr_vscsi.c')
-rw-r--r--hw/spapr_vscsi.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c
index ea3bb08..e6c3581 100644
--- a/hw/spapr_vscsi.c
+++ b/hw/spapr_vscsi.c
@@ -131,9 +131,39 @@ static void vscsi_put_req(vscsi_req *req)
static SCSIDevice *vscsi_device_find(SCSIBus *bus, uint64_t srp_lun, int *lun)
{
- /* XXX Figure that one out properly ! This is crackpot */
- int id = (srp_lun >> 56) & 0x7f;
- *lun = (srp_lun >> 48) & 0xff;
+ int channel = 0, id = 0;
+
+retry:
+ switch (srp_lun >> 62) {
+ case 0:
+ if ((srp_lun >> 56) != 0) {
+ channel = (srp_lun >> 56) & 0x3f;
+ id = (srp_lun >> 48) & 0xff;
+ srp_lun <<= 16;
+ goto retry;
+ }
+ *lun = (srp_lun >> 48) & 0xff;
+ break;
+
+ case 1:
+ *lun = (srp_lun >> 48) & 0x3fff;
+ break;
+ case 2:
+ channel = (srp_lun >> 53) & 0x7;
+ id = (srp_lun >> 56) & 0x3f;
+ *lun = (srp_lun >> 48) & 0x1f;
+ break;
+ case 3:
+ *lun = -1;
+ return NULL;
+ default:
+ abort();
+ }
+
+ if (channel) {
+ *lun = -1;
+ return NULL;
+ }
return scsi_device_find(bus, id, *lun);
}
@@ -862,7 +892,8 @@ static int vscsi_do_crq(struct VIOsPAPRDevice *dev, uint8_t *crq_data)
static const struct SCSIBusInfo vscsi_scsi_info = {
.tcq = true,
- .ndev = VSCSI_REQ_LIMIT,
+ .max_target = 63, /* logical unit addressing format */
+ .max_lun = 31,
.transfer_data = vscsi_transfer_data,
.complete = vscsi_command_complete,