qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH v2 01/16] Visitor: Add methods for migration


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] [RFC PATCH v2 01/16] Visitor: Add methods for migration format use
Date: Wed, 7 May 2014 13:32:01 +0300

On Wed, May 07, 2014 at 11:23:05AM +0100, Dr. David Alan Gilbert wrote:
> * Michael S. Tsirkin (address@hidden) wrote:
> > On Wed, Apr 23, 2014 at 05:37:34PM +0100, Dr. David Alan Gilbert (git) 
> > wrote:
> 
> <snip>
> 
> > > +/* Type of visitor, used where actions have to be taken when 
> > > (de)serializing */
> > > +bool visitor_loading(Visitor *v);
> > > +bool visitor_saving(Visitor *v);
> > > +
> > > +typedef enum {
> > > +    VISIT_SEQ_COMPAT_BYTE0TERM,      /* list terminated with a 0 byte */
> > > +    VISIT_SEQ_COMPAT_FILE,           /* The top level file object */
> > > +    VISIT_SEQ_COMPAT_SUBSECLIST,     /* list terminated by
> > > +                                        historical complexity */
> > > +    VISIT_SEQ_COMPAT_SUBSECTION,     /* One subsection */
> > > +    VISIT_SEQ_COMPAT_SECTION_HEADER, /* SECTION_FULL/START, header + 
> > > name */
> > > +    VISIT_SEQ_COMPAT_SECTION_MIN,    /* SECTION_PART/END - minimal 
> > > header */
> > > +    VISIT_SEQ_COMPAT_RAMSECLIST,     /* list terminated by int64 bit
> > > +                                        RAM_SAVE_FLAG_EOS */
> > > +    VISIT_SEQ_COMPAT_RAMSECENTRY,    /* Entry in RAM Sec list */
> > > +    VISIT_SEQ_COMPAT_VMSTATE,        /* One VMState */
> > > +    VISIT_SEQ_COMPAT_BLOB            /* A binary old-format blob */
> > > +} Visit_seq_compat_mode;
> > 
> > VisitorSeqCompatMode
> 
> Fixed.
> 
> > We have visit_ for functions but Visitor for types ...
> 
> So should I be changing those visitor_loading/saving's to visit_ ?
> 
> Dave

I don't think so: visit_ seems to be the function that actually visits something
:)


> > 
> > > +
> > > +/* Start a sequence of items (which may be of unknown length and unknown
> > > + * mix of some subset of types), specify a compatibility mode that's only
> > > + * used by an implementation trying to match the existing binary 
> > > migration
> > > + * format.
> > > + * opaque is compat_mode specific
> > > + */
> > > +void visit_start_sequence_compat(Visitor *v, const char *name,
> > > +                                 Visit_seq_compat_mode compat_mode,
> > > +                                 void *opaque,
> > > +                                 Error **errp);
> > > +/* Use visit_get_next_type for each entry including the first */
> > > +void visit_end_sequence_compat(Visitor *v, const char *name,
> > > +                                 Visit_seq_compat_mode compat_mode,
> > > +                                 Error **errp);
> > > +
> > > +/* Don't Use! - lets us move forward until we can get rid of all file 
> > > uses */
> > > +QEMUFile *visitor_get_qemufile(Visitor *v);
> > >  
> > >  #endif
> > > diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
> > > index 6451a21..2d20fde 100644
> > > --- a/qapi/qapi-visit-core.c
> > > +++ b/qapi/qapi-visit-core.c
> > > @@ -84,6 +84,28 @@ void visit_end_list(Visitor *v, Error **errp)
> > >      v->end_list(v, errp);
> > >  }
> > >  
> > > +void visit_start_array(Visitor *v, void **obj, const char *name,
> > > +                       size_t elem_count, size_t elem_size, Error **errp)
> > > +{
> > > +    if (!error_is_set(errp)) {
> > > +        v->start_array(v, obj, name, elem_count, elem_size, errp);
> > > +    }
> > > +}
> > > +
> > > +void visit_next_array(Visitor *v, Error **errp)
> > > +{
> > > +    if (!error_is_set(errp)) {
> > > +        v->next_array(v, errp);
> > > +    }
> > > +}
> > > +
> > > +void visit_end_array(Visitor *v, Error **errp)
> > > +{
> > > +    if (!error_is_set(errp)) {
> > > +        v->end_array(v, errp);
> > > +    }
> > > +}
> > > +
> > >  void visit_start_optional(Visitor *v, bool *present, const char *name,
> > >                            Error **errp)
> > >  {
> > > @@ -107,6 +129,14 @@ void visit_get_next_type(Visitor *v, int *obj, const 
> > > int *qtypes,
> > >      }
> > >  }
> > >  
> > > +void visit_type_buffer(Visitor *v, void *data, size_t len, bool async,
> > > +                       const char *name, Error **errp)
> > > +{
> > > +    if (!error_is_set(errp)) {
> > > +        v->type_buffer(v, data, len, async, name, errp);
> > > +    }
> > > +}
> > > +
> > >  void visit_type_enum(Visitor *v, int *obj, const char *strings[],
> > >                       const char *kind, const char *name, Error **errp)
> > >  {
> > > @@ -291,6 +321,13 @@ void visit_type_str(Visitor *v, char **obj, const 
> > > char *name, Error **errp)
> > >      }
> > >  }
> > >  
> > > +void visit_type_str256(Visitor *v, char *obj, const char *name, Error 
> > > **errp)
> > > +{
> > > +    if (!error_is_set(errp)) {
> > > +        v->type_str256(v, obj, name, errp);
> > > +    }
> > > +}
> > > +
> > >  void visit_type_number(Visitor *v, double *obj, const char *name, Error 
> > > **errp)
> > >  {
> > >      if (!error_is_set(errp)) {
> > > @@ -347,3 +384,46 @@ void input_type_enum(Visitor *v, int *obj, const 
> > > char *strings[],
> > >      g_free(enum_str);
> > >      *obj = value;
> > >  }
> > > +
> > > +void visit_destroy(Visitor *v, Error **errp)
> > > +{
> > > +    v->destroy(v, errp);
> > > +}
> > > +
> > > +void visit_start_sequence_compat(Visitor *v, const char *name,
> > > +                                 Visit_seq_compat_mode compat_mode,
> > > +                                 void *opaque, Error **errp)
> > > +{
> > > +    if (error_is_set(errp)) {
> > > +        return;
> > > +    }
> > > +
> > > +    v->start_sequence_compat(v, name, compat_mode, opaque, errp);
> > > +}
> > > +
> > > +void visit_end_sequence_compat(Visitor *v, const char *name,
> > > +                                 Visit_seq_compat_mode compat_mode,
> > > +                               Error **errp)
> > > +{
> > > +    if (error_is_set(errp)) {
> > > +        return;
> > > +    }
> > > +
> > > +    v->end_sequence_compat(v, name, compat_mode, errp);
> > > +}
> > > +
> > > +QEMUFile *visitor_get_qemufile(Visitor *v)
> > > +{
> > > +    return v->get_qemufile(v);
> > > +}
> > > +
> > > +bool visitor_loading(Visitor *v)
> > > +{
> > > +    return v->flags & VISITOR_LOADING;
> > > +}
> > > +
> > > +bool visitor_saving(Visitor *v)
> > > +{
> > > +    return v->flags & VISITOR_SAVING;
> > > +}
> > > +
> > > -- 
> > > 1.9.0
> --
> Dr. David Alan Gilbert / address@hidden / Manchester, UK



reply via email to

[Prev in Thread] Current Thread [Next in Thread]