All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Damien Hedde <damien.hedde@greensocs.com>,
	qemu-arm@nongnu.org, qemu-devel@nongnu.org,
	Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-arm] [PATCH for-4.1? 1/2] stellaris_input: Fix vmstate description of buttons field
Date: Thu, 25 Jul 2019 18:02:28 +0100	[thread overview]
Message-ID: <20190725170228.GL2656@work-vm> (raw)
In-Reply-To: <20190725163710.11703-2-peter.maydell@linaro.org>

* Peter Maydell (peter.maydell@linaro.org) wrote:
> gamepad_state::buttons is a pointer to an array of structs,
> not an array of structs, so should be declared in the vmstate
> with VMSTATE_STRUCT_VARRAY_POINTER_INT32; otherwise we
> corrupt memory on incoming migration.
> 
> We bump the vmstate version field as the easiest way to
> deal with the migration break, since migration wouldn't have
> worked reliably before anyway.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

OK, it would be great to change num_buttons to uint32_t and make that a
UINT32 at some point;  it's hard to press negative buttons.


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

> ---
>  hw/input/stellaris_input.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c
> index 20c87d86f40..3a666d61d47 100644
> --- a/hw/input/stellaris_input.c
> +++ b/hw/input/stellaris_input.c
> @@ -60,12 +60,14 @@ static const VMStateDescription vmstate_stellaris_button = {
>  
>  static const VMStateDescription vmstate_stellaris_gamepad = {
>      .name = "stellaris_gamepad",
> -    .version_id = 1,
> -    .minimum_version_id = 1,
> +    .version_id = 2,
> +    .minimum_version_id = 2,
>      .fields = (VMStateField[]) {
>          VMSTATE_INT32(extension, gamepad_state),
> -        VMSTATE_STRUCT_VARRAY_INT32(buttons, gamepad_state, num_buttons, 0,
> -                              vmstate_stellaris_button, gamepad_button),
> +        VMSTATE_STRUCT_VARRAY_POINTER_INT32(buttons, gamepad_state,
> +                                            num_buttons,
> +                                            vmstate_stellaris_button,
> +                                            gamepad_button),
>          VMSTATE_END_OF_LIST()
>      }
>  };
> -- 
> 2.20.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

WARNING: multiple messages have this Message-ID (diff)
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Damien Hedde <damien.hedde@greensocs.com>,
	qemu-arm@nongnu.org, qemu-devel@nongnu.org,
	Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] [PATCH for-4.1? 1/2] stellaris_input: Fix vmstate description of buttons field
Date: Thu, 25 Jul 2019 18:02:28 +0100	[thread overview]
Message-ID: <20190725170228.GL2656@work-vm> (raw)
In-Reply-To: <20190725163710.11703-2-peter.maydell@linaro.org>

* Peter Maydell (peter.maydell@linaro.org) wrote:
> gamepad_state::buttons is a pointer to an array of structs,
> not an array of structs, so should be declared in the vmstate
> with VMSTATE_STRUCT_VARRAY_POINTER_INT32; otherwise we
> corrupt memory on incoming migration.
> 
> We bump the vmstate version field as the easiest way to
> deal with the migration break, since migration wouldn't have
> worked reliably before anyway.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

OK, it would be great to change num_buttons to uint32_t and make that a
UINT32 at some point;  it's hard to press negative buttons.


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

> ---
>  hw/input/stellaris_input.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c
> index 20c87d86f40..3a666d61d47 100644
> --- a/hw/input/stellaris_input.c
> +++ b/hw/input/stellaris_input.c
> @@ -60,12 +60,14 @@ static const VMStateDescription vmstate_stellaris_button = {
>  
>  static const VMStateDescription vmstate_stellaris_gamepad = {
>      .name = "stellaris_gamepad",
> -    .version_id = 1,
> -    .minimum_version_id = 1,
> +    .version_id = 2,
> +    .minimum_version_id = 2,
>      .fields = (VMStateField[]) {
>          VMSTATE_INT32(extension, gamepad_state),
> -        VMSTATE_STRUCT_VARRAY_INT32(buttons, gamepad_state, num_buttons, 0,
> -                              vmstate_stellaris_button, gamepad_button),
> +        VMSTATE_STRUCT_VARRAY_POINTER_INT32(buttons, gamepad_state,
> +                                            num_buttons,
> +                                            vmstate_stellaris_button,
> +                                            gamepad_button),
>          VMSTATE_END_OF_LIST()
>      }
>  };
> -- 
> 2.20.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


  reply	other threads:[~2019-07-25 17:02 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-25 16:37 [Qemu-arm] [PATCH for-4.1? 0/2] Typecheck VMSTATE VARRAY macros and fix bug found Peter Maydell
2019-07-25 16:37 ` [Qemu-devel] " Peter Maydell
2019-07-25 16:37 ` [Qemu-devel] [PATCH for-4.1? 1/2] stellaris_input: Fix vmstate description of buttons field Peter Maydell
2019-07-25 17:02   ` Dr. David Alan Gilbert [this message]
2019-07-25 17:02     ` Dr. David Alan Gilbert
2019-07-25 17:40     ` [Qemu-arm] " Philippe Mathieu-Daudé
2019-07-25 17:40       ` Philippe Mathieu-Daudé
2019-07-26  9:52       ` [Qemu-arm] " Peter Maydell
2019-07-26  9:52         ` Peter Maydell
2019-07-26  9:59         ` [Qemu-arm] " Dr. David Alan Gilbert
2019-07-26  9:59           ` Dr. David Alan Gilbert
2019-07-26 10:03           ` [Qemu-arm] " Peter Maydell
2019-07-26 10:03             ` Peter Maydell
2019-07-25 17:59     ` [Qemu-arm] " Peter Maydell
2019-07-25 17:59       ` [Qemu-devel] " Peter Maydell
2019-07-25 18:32       ` [Qemu-arm] " Dr. David Alan Gilbert
2019-07-25 18:32         ` [Qemu-devel] " Dr. David Alan Gilbert
2019-07-26  8:25       ` [Qemu-arm] " Damien Hedde
2019-07-26  8:25         ` Damien Hedde
2019-07-26  8:47         ` [Qemu-arm] " Peter Maydell
2019-07-26  8:47           ` Peter Maydell
2019-07-25 16:37 ` [Qemu-devel] [PATCH for-4.1? 2/2] vmstate.h: Type check VMSTATE_STRUCT_VARRAY macros Peter Maydell
2019-07-25 17:27   ` [Qemu-arm] " Dr. David Alan Gilbert
2019-07-25 17:27     ` [Qemu-devel] " Dr. David Alan Gilbert
2019-07-25 17:57     ` [Qemu-arm] " Peter Maydell
2019-07-25 17:57       ` [Qemu-devel] " Peter Maydell
2019-07-25 18:00       ` [Qemu-arm] " Dr. David Alan Gilbert
2019-07-25 18:00         ` [Qemu-devel] " Dr. David Alan Gilbert
2019-07-26  9:24         ` [Qemu-arm] " Peter Maydell
2019-07-26  9:24           ` [Qemu-devel] " Peter Maydell
2019-07-26  9:32           ` [Qemu-arm] " Dr. David Alan Gilbert
2019-07-26  9:32             ` [Qemu-devel] " Dr. David Alan Gilbert
2019-07-26  9:33             ` [Qemu-arm] " Peter Maydell
2019-07-26  9:33               ` [Qemu-devel] " Peter Maydell
2019-07-26  9:34               ` [Qemu-arm] " Dr. David Alan Gilbert
2019-07-26  9:34                 ` [Qemu-devel] " Dr. David Alan Gilbert
2019-07-26  9:12     ` [Qemu-arm] " Damien Hedde
2019-07-26  9:12       ` Damien Hedde

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=20190725170228.GL2656@work-vm \
    --to=dgilbert@redhat.com \
    --cc=damien.hedde@greensocs.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --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.