Patchwork [RFC,v2,13/13] scsi: delete handling of REPORT LUNS and unknown LUNs outside scsi-target

login
register
mail settings
Submitter Paolo Bonzini
Date June 6, 2011, 4:04 p.m.
Message ID <1307376262-1255-14-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/98965/
State New
Headers show

Comments

Paolo Bonzini - June 6, 2011, 4:04 p.m.
This removes scsi-disk and scsi-generic's handling of requests
that should be entirely within the realm of the target.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi-disk.c    |   23 +----------------------
 hw/scsi-generic.c |   34 +++-------------------------------
 2 files changed, 4 insertions(+), 53 deletions(-)

Patch

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 0a4fbee..60e96a0 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -517,12 +517,6 @@  static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
         buflen = SCSI_MAX_INQUIRY_LEN;
 
     memset(outbuf, 0, buflen);
-
-    if (req->lun != s->qdev.lun) {
-        outbuf[0] = 0x7f;	/* LUN not supported */
-        return buflen;
-    }
-
     if (s->drive_kind == SCSI_CD) {
         outbuf[0] = 5;
         outbuf[1] = 0x80;
@@ -956,13 +950,6 @@  static int scsi_disk_emulate_command(SCSIDiskReq *r, uint8_t *outbuf)
         }
         DPRINTF("Unsupported Service Action In\n");
         goto illegal_request;
-    case REPORT_LUNS:
-        if (req->cmd.xfer < 16)
-            goto illegal_request;
-        memset(outbuf, 0, 16);
-        outbuf[3] = 8;
-        buflen = 16;
-        break;
     case VERIFY:
         break;
     case REZERO_UNIT:
@@ -1024,15 +1011,7 @@  static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
     }
 #endif
 
-    if (req->lun != s->qdev.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;
-        }
-    }
+    assert(req->lun == s->qdev.lun);
     switch (command) {
     case TEST_UNIT_READY:
     case REQUEST_SENSE:
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index e1f9d0e..5912a3d 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -231,11 +231,9 @@  static void scsi_read_data(SCSIRequest *req)
         return;
     }
 
-    switch (r->req.cmd.buf[0]) {
-    case REQUEST_SENSE:
-        if (!(s->driver_status & SG_ERR_DRIVER_SENSE)) {
-            break;
-        }
+    assert(req->lun == s->qdev.lun);
+    if (r->req.cmd.buf[0] == REQUEST_SENSE &&
+        !(s->driver_status & SG_ERR_DRIVER_SENSE)) {
         s->senselen = MIN(r->len, s->senselen);
         memcpy(r->buf, s->sensebuf, s->senselen);
         r->io_header.driver_status = 0;
@@ -250,32 +248,6 @@  static void scsi_read_data(SCSIRequest *req)
         /* Clear sensebuf after REQUEST_SENSE */
         scsi_clear_sense(s);
         return;
-
-    case REPORT_LUNS:
-	assert(!s->qdev.lun);
-        if (r->req.cmd.xfer < 16) {
-            scsi_command_complete(r, -EINVAL);
-            return;
-        }
-        r->io_header.driver_status = 0;
-        r->io_header.status = 0;
-        r->io_header.dxfer_len  = 16;
-        r->len = -1;
-        r->buf[3] = 8;
-        scsi_req_data(&r->req, 16);
-        scsi_command_complete(r, 0);
-        return;
-
-    case INQUIRY:
-        if (req->lun != s->qdev.lun) {
-            if (r->req.cmd.xfer < 1) {
-                scsi_command_complete(r, -EINVAL);
-                return;
-            }
-            r->buf[0] = 0x7f;
-            return;
-        }
-        break;
     }
 
     ret = execute_command(s->bs, r, SG_DXFER_FROM_DEV, scsi_read_complete);