qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Fabiano Rosas <farosas@suse.de>
Cc: qemu-devel@nongnu.org, Juan Quintela <quintela@redhat.com>
Subject: Re: [PATCH] migration: Unify and trace vmstate field_exists() checks
Date: Tue, 3 Oct 2023 11:04:51 -0400	[thread overview]
Message-ID: <ZRwtkwKy2p/gN521@x1n> (raw)
In-Reply-To: <87ledi8aev.fsf@suse.de>

On Thu, Sep 07, 2023 at 08:55:52AM -0300, Fabiano Rosas wrote:
> Peter Xu <peterx@redhat.com> writes:
> 
> > For both save/load we actually share the logic on deciding whether a field
> > should exist.  Merge the checks into a helper and use it for both save and
> > load.  When doing so, add documentations and reformat the code to make it
> > much easier to read.
> >
> > The real benefit here (besides code cleanups) is we add a trace-point for
> > this; this is a known spot where we can easily break migration
> > compatibilities between binaries, and this trace point will be critical for
> > us to identify such issues.
> >
> > For example, this will be handy when debugging things like:
> >
> > https://gitlab.com/qemu-project/qemu/-/issues/932
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >  migration/vmstate.c    | 34 ++++++++++++++++++++++++++--------
> >  migration/trace-events |  1 +
> >  2 files changed, 27 insertions(+), 8 deletions(-)
> >
> > diff --git a/migration/vmstate.c b/migration/vmstate.c
> > index 31842c3afb..73e74ddea0 100644
> > --- a/migration/vmstate.c
> > +++ b/migration/vmstate.c
> > @@ -25,6 +25,30 @@ static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
> >  static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
> >                                     void *opaque);
> >  
> > +/* Whether this field should exist for either save or load the VM? */
> > +static bool
> > +vmstate_field_exists(const VMStateDescription *vmsd, const VMStateField *field,
> > +                     void *opaque, int version_id)
> > +{
> > +    bool result;
> > +
> > +    if (field->field_exists) {
> > +        /* If there's the function checker, that's the solo truth */
> > +        result = field->field_exists(opaque, version_id);
> > +        trace_vmstate_field_exists(vmsd->name, field->name, field->version_id,
> > +                                   version_id, result);
> > +    } else {
> > +        /*
> > +         * Otherwise, we only save/load if field version is same or older.
> > +         * For example, when loading from an old binary with old version,
> > +         * we ignore new fields with newer version_ids.
> > +         */
> > +        result = field->version_id <= version_id;
> 
> This one doesn't get a trace?

Right, I didn't add that since I found mostly the bug comes from
field_exists() returning different values for different qemu binaries.
So I explicitly didn't include that otherwise we'll see tons of entries
under that regard but is probably safe.

> 
> Aside from that:
> 
> Reviewed-by: Fabiano Rosas <farosas@suse.de>

Thanks!

-- 
Peter Xu



  reply	other threads:[~2023-10-03 15:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06 20:47 [PATCH] migration: Unify and trace vmstate field_exists() checks Peter Xu
2023-09-07 11:55 ` Fabiano Rosas
2023-10-03 15:04   ` Peter Xu [this message]
2023-10-04 11:19 ` Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZRwtkwKy2p/gN521@x1n \
    --to=peterx@redhat.com \
    --cc=farosas@suse.de \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).