Patchwork [2/3] hw/sd.c: fix migration of dynamically allocated buffer "buf"

login
register
mail settings
Submitter Igor Mitsyanko
Date March 10, 2013, 1:47 p.m.
Message ID <1362923278-4080-3-git-send-email-i.mitsyanko@gmail.com>
Download mbox | patch
Permalink /patch/226436/
State New
Headers show

Comments

Igor Mitsyanko - March 10, 2013, 1:47 p.m.
VMSTATE_BUFFER_UNSAFE should be used for buffers inlined in device state, not
for buffers allocated dynamically. Change to VMSTATE_BUFFER_POINTER_UNSAFE macro,
which will do migration right.

Signed-off-by: Igor Mitsyanko <i.mitsyanko@gmail.com>
---
 hw/sd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Michael Walle - March 18, 2013, 6:33 p.m.
Am Sonntag 10 März 2013, 14:47:57 schrieb Igor Mitsyanko:
> VMSTATE_BUFFER_UNSAFE should be used for buffers inlined in device state,
> not for buffers allocated dynamically. Change to
> VMSTATE_BUFFER_POINTER_UNSAFE macro, which will do migration right.
> 
> Signed-off-by: Igor Mitsyanko <i.mitsyanko@gmail.com>
> ---
>  hw/sd.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/sd.c b/hw/sd.c
> index 428bd78..88eaaf8 100644
> --- a/hw/sd.c
> +++ b/hw/sd.c
> @@ -478,7 +478,7 @@ static const VMStateDescription sd_vmstate = {
>          VMSTATE_UINT64(data_start, SDState),
>          VMSTATE_UINT32(data_offset, SDState),
>          VMSTATE_UINT8_ARRAY(data, SDState, 512),
> -        VMSTATE_BUFFER_UNSAFE(buf, SDState, 1, 512),
> +        VMSTATE_BUFFER_POINTER_UNSAFE(buf, SDState, 1, 512),
>          VMSTATE_BOOL(enable, SDState),
>          VMSTATE_END_OF_LIST()
>      }

Tested-by: Michael Walle <michael@walle.cc>

Patch

diff --git a/hw/sd.c b/hw/sd.c
index 428bd78..88eaaf8 100644
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -478,7 +478,7 @@  static const VMStateDescription sd_vmstate = {
         VMSTATE_UINT64(data_start, SDState),
         VMSTATE_UINT32(data_offset, SDState),
         VMSTATE_UINT8_ARRAY(data, SDState, 512),
-        VMSTATE_BUFFER_UNSAFE(buf, SDState, 1, 512),
+        VMSTATE_BUFFER_POINTER_UNSAFE(buf, SDState, 1, 512),
         VMSTATE_BOOL(enable, SDState),
         VMSTATE_END_OF_LIST()
     }