[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [Qemu-devel] [PATCH for-4.1? 1/2] stellaris_input: Fix vm
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-arm] [Qemu-devel] [PATCH for-4.1? 1/2] stellaris_input: Fix vmstate description of buttons field |
Date: |
Thu, 25 Jul 2019 19:40:01 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
On 7/25/19 7:02 PM, Dr. David Alan Gilbert wrote:
> * Peter Maydell (address@hidden) 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 <address@hidden>
>
> 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.
Since the version is incremented, now seems to be a good time.
>
> Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
>
>> ---
>> 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 / address@hidden / Manchester, UK
>
- [Qemu-arm] [PATCH for-4.1? 0/2] Typecheck VMSTATE VARRAY macros and fix bug found, Peter Maydell, 2019/07/25
- Re: [Qemu-arm] [PATCH for-4.1? 1/2] stellaris_input: Fix vmstate description of buttons field, Peter Maydell, 2019/07/25
- Re: [Qemu-arm] [PATCH for-4.1? 1/2] stellaris_input: Fix vmstate description of buttons field, Dr. David Alan Gilbert, 2019/07/25
- Re: [Qemu-arm] [Qemu-devel] [PATCH for-4.1? 1/2] stellaris_input: Fix vmstate description of buttons field, Damien Hedde, 2019/07/26
- Re: [Qemu-arm] [Qemu-devel] [PATCH for-4.1? 1/2] stellaris_input: Fix vmstate description of buttons field, Peter Maydell, 2019/07/26
[Qemu-arm] [PATCH for-4.1? 2/2] vmstate.h: Type check VMSTATE_STRUCT_VARRAY macros, Peter Maydell, 2019/07/25