From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNRF7-0008C9-9x for qemu-devel@nongnu.org; Fri, 20 May 2011 11:03:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QNRF6-0002Tb-4k for qemu-devel@nongnu.org; Fri, 20 May 2011 11:03:57 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:49685) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNRF6-0002SH-1x for qemu-devel@nongnu.org; Fri, 20 May 2011 11:03:56 -0400 Received: by mail-qw0-f45.google.com with SMTP id 8so2228093qwj.4 for ; Fri, 20 May 2011 08:03:55 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 20 May 2011 17:03:35 +0200 Message-Id: <1305903817-25476-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1305903817-25476-1-git-send-email-pbonzini@redhat.com> References: <1305903817-25476-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [RFC PATCH 4/6] scsi-disk: allow customization of the lun List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This will not work until there is a device that can answer REPORT LUNS for disks with LUN != 0. However, it provides the infrastructure. Signed-off-by: Paolo Bonzini --- hw/scsi-disk.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index b14c32f..f41550a 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -66,6 +66,7 @@ struct SCSIDiskState /* The qemu block layer uses a fixed 512 byte sector size. This is the number of 512 byte blocks in a single scsi sector. */ int cluster_size; + uint32_t lun; uint32_t removable; uint64_t max_lba; QEMUBH *bh; @@ -516,7 +517,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) memset(outbuf, 0, buflen); - if (req->lun) { + if (req->lun != s->lun) { outbuf[0] = 0x7f; /* LUN not supported */ return buflen; } @@ -955,6 +956,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r, uint8_t *outbuf) DPRINTF("Unsupported Service Action In\n"); goto illegal_request; case REPORT_LUNS: + assert(!s->lun); if (req->cmd.xfer < 16) goto illegal_request; memset(outbuf, 0, 16); @@ -1022,14 +1024,12 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf) } #endif - if (req->lun) { - /* Only LUN 0 supported. */ + if (command != REQUEST_SENSE && command != INQUIRY && req->lun != s->lun) { + /* Only one LUN supported. */ DPRINTF("Unimplemented LUN %d\n", req->lun); - if (command != REQUEST_SENSE && command != INQUIRY) { - scsi_command_complete(r, CHECK_CONDITION, - SENSE_CODE(LUN_NOT_SUPPORTED)); - return 0; - } + scsi_command_complete(r, CHECK_CONDITION, + SENSE_CODE(LUN_NOT_SUPPORTED)); + return 0; } switch (command) { case TEST_UNIT_READY: @@ -1247,6 +1247,7 @@ static SCSIDeviceInfo scsi_disk_info = { .get_sense = scsi_get_sense, .qdev.props = (Property[]) { DEFINE_BLOCK_PROPERTIES(SCSIDiskState, qdev.conf), + DEFINE_PROP_UINT32("lun", SCSIDiskState, lun, 0), DEFINE_PROP_STRING("ver", SCSIDiskState, version), DEFINE_PROP_STRING("serial", SCSIDiskState, serial), DEFINE_PROP_BIT("removable", SCSIDiskState, removable, 0, false), -- 1.7.4.4