From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoX94-00063Z-0i for qemu-devel@nongnu.org; Wed, 03 Aug 2011 04:49:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QoX8x-0003iQ-FM for qemu-devel@nongnu.org; Wed, 03 Aug 2011 04:49:41 -0400 Received: from mail-ww0-f53.google.com ([74.125.82.53]:42749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoX8w-0003g6-E5 for qemu-devel@nongnu.org; Wed, 03 Aug 2011 04:49:34 -0400 Received: by mail-ww0-f53.google.com with SMTP id 26so527679wwf.10 for ; Wed, 03 Aug 2011 01:49:34 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 3 Aug 2011 10:49:12 +0200 Message-Id: <1312361359-15445-10-git-send-email-pbonzini@redhat.com> In-Reply-To: <1312361359-15445-1-git-send-email-pbonzini@redhat.com> References: <1312361359-15445-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 09/16] scsi: push lun field to SCSIDevice List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This will let SCSIBus detect requests sent to an invalid LUN, and handle them itself. However, there will be still support for only one LUN per target Signed-off-by: Paolo Bonzini --- hw/scsi-bus.c | 1 + hw/scsi-generic.c | 5 +---- hw/scsi.h | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 579f6b4..07d8704 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -16,6 +16,7 @@ static struct BusInfo scsi_bus_info = { .get_fw_dev_path = scsibus_get_fw_dev_path, .props = (Property[]) { DEFINE_PROP_UINT32("scsi-id", SCSIDevice, id, -1), + DEFINE_PROP_UINT32("lun", SCSIDevice, lun, 0), DEFINE_PROP_END_OF_LIST(), }, }; diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index 453a295..699831a 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -60,7 +60,6 @@ struct SCSIGenericState { SCSIDevice qdev; BlockDriverState *bs; - int lun; }; static void scsi_free_request(SCSIRequest *req) @@ -292,7 +291,7 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *cmd) SCSIGenericReq *r = DO_UPCAST(SCSIGenericReq, req, req); int ret; - if (cmd[0] != REQUEST_SENSE && req->lun != s->lun) { + if (cmd[0] != REQUEST_SENSE && req->lun != s->qdev.lun) { DPRINTF("Unimplemented LUN %d\n", req->lun); scsi_req_build_sense(&r->req, SENSE_CODE(LUN_NOT_SUPPORTED)); scsi_req_complete(&r->req, CHECK_CONDITION); @@ -466,8 +465,6 @@ static int scsi_generic_initfn(SCSIDevice *dev) } /* define device state */ - s->lun = scsiid.lun; - DPRINTF("LUN %d\n", s->lun); s->qdev.type = scsiid.scsi_type; DPRINTF("device type %d\n", s->qdev.type); if (s->qdev.type == TYPE_TAPE) { diff --git a/hw/scsi.h b/hw/scsi.h index f29d65f..5a1bbe2 100644 --- a/hw/scsi.h +++ b/hw/scsi.h @@ -65,6 +65,7 @@ struct SCSIDevice uint8_t sense[SCSI_SENSE_BUF_SIZE]; uint32_t sense_len; QTAILQ_HEAD(, SCSIRequest) requests; + uint32_t lun; int blocksize; int type; }; -- 1.7.6