From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] scsi-generic: decode correctly SCSI tape commands
Date: Mon, 22 Sep 2008 14:21:05 -0500 [thread overview]
Message-ID: <48D7F021.5040102@codemonkey.ws> (raw)
In-Reply-To: <1222099458.4151.20.camel@frecb07144>
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
next prev parent reply other threads:[~2008-09-22 19:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-22 16:04 [Qemu-devel] [PATCH] scsi-generic: decode correctly SCSI tape commands Laurent Vivier
2008-09-22 19:21 ` Anthony Liguori [this message]
2008-09-23 8:51 ` [Qemu-devel] [PATCH][v2] " Laurent Vivier
2008-09-23 13:38 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48D7F021.5040102@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).