qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Hannes Reinecke <hare@suse.de>
Cc: Hannes Reinecke <hare@suse.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCHv2 3/4] scsi: clarify sense codes for LUN0 emulation
Date: Fri, 4 Aug 2017 12:49:12 +0200	[thread overview]
Message-ID: <cecc5581-7013-f870-dbd7-da28ac80d2a4@redhat.com> (raw)
In-Reply-To: <1501835795-92331-4-git-send-email-hare@suse.de>

On 04/08/2017 10:36, Hannes Reinecke wrote:
> The LUN0 emulation is just that, an emulation for a non-existing
> LUN0. So we should be returning LUN_NOT_SUPPORTED for any request
> coming from any other LUN.
> And we should be aborting unhandled commands with INVALID OPCODE,
> not LUN NOT SUPPORTED.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>  hw/scsi/scsi-bus.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
> index 8419c75..79a222f 100644
> --- a/hw/scsi/scsi-bus.c
> +++ b/hw/scsi/scsi-bus.c
> @@ -583,6 +583,11 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
>  {
>      SCSITargetReq *r = DO_UPCAST(SCSITargetReq, req, req);
>  
> +    if (req->lun != 0) {
> +        scsi_req_build_sense(req, SENSE_CODE(LUN_NOT_SUPPORTED));
> +        scsi_req_complete(req, CHECK_CONDITION);
> +        return 0;
> +    }
>      switch (buf[0]) {
>      case REPORT_LUNS:
>          if (!scsi_target_emulate_report_luns(r)) {
> @@ -613,7 +618,7 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
>      case TEST_UNIT_READY:
>          break;
>      default:
> -        scsi_req_build_sense(req, SENSE_CODE(LUN_NOT_SUPPORTED));
> +        scsi_req_build_sense(req, SENSE_CODE(INVALID_OPCODE));
>          scsi_req_complete(req, CHECK_CONDITION);
>          return 0;
>      illegal_request:
> 

I am queuing this one since it's an independent bugfix.

Paolo

  reply	other threads:[~2017-08-04 10:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-04  8:36 [Qemu-devel] [PATCHv2 0/4] scsi: enclosure support Hannes Reinecke
2017-08-04  8:36 ` [Qemu-devel] [PATCHv2 1/4] scsi: Make LUN 0 a simple enclosure Hannes Reinecke
2017-08-04  8:36 ` [Qemu-devel] [PATCHv2 2/4] scsi: use qemu_uuid to generate logical identifier for SES Hannes Reinecke
2017-08-04  8:36 ` [Qemu-devel] [PATCHv2 3/4] scsi: clarify sense codes for LUN0 emulation Hannes Reinecke
2017-08-04 10:49   ` Paolo Bonzini [this message]
2017-08-17 20:57     ` Laszlo Ersek
2017-08-18  0:16       ` Laszlo Ersek
2017-08-18  0:57         ` Laszlo Ersek
2017-08-18  5:51           ` Hannes Reinecke
2017-08-04  8:36 ` [Qemu-devel] [PATCHv2 4/4] scsi: Add 'enclosure' option for scsi devices Hannes Reinecke
2017-08-04 10:48   ` Paolo Bonzini
2017-08-04 11:54     ` Hannes Reinecke

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=cecc5581-7013-f870-dbd7-da28ac80d2a4@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=hare@suse.com \
    --cc=hare@suse.de \
    --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).