qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [4260] Fix scsi-disk sense-key/status confusion (Marcelo Tosatti).
@ 2008-04-26 15:56 Andrzej Zaborowski
  2008-04-27 19:52 ` Blue Swirl
  0 siblings, 1 reply; 3+ messages in thread
From: Andrzej Zaborowski @ 2008-04-26 15:56 UTC (permalink / raw)
  To: qemu-devel

Revision: 4260
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4260
Author:   balrog
Date:     2008-04-26 15:56:05 +0000 (Sat, 26 Apr 2008)

Log Message:
-----------
Fix scsi-disk sense-key/status confusion (Marcelo Tosatti).

Modified Paths:
--------------
    trunk/hw/scsi-disk.c

Modified: trunk/hw/scsi-disk.c
===================================================================
--- trunk/hw/scsi-disk.c	2008-04-26 15:33:41 UTC (rev 4259)
+++ trunk/hw/scsi-disk.c	2008-04-26 15:56:05 UTC (rev 4260)
@@ -34,6 +34,18 @@
 #define SENSE_HARDWARE_ERROR  4
 #define SENSE_ILLEGAL_REQUEST 5
 
+#define SCSI_OK               0
+#define SCSI_CHECK_COND       0x2
+#define SCSI_COND_MET         0x4
+#define SCSI_BUSY             0x8
+#define SCSI_INTERMEDIATE     0x10
+#define SCSI_INTER_MET        0x14
+#define SCSI_RES_CONFLICT     0x18
+#define SCSI_CMD_TERMINATED   0x22
+#define SCSI_QUEUE_FULL       0x28
+#define SCSI_ACA_ACTIVE       0x30
+#define SCSI_TASK_ABORTED     0x40
+
 #define SCSI_DMA_BUF_SIZE    65536
 
 typedef struct SCSIRequest {
@@ -124,7 +136,7 @@
 }
 
 /* Helper function for command completion.  */
-static void scsi_command_complete(SCSIRequest *r, int sense)
+static void scsi_command_complete(SCSIRequest *r, int status, int sense)
 {
     SCSIDeviceState *s = r->dev;
     uint32_t tag;
@@ -132,7 +144,7 @@
     s->sense = sense;
     tag = r->tag;
     scsi_remove_request(r);
-    s->completion(s->opaque, SCSI_REASON_DONE, tag, sense);
+    s->completion(s->opaque, SCSI_REASON_DONE, tag, status);
 }
 
 /* Cancel a pending data transfer.  */
@@ -157,7 +169,7 @@
 
     if (ret) {
         DPRINTF("IO error\n");
-        scsi_command_complete(r, SENSE_HARDWARE_ERROR);
+        scsi_command_complete(r, SCSI_CHECK_COND, SENSE_HARDWARE_ERROR);
         return;
     }
     DPRINTF("Data ready tag=0x%x len=%d\n", r->tag, r->buf_len);
@@ -175,8 +187,7 @@
     r = scsi_find_request(s, tag);
     if (!r) {
         BADF("Bad read tag 0x%x\n", tag);
-        /* ??? This is the wrong error.  */
-        scsi_command_complete(r, SENSE_HARDWARE_ERROR);
+        scsi_command_complete(r, SCSI_CHECK_COND, SENSE_HARDWARE_ERROR);
         return;
     }
     if (r->sector_count == (uint32_t)-1) {
@@ -187,7 +198,7 @@
     }
     DPRINTF("Read sector_count=%d\n", r->sector_count);
     if (r->sector_count == 0) {
-        scsi_command_complete(r, SENSE_NO_SENSE);
+        scsi_command_complete(r, SCSI_OK, SENSE_NO_SENSE);
         return;
     }
 
@@ -199,7 +210,7 @@
     r->aiocb = bdrv_aio_read(s->bdrv, r->sector, r->dma_buf, n,
                              scsi_read_complete, r);
     if (r->aiocb == NULL)
-        scsi_command_complete(r, SENSE_HARDWARE_ERROR);
+        scsi_command_complete(r, SCSI_CHECK_COND, SENSE_HARDWARE_ERROR);
     r->sector += n;
     r->sector_count -= n;
 }
@@ -217,7 +228,7 @@
 
     r->aiocb = NULL;
     if (r->sector_count == 0) {
-        scsi_command_complete(r, SENSE_NO_SENSE);
+        scsi_command_complete(r, SCSI_OK, SENSE_NO_SENSE);
     } else {
         len = r->sector_count * 512;
         if (len > SCSI_DMA_BUF_SIZE) {
@@ -241,7 +252,7 @@
     r = scsi_find_request(s, tag);
     if (!r) {
         BADF("Bad write tag 0x%x\n", tag);
-        scsi_command_complete(r, SENSE_HARDWARE_ERROR);
+        scsi_command_complete(r, SCSI_CHECK_COND, SENSE_HARDWARE_ERROR);
         return 1;
     }
     if (r->aiocb)
@@ -251,7 +262,7 @@
         r->aiocb = bdrv_aio_write(s->bdrv, r->sector, r->dma_buf, n,
                                   scsi_write_complete, r);
         if (r->aiocb == NULL)
-            scsi_command_complete(r, SENSE_HARDWARE_ERROR);
+            scsi_command_complete(r, SCSI_CHECK_COND, SENSE_HARDWARE_ERROR);
         r->sector += n;
         r->sector_count -= n;
     } else {
@@ -601,7 +612,7 @@
             outbuf[7] = 0;
             r->buf_len = 8;
         } else {
-            scsi_command_complete(r, SENSE_NOT_READY);
+            scsi_command_complete(r, SCSI_CHECK_COND, SENSE_NOT_READY);
             return 0;
         }
 	break;
@@ -688,11 +699,11 @@
     default:
 	DPRINTF("Unknown SCSI command (%2.2x)\n", buf[0]);
     fail:
-        scsi_command_complete(r, SENSE_ILLEGAL_REQUEST);
+        scsi_command_complete(r, SCSI_CHECK_COND, SENSE_ILLEGAL_REQUEST);
 	return 0;
     }
     if (r->sector_count == 0 && r->buf_len == 0) {
-        scsi_command_complete(r, SENSE_NO_SENSE);
+        scsi_command_complete(r, SCSI_OK, SENSE_NO_SENSE);
     }
     len = r->sector_count * 512 + r->buf_len;
     if (is_write) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [4260] Fix scsi-disk sense-key/status confusion (Marcelo Tosatti).
  2008-04-26 15:56 [Qemu-devel] [4260] Fix scsi-disk sense-key/status confusion (Marcelo Tosatti) Andrzej Zaborowski
@ 2008-04-27 19:52 ` Blue Swirl
  2008-04-27 21:23   ` andrzej zaborowski
  0 siblings, 1 reply; 3+ messages in thread
From: Blue Swirl @ 2008-04-27 19:52 UTC (permalink / raw)
  To: qemu-devel

On 4/26/08, Andrzej Zaborowski <balrogg@gmail.com> wrote:
> Revision: 4260
>           http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4260
>  Author:   balrog
>  Date:     2008-04-26 15:56:05 +0000 (Sat, 26 Apr 2008)
>
>  Log Message:
>  -----------
>  Fix scsi-disk sense-key/status confusion (Marcelo Tosatti).

This patch breaks Sparc32 Debian 3.1r1 install disk boot, among
others. I will revert it.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [4260] Fix scsi-disk sense-key/status confusion (Marcelo Tosatti).
  2008-04-27 19:52 ` Blue Swirl
@ 2008-04-27 21:23   ` andrzej zaborowski
  0 siblings, 0 replies; 3+ messages in thread
From: andrzej zaborowski @ 2008-04-27 21:23 UTC (permalink / raw)
  To: Blue Swirl, qemu-devel

On 27/04/2008, Blue Swirl <blauwirbel@gmail.com> wrote:
> On 4/26/08, Andrzej Zaborowski <balrogg@gmail.com> wrote:
>  > Revision: 4260
>  >           http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4260
>  >  Author:   balrog
>  >  Date:     2008-04-26 15:56:05 +0000 (Sat, 26 Apr 2008)
>  >
>  >  Log Message:
>  >  -----------
>  >  Fix scsi-disk sense-key/status confusion (Marcelo Tosatti).
>
>  This patch breaks Sparc32 Debian 3.1r1 install disk boot, among
>  others. I will revert it.

Sorry, please do.  Apparently I didn't do enough testing.

Regards

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-04-27 21:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-26 15:56 [Qemu-devel] [4260] Fix scsi-disk sense-key/status confusion (Marcelo Tosatti) Andrzej Zaborowski
2008-04-27 19:52 ` Blue Swirl
2008-04-27 21:23   ` andrzej zaborowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).