qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, "Juraj Marcin" <jmarcin@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>
Subject: Re: [PATCH for-11.0 3/6] migration: Make migration_connect_set_error() own the error
Date: Fri, 28 Nov 2025 11:58:27 -0500	[thread overview]
Message-ID: <aSnUsxSCkkVJbcMt@x1.local> (raw)
In-Reply-To: <87jyzdfe2z.fsf@pond.sub.org>

On Wed, Nov 26, 2025 at 08:27:48AM +0100, Markus Armbruster wrote:
> Peter Xu <peterx@redhat.com> writes:
> 
> > Make migration_connect_set_error() take ownership of the error always.
> > Paving way for making migrate_set_error() to take ownership.
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >  migration/channel.c   | 1 -
> >  migration/migration.c | 7 ++++---
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/migration/channel.c b/migration/channel.c
> > index 462cc183e1..92435fa7f7 100644
> > --- a/migration/channel.c
> > +++ b/migration/channel.c
> > @@ -95,7 +95,6 @@ void migration_channel_connect(MigrationState *s,
> >          }
> >      }
> >      migration_connect(s, error);
> > -    error_free(error);
> >  }
> >  
> >  
> > diff --git a/migration/migration.c b/migration/migration.c
> > index b316ee01ab..4fe69cc2ef 100644
> > --- a/migration/migration.c
> > +++ b/migration/migration.c
> > @@ -1575,7 +1575,7 @@ static void migrate_error_free(MigrationState *s)
> >      }
> >  }
> >  
> > -static void migration_connect_set_error(MigrationState *s, const Error *error)
> > +static void migration_connect_set_error(MigrationState *s, Error *error)
> 
> Recommend to rename for the same reason you rename migrate_set_error()
> in the last patch.
> 
> Bonus: all calls become visible in the patch, easing review.

Makes sense, will do.

> 
> >  {
> >      MigrationStatus current = s->state;
> >      MigrationStatus next;
> > @@ -1602,6 +1602,7 @@ static void migration_connect_set_error(MigrationState *s, const Error *error)
> >  
> >      migrate_set_state(&s->state, current, next);
> >      migrate_set_error(s, error);
> > +    error_free(error);
> >  }
> >  
> >  void migration_cancel(void)
> > @@ -2292,7 +2293,7 @@ void qmp_migrate(const char *uri, bool has_channels,
> >  
> >  out:
> >      if (local_err) {
> > -        migration_connect_set_error(s, local_err);
> > +        migration_connect_set_error(s, error_copy(local_err));
> >          error_propagate(errp, local_err);
> >      }
> >  }
> > @@ -2337,7 +2338,7 @@ static void qmp_migrate_finish(MigrationAddress *addr, bool resume_requested,
> >          if (!resume_requested) {
> >              yank_unregister_instance(MIGRATION_YANK_INSTANCE);
> >          }
> > -        migration_connect_set_error(s, local_err);
> > +        migration_connect_set_error(s, error_copy(local_err));
> >          error_propagate(errp, local_err);
> >          return;
> >      }
> 
> There's one more call in migration_connect().  Doesn't it need an
> error_copy() now?  Oh, I see: it doesn't, because its only caller
> migration_channel_connect() loses its error_free() in the first hunk.
> 
> So, migration_connect() *also* takes ownership now.  The commit message
> should cover this.

Will add a note.

> 
> Aside: I'd be tempted to lift the if (error_in) code from
> migration_connect() to migration_channel_connect() and drop the
> @error_in parameter.

It was deliberately introduced in:

commit 688a3dcba980bf01344a1ae2bc37fea44c6014ac
Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
Date:   Fri Dec 15 17:16:55 2017 +0000

    migration: Route errors down through migration_channel_connect

That change will need some justification and care taken on its own when
changing back to before.  I plan to stick with the current goal of this
series so far (which is to remove autoptr for Error and also make the main
migration error API to follow Error's) to land this first.

Thanks!

-- 
Peter Xu



  reply	other threads:[~2025-11-28 16:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-25 20:46 [PATCH for-11.0 0/6] migration: Error reporting cleanups Peter Xu
2025-11-25 20:46 ` [PATCH for-11.0 1/6] migration: Use explicit error_free() instead of g_autoptr Peter Xu
2025-11-26  6:43   ` Markus Armbruster
2025-11-25 20:46 ` [PATCH for-11.0 2/6] Revert "error: define g_autoptr() cleanup function for the Error type" Peter Xu
2025-11-26  6:45   ` Markus Armbruster
2025-11-26  7:43   ` Cédric Le Goater
2025-11-26  8:08     ` Markus Armbruster
2025-11-26 14:34   ` [PATCH 2.5/6] error: Explain why we don't g_autoptr(Error) Markus Armbruster
2025-11-26 15:14     ` Cédric Le Goater
2025-11-26 16:18       ` Peter Xu
2025-11-27  7:01         ` Markus Armbruster
2025-11-26 20:21   ` [PATCH for-11.0 2/6] Revert "error: define g_autoptr() cleanup function for the Error type" Maciej S. Szmigiero
2025-11-27  7:10   ` [PATCH 2.5/6] error: Poison g_autoptr(Error) to prevent its use Markus Armbruster
2025-11-27 15:34     ` Cédric Le Goater
2025-11-25 20:46 ` [PATCH for-11.0 3/6] migration: Make migration_connect_set_error() own the error Peter Xu
2025-11-26  7:27   ` Markus Armbruster
2025-11-28 16:58     ` Peter Xu [this message]
2025-11-25 20:46 ` [PATCH for-11.0 4/6] migration: Make multifd_send_set_error() " Peter Xu
2025-11-26  7:30   ` Markus Armbruster
2025-11-26  7:32     ` Markus Armbruster
2025-11-25 20:46 ` [PATCH for-11.0 5/6] migration: Make multifd_recv_terminate_threads() " Peter Xu
2025-11-25 20:46 ` [PATCH for-11.0 6/6] migration: Replace migrate_set_error() with migrate_error_propagate() Peter Xu
2025-11-26  7:57   ` Markus Armbruster
2025-12-01 17:32     ` Peter Xu

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=aSnUsxSCkkVJbcMt@x1.local \
    --to=peterx@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=farosas@suse.de \
    --cc=jmarcin@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /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).