diff mbox

[RFC,v2,2/5] vmstate: add VMS_NONE

Message ID 1395671853-2685-3-git-send-email-mst@redhat.com
State New
Headers show

Commit Message

Michael S. Tsirkin March 24, 2014, 2:37 p.m. UTC
The element with this flags value is skipped.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/migration/vmstate.h | 1 +
 vmstate.c                   | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Dr. David Alan Gilbert March 24, 2014, 5:07 p.m. UTC | #1
* Michael S. Tsirkin (mst@redhat.com) wrote:
> The element with this flags value is skipped.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  include/migration/vmstate.h | 1 +
>  vmstate.c                   | 4 +++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index e7e1705..3a1587e 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -88,6 +88,7 @@ struct VMStateInfo {
>  };
>  
>  enum VMStateFlags {
> +    VMS_NONE             = 0x000,
>      VMS_SINGLE           = 0x001,
>      VMS_POINTER          = 0x002,
>      VMS_ARRAY            = 0x004,

I think this would be simpler if you just gave it it's own
bit, the next patch already makes the mask more complicated.

However, do you need it?  Why not just declare a VMS_ARRAY with field->num=0 ?

Dave

> diff --git a/vmstate.c b/vmstate.c
> index 18b3732..fe53735 100644
> --- a/vmstate.c
> +++ b/vmstate.c
> @@ -13,7 +13,9 @@ static int vmstate_n_elems(void *opaque, VMStateField *field)
>  {
>      int n_elems = 1;
>  
> -    if (field->flags & VMS_ARRAY) {
> +    if (!(field->flags & ~VMS_NONE)) {
> +        n_elems = 0;
> +    } else if (field->flags & VMS_ARRAY) {
>          n_elems = field->num;
>      } else if (field->flags & VMS_VARRAY_INT32) {
>          n_elems = *(int32_t *)(opaque+field->num_offset);
> -- 
> MST
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Michael S. Tsirkin March 24, 2014, 9:51 p.m. UTC | #2
On Mon, Mar 24, 2014 at 05:07:39PM +0000, Dr. David Alan Gilbert wrote:
> * Michael S. Tsirkin (mst@redhat.com) wrote:
> > The element with this flags value is skipped.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  include/migration/vmstate.h | 1 +
> >  vmstate.c                   | 4 +++-
> >  2 files changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> > index e7e1705..3a1587e 100644
> > --- a/include/migration/vmstate.h
> > +++ b/include/migration/vmstate.h
> > @@ -88,6 +88,7 @@ struct VMStateInfo {
> >  };
> >  
> >  enum VMStateFlags {
> > +    VMS_NONE             = 0x000,
> >      VMS_SINGLE           = 0x001,
> >      VMS_POINTER          = 0x002,
> >      VMS_ARRAY            = 0x004,
> 
> I think this would be simpler if you just gave it it's own
> bit, the next patch already makes the mask more complicated.
> 
> However, do you need it?  Why not just declare a VMS_ARRAY with field->num=0 ?
> 
> Dave

Good idea, I'll do that.

> > diff --git a/vmstate.c b/vmstate.c
> > index 18b3732..fe53735 100644
> > --- a/vmstate.c
> > +++ b/vmstate.c
> > @@ -13,7 +13,9 @@ static int vmstate_n_elems(void *opaque, VMStateField *field)
> >  {
> >      int n_elems = 1;
> >  
> > -    if (field->flags & VMS_ARRAY) {
> > +    if (!(field->flags & ~VMS_NONE)) {
> > +        n_elems = 0;
> > +    } else if (field->flags & VMS_ARRAY) {
> >          n_elems = field->num;
> >      } else if (field->flags & VMS_VARRAY_INT32) {
> >          n_elems = *(int32_t *)(opaque+field->num_offset);
> > -- 
> > MST
> > 
> > 
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
diff mbox

Patch

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index e7e1705..3a1587e 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -88,6 +88,7 @@  struct VMStateInfo {
 };
 
 enum VMStateFlags {
+    VMS_NONE             = 0x000,
     VMS_SINGLE           = 0x001,
     VMS_POINTER          = 0x002,
     VMS_ARRAY            = 0x004,
diff --git a/vmstate.c b/vmstate.c
index 18b3732..fe53735 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -13,7 +13,9 @@  static int vmstate_n_elems(void *opaque, VMStateField *field)
 {
     int n_elems = 1;
 
-    if (field->flags & VMS_ARRAY) {
+    if (!(field->flags & ~VMS_NONE)) {
+        n_elems = 0;
+    } else if (field->flags & VMS_ARRAY) {
         n_elems = field->num;
     } else if (field->flags & VMS_VARRAY_INT32) {
         n_elems = *(int32_t *)(opaque+field->num_offset);