diff mbox

[4/6] savevm: Add VMSTATE_STRUCT_VARRAY_POINTER_UINT32

Message ID 1363057565-23671-5-git-send-email-david@gibson.dropbear.id.au
State New
Headers show

Commit Message

David Gibson March 12, 2013, 3:06 a.m. UTC
Currently the savevm code contains a VMSTATE_STRUCT_VARRAY_POINTER_INT32
helper (a variably sized array with the number of elements in an int32_t),
but not VMSTATE_STRUCT_VARRAY_POINTER_UINT32 (... with the number of
elements in a uint32_t).  This patch (trivially) fixes the deficiency.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 include/migration/vmstate.h |   10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Juan Quintela March 14, 2013, 12:40 p.m. UTC | #1
David Gibson <david@gibson.dropbear.id.au> wrote:
> Currently the savevm code contains a VMSTATE_STRUCT_VARRAY_POINTER_INT32
> helper (a variably sized array with the number of elements in an int32_t),
> but not VMSTATE_STRUCT_VARRAY_POINTER_UINT32 (... with the number of
> elements in a uint32_t).  This patch (trivially) fixes the deficiency.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  include/migration/vmstate.h |   10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index f0a6374..fe39cd9 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -339,6 +339,16 @@ extern const VMStateInfo vmstate_info_bitmap;
>      .offset     = vmstate_offset_pointer(_state, _field, _type),     \
>  }
>  
> +#define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _vmsd, _type) { \
> +    .name       = (stringify(_field)),                               \
> +    .version_id = 0,                                                 \
> +    .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
> +    .size       = sizeof(_type),                                     \
> +    .vmsd       = &(_vmsd),                                          \
> +    .flags      = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT,       \

We are overridding VMS_VARRAYS_INT32 here, but if we have so many
elements in the array, we have other problems to fix O:-)

> +    .offset     = vmstate_offset_pointer(_state, _field, _type),     \
> +}
> +
>  #define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \
>      .name       = (stringify(_field)),                               \
>      .version_id = 0,                                                 \
David Gibson March 15, 2013, 5:36 a.m. UTC | #2
On Thu, Mar 14, 2013 at 01:40:37PM +0100, Juan Quintela wrote:
> David Gibson <david@gibson.dropbear.id.au> wrote:
> > Currently the savevm code contains a VMSTATE_STRUCT_VARRAY_POINTER_INT32
> > helper (a variably sized array with the number of elements in an int32_t),
> > but not VMSTATE_STRUCT_VARRAY_POINTER_UINT32 (... with the number of
> > elements in a uint32_t).  This patch (trivially) fixes the deficiency.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> >  include/migration/vmstate.h |   10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> > index f0a6374..fe39cd9 100644
> > --- a/include/migration/vmstate.h
> > +++ b/include/migration/vmstate.h
> > @@ -339,6 +339,16 @@ extern const VMStateInfo vmstate_info_bitmap;
> >      .offset     = vmstate_offset_pointer(_state, _field, _type),     \
> >  }
> >  
> > +#define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _vmsd, _type) { \
> > +    .name       = (stringify(_field)),                               \
> > +    .version_id = 0,                                                 \
> > +    .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
> > +    .size       = sizeof(_type),                                     \
> > +    .vmsd       = &(_vmsd),                                          \
> > +    .flags      = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT,       \
> 
> We are overridding VMS_VARRAYS_INT32 here, but if we have so many
> elements in the array, we have other problems to fix O:-)

More to the point, negative numbers of elements make no sense, so in
practice the only sensible interpretation of the field is unsigned
anyway.
diff mbox

Patch

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index f0a6374..fe39cd9 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -339,6 +339,16 @@  extern const VMStateInfo vmstate_info_bitmap;
     .offset     = vmstate_offset_pointer(_state, _field, _type),     \
 }
 
+#define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _vmsd, _type) { \
+    .name       = (stringify(_field)),                               \
+    .version_id = 0,                                                 \
+    .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
+    .size       = sizeof(_type),                                     \
+    .vmsd       = &(_vmsd),                                          \
+    .flags      = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT,       \
+    .offset     = vmstate_offset_pointer(_state, _field, _type),     \
+}
+
 #define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \
     .name       = (stringify(_field)),                               \
     .version_id = 0,                                                 \