All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: "Gerd Hoffmann" <kraxel@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Juan Quintela" <quintela@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] scsi: Fix migration of scsi sense data
Date: Thu, 06 Mar 2014 09:42:51 +0100	[thread overview]
Message-ID: <5318350B.4020303@redhat.com> (raw)
In-Reply-To: <1394094362-12949-1-git-send-email-famz@redhat.com>

Il 06/03/2014 09:26, Fam Zheng ha scritto:
> c5f52875 changed the size of sense array in vmstate_scsi_device by
> mistake. This patch restores the old size, and add a subsection for the
> remaining part of the buffer size. So that migration is not broken.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  hw/scsi/scsi-bus.c          | 30 +++++++++++++++++++++++++++++-
>  include/hw/scsi/scsi.h      |  1 +
>  include/migration/vmstate.h |  3 +++
>  3 files changed, 33 insertions(+), 1 deletion(-)
>
> diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
> index 50a0acf..eaad925 100644
> --- a/hw/scsi/scsi-bus.c
> +++ b/hw/scsi/scsi-bus.c
> @@ -1905,6 +1905,26 @@ static const VMStateInfo vmstate_info_scsi_requests = {
>      .put  = put_scsi_requests,
>  };
>
> +static bool scsi_sense_state_needed(void *opaque)
> +{
> +    SCSIDevice *s = opaque;
> +
> +    return s->sense_len > SCSI_SENSE_BUF_SIZE_OLD;
> +}
> +
> +static const VMStateDescription vmstate_scsi_sense_state = {
> +    .name = "SCSIDevice/sense",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .fields      = (VMStateField []) {
> +        VMSTATE_UINT8_SUB_ARRAY(sense, SCSIDevice,
> +                                SCSI_SENSE_BUF_SIZE_OLD,
> +                                SCSI_SENSE_BUF_SIZE - SCSI_SENSE_BUF_SIZE_OLD),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> +
>  const VMStateDescription vmstate_scsi_device = {
>      .name = "SCSIDevice",
>      .version_id = 1,
> @@ -1915,7 +1935,7 @@ const VMStateDescription vmstate_scsi_device = {
>          VMSTATE_UINT8(unit_attention.asc, SCSIDevice),
>          VMSTATE_UINT8(unit_attention.ascq, SCSIDevice),
>          VMSTATE_BOOL(sense_is_ua, SCSIDevice),
> -        VMSTATE_UINT8_ARRAY(sense, SCSIDevice, SCSI_SENSE_BUF_SIZE),
> +        VMSTATE_UINT8_SUB_ARRAY(sense, SCSIDevice, 0, SCSI_SENSE_BUF_SIZE_OLD),
>          VMSTATE_UINT32(sense_len, SCSIDevice),
>          {
>              .name         = "requests",
> @@ -1927,6 +1947,14 @@ const VMStateDescription vmstate_scsi_device = {
>              .offset       = 0,
>          },
>          VMSTATE_END_OF_LIST()
> +    },
> +    .subsections = (VMStateSubsection []) {
> +        {
> +            .vmsd = &vmstate_scsi_sense_state,
> +            .needed = scsi_sense_state_needed,
> +        }, {
> +            /* empty */
> +        }
>      }
>  };
>
> diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
> index e5fc39d..1adb549 100644
> --- a/include/hw/scsi/scsi.h
> +++ b/include/hw/scsi/scsi.h
> @@ -31,6 +31,7 @@ typedef struct SCSISense {
>      uint8_t ascq;
>  } SCSISense;
>
> +#define SCSI_SENSE_BUF_SIZE_OLD 96
>  #define SCSI_SENSE_BUF_SIZE 252
>
>  struct SCSICommand {
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index ded8e23..e7e1705 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -650,6 +650,9 @@ extern const VMStateInfo vmstate_info_bitmap;
>  #define VMSTATE_UINT8_ARRAY(_f, _s, _n)                               \
>      VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
>
> +#define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num)                \
> +    VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t)
> +
>  #define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2)                       \
>      VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, 0)
>
>

Looks good, thanks!  I'll apply to scsi-next after a little more testing.

Paolo

  reply	other threads:[~2014-03-06  8:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-06  8:26 [Qemu-devel] [PATCH] scsi: Fix migration of scsi sense data Fam Zheng
2014-03-06  8:42 ` Paolo Bonzini [this message]
2014-03-14  5:58   ` Fam Zheng
2014-03-14 12:38     ` 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=5318350B.4020303@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=afaerber@suse.de \
    --cc=famz@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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.