qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] scsi-generic: decode correctly SCSI tape comman


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH] scsi-generic: decode correctly SCSI tape commands
Date: Mon, 22 Sep 2008 14:21:05 -0500
User-agent: Thunderbird 2.0.0.16 (X11/20080723)

Laurent Vivier wrote:
This patch allows to use a "real" SCSI tape with qemu using
"-drive /dev/sgX,if=scsi".

It allows to decode correctly transfer length when the type of the
device is a tape.

Some issues subsist when the application reading the tape tries to go
beyond the end of the stream (but they must be corrected at the SCSI
controller level).

You have some tab/whitespace damage in this patch

@@ -75,6 +77,7 @@ struct SCSIDeviceState
 {
     SCSIRequest *requests;
     BlockDriverState *bdrv;
+    int type;
     int blocksize;
     int lun;
     scsi_completionfn completion;
@@ -163,7 +166,7 @@ static void scsi_command_complete(void *
         } else if ((s->driver_status & SG_ERR_DRIVER_SENSE) == 0)
             sense = NO_SENSE;
         else
-            sense = s->sensebuf[2] & 0x0f;
+            sense = s->sensebuf[2];
     }
DPRINTF("Command complete 0x%p tag=0x%x sense=%d\n", r, r->tag, sense);
@@ -273,10 +276,15 @@ static void scsi_read_data(SCSIDevice *d
if (r->cmd[0] == REQUEST_SENSE && s->driver_status & SG_ERR_DRIVER_SENSE)
     {
-        memcpy(r->buf, s->sensebuf, 16);
+       int len;

Right here.

+        len = r->len > SCSI_SENSE_BUF_SIZE ? SCSI_SENSE_BUF_SIZE : r->len;

Just use len = MIN(r->len, SCSI_SENSE_BUF_SIZE);

The rest looks pretty straight forward.

Regards,

Anthony Liguori




reply via email to

[Prev in Thread] Current Thread [Next in Thread]