qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qemu-pr-helper: miscellaneous fixes
Date: Fri, 1 Dec 2017 20:00:45 +0000	[thread overview]
Message-ID: <20171201200044.GF3101@work-vm> (raw)
In-Reply-To: <20171201174018.6517-1-pbonzini@redhat.com>

* Paolo Bonzini (pbonzini@redhat.com) wrote:
> 1) Return a generic sense if TEST UNIT READY does not provide one;
> 
> 2) Fix two mistakes in copying from the spec.
> 
> Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

(Is there a separate fix to the scsi_target_send_command sense
comment?)

Dave

> ---
>  include/scsi/utils.h  |  6 +++++-
>  scsi/qemu-pr-helper.c | 30 ++++++++++++++++++++++++++----
>  scsi/utils.c          | 10 ++++++++++
>  3 files changed, 41 insertions(+), 5 deletions(-)
> 
> diff --git a/include/scsi/utils.h b/include/scsi/utils.h
> index 00a4bdb080..eb07e474ee 100644
> --- a/include/scsi/utils.h
> +++ b/include/scsi/utils.h
> @@ -76,7 +76,11 @@ extern const struct SCSISense sense_code_LUN_FAILURE;
>  extern const struct SCSISense sense_code_LUN_COMM_FAILURE;
>  /* Command aborted, Overlapped Commands Attempted */
>  extern const struct SCSISense sense_code_OVERLAPPED_COMMANDS;
> -/* LUN not ready, Capacity data has changed */
> +/* Medium error, Unrecovered read error */
> +extern const struct SCSISense sense_code_READ_ERROR;
> +/* LUN not ready, Cause not reportable */
> +extern const struct SCSISense sense_code_NOT_READY;
> +/* Unit attention, Capacity data has changed */
>  extern const struct SCSISense sense_code_CAPACITY_CHANGED;
>  /* Unit attention, SCSI bus reset */
>  extern const struct SCSISense sense_code_SCSI_BUS_RESET;
> diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
> index dd9785143b..9fe615c73c 100644
> --- a/scsi/qemu-pr-helper.c
> +++ b/scsi/qemu-pr-helper.c
> @@ -314,6 +314,22 @@ static int is_mpath(int fd)
>      return !strncmp(tgt->target_type, "multipath", DM_MAX_TYPE_NAME);
>  }
>  
> +static SCSISense mpath_generic_sense(int r)
> +{
> +    switch (r) {
> +    case MPATH_PR_SENSE_NOT_READY:
> +         return SENSE_CODE(NOT_READY);
> +    case MPATH_PR_SENSE_MEDIUM_ERROR:
> +         return SENSE_CODE(READ_ERROR);
> +    case MPATH_PR_SENSE_HARDWARE_ERROR:
> +         return SENSE_CODE(TARGET_FAILURE);
> +    case MPATH_PR_SENSE_ABORTED_COMMAND:
> +         return SENSE_CODE(IO_ERROR);
> +    default:
> +         abort();
> +    }
> +}
> +
>  static int mpath_reconstruct_sense(int fd, int r, uint8_t *sense)
>  {
>      switch (r) {
> @@ -329,7 +345,13 @@ static int mpath_reconstruct_sense(int fd, int r, uint8_t *sense)
>               */
>              uint8_t cdb[6] = { TEST_UNIT_READY };
>              int sz = 0;
> -            return do_sgio(fd, cdb, sense, NULL, &sz, SG_DXFER_NONE);
> +            int r = do_sgio(fd, cdb, sense, NULL, &sz, SG_DXFER_NONE);
> +
> +            if (r != GOOD) {
> +                return r;
> +            }
> +            scsi_build_sense(sense, mpath_generic_sense(r));
> +            return CHECK_CONDITION;
>          }
>  
>      case MPATH_PR_SENSE_UNIT_ATTENTION:
> @@ -449,7 +471,7 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense,
>      memset(&paramp, 0, sizeof(paramp));
>      memcpy(&paramp.key, &param[0], 8);
>      memcpy(&paramp.sa_key, &param[8], 8);
> -    paramp.sa_flags = param[10];
> +    paramp.sa_flags = param[20];
>      if (sz > PR_OUT_FIXED_PARAM_SIZE) {
>          size_t transportid_len;
>          int i, j;
> @@ -478,8 +500,8 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense,
>                  j += offsetof(struct transportid, n_port_name[8]);
>                  i += 24;
>                  break;
> -            case 3:
> -            case 0x43:
> +            case 5:
> +            case 0x45:
>                  /* iSCSI transport.  */
>                  len = lduw_be_p(&param[i + 2]);
>                  if (len > 252 || (len & 3) || i + len + 4 > transportid_len) {
> diff --git a/scsi/utils.c b/scsi/utils.c
> index 5684951b12..e4182a9b09 100644
> --- a/scsi/utils.c
> +++ b/scsi/utils.c
> @@ -211,6 +211,16 @@ const struct SCSISense sense_code_LUN_COMM_FAILURE = {
>      .key = ABORTED_COMMAND, .asc = 0x08, .ascq = 0x00
>  };
>  
> +/* Medium Error, Unrecovered read error */
> +const struct SCSISense sense_code_READ_ERROR = {
> +    .key = MEDIUM_ERROR, .asc = 0x11, .ascq = 0x00
> +};
> +
> +/* Not ready, Cause not reportable */
> +const struct SCSISense sense_code_NOT_READY = {
> +    .key = NOT_READY, .asc = 0x04, .ascq = 0x00
> +};
> +
>  /* Unit attention, Capacity data has changed */
>  const struct SCSISense sense_code_CAPACITY_CHANGED = {
>      .key = UNIT_ATTENTION, .asc = 0x2a, .ascq = 0x09
> -- 
> 2.14.3
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2017-12-01 20:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01 17:40 [Qemu-devel] [PATCH] qemu-pr-helper: miscellaneous fixes Paolo Bonzini
2017-12-01 20:00 ` Dr. David Alan Gilbert [this message]
2017-12-03 20:42   ` [Qemu-devel] R: " Paolo Bonzini

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=20171201200044.GF3101@work-vm \
    --to=dgilbert@redhat.com \
    --cc=pbonzini@redhat.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 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).