All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Bernhard Kohl <bernhard.kohl@nsn.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/4] scsi-disk: fix changeable values returned by the MODE SENSE command
Date: Mon, 16 Aug 2010 19:12:21 +0200	[thread overview]
Message-ID: <4C697175.5060908@redhat.com> (raw)
In-Reply-To: <1280763089-11829-4-git-send-email-bernhard.kohl@nsn.com>

Am 02.08.2010 17:31, schrieb Bernhard Kohl:
> If the page control (PC) field in the MODE SENSE command defines Changeable
> Values to be returned in the mode pages, don't return any mode page as there
> is no support to change any values.
> 
> Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com>
> ---
>  hw/scsi-disk.c |    9 ++++++---
>  1 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
> index 927df54..26f7345 100644
> --- a/hw/scsi-disk.c
> +++ b/hw/scsi-disk.c
> @@ -604,13 +604,15 @@ static int scsi_disk_emulate_mode_sense(SCSIRequest *req, uint8_t *outbuf)
>  {
>      SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
>      uint64_t nb_sectors;
> -    int page, dbd, buflen;
> +    int page, dbd, buflen, page_control;
>      uint8_t *p;
>      uint8_t dev_specific_param;
>  
>      dbd = req->cmd.buf[1]  & 0x8;
>      page = req->cmd.buf[2] & 0x3f;
> -    DPRINTF("Mode Sense (page %d, len %zd)\n", page, req->cmd.xfer);
> +    page_control = (req->cmd.buf[2] & 0xc0) >> 6;
> +    DPRINTF("Mode Sense(%d) (page %d, len %d, page_control %d)\n",
> +        (req->cmd.buf[0] == MODE_SENSE) ? 6 : 10, page, len, page_control);
>      memset(outbuf, 0, req->cmd.xfer);
>      p = outbuf;
>  
> @@ -654,7 +656,8 @@ static int scsi_disk_emulate_mode_sense(SCSIRequest *req, uint8_t *outbuf)
>          p += 8;
>      }
>  
> -    switch (page) {
> +    /* Don't return pages if Changeable Values (1) are requested. */
> +    if (page_control != 1) switch (page) {

Coding style (missing braces, and switch belongs on its own line).

>      case 0x04:
>      case 0x05:
>      case 0x08:

I don't think this is enough. Wouldn't this still let the command return
successfully? In fact we need it to fail:

"If the logical unit does not implement changeable parameters mode pages
and the device server receives a MODE SENSE command with 01b in the PC
field, then the command shall be terminated with CHECK CONDITION status,
with the sense key set to ILLEGAL REQUEST, and the additional sense code
set to INVALID FIELD IN CDB."

This should do it if I'm not mistaken:

if (page_control == 0x01) {
    return -1;
}

Kevin

  reply	other threads:[~2010-08-16 17:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-02 15:31 [Qemu-devel] [PATCH 0/4] scsi-disk: improve the emulation of the MODE SENSE command Bernhard Kohl
2010-08-02 15:31 ` [Qemu-devel] [PATCH 1/4] scsi-disk: fix the mode data length field returned by " Bernhard Kohl
2010-08-02 15:31 ` [Qemu-devel] [PATCH 2/4] scsi-disk: fix the mode data header returned by the MODE SENSE(10) command Bernhard Kohl
2010-08-16 17:02   ` Kevin Wolf
2010-08-27 15:24     ` Bernhard Kohl
2010-08-02 15:31 ` [Qemu-devel] [PATCH 3/4] scsi-disk: fix changeable values returned by the MODE SENSE command Bernhard Kohl
2010-08-16 17:12   ` Kevin Wolf [this message]
2010-08-27 15:25     ` Bernhard Kohl
2010-08-02 15:31 ` [Qemu-devel] [PATCH 4/4] scsi-disk: fix the block descriptor " Bernhard Kohl
2010-08-16 17:34   ` Kevin Wolf
2010-08-27 15:26     ` Bernhard Kohl
2010-08-16 17:39 ` [Qemu-devel] [PATCH 0/4] scsi-disk: improve the emulation of " Kevin Wolf
2010-08-17 13:03   ` Bernhard Kohl

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=4C697175.5060908@redhat.com \
    --to=kwolf@redhat.com \
    --cc=bernhard.kohl@nsn.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.