All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] migration: Unregister yank if migration setup fails
@ 2021-06-22  2:42 Leonardo Bras
  2021-06-22 17:38 ` Peter Xu
  2021-06-24 17:14 ` Dr. David Alan Gilbert
  0 siblings, 2 replies; 6+ messages in thread
From: Leonardo Bras @ 2021-06-22  2:42 UTC (permalink / raw)
  To: Juan Quintela, Dr. David Alan Gilbert, Lukas Straub, Peter Xu
  Cc: Leonardo Bras, qemu-devel

Currently, if a qemu instance is started with "-incoming defer" and
an incorect parameter is passed to "migrate_incoming", it will print the
expected error and reply with "duplicate yank instance" for any upcoming
"migrate_incoming" command.

This renders current qemu process unusable, and requires a new qemu
process to be started before accepting a migration.

This is caused by a yank_register_instance() that happens in
qemu_start_incoming_migration() but is never reverted if any error
happens.

Solves this by unregistering the instance if anything goes wrong
in the function, allowing a new "migrate_incoming" command to be
accepted.

Fixes: b5eea99ec2f ("migration: Add yank feature", 2021-01-13)
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1974366
Signed-off-by: Leonardo Bras <leobras@redhat.com>

---
 migration/migration.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/migration/migration.c b/migration/migration.c
index 4228635d18..ddcf9e1868 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -474,9 +474,13 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)
     } else if (strstart(uri, "fd:", &p)) {
         fd_start_incoming_migration(p, errp);
     } else {
-        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
         error_setg(errp, "unknown migration protocol: %s", uri);
     }
+
+    if (*errp) {
+        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
+    }
+
 }
 
 static void process_incoming_migration_bh(void *opaque)
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] migration: Unregister yank if migration setup fails
  2021-06-22  2:42 [PATCH v1 1/1] migration: Unregister yank if migration setup fails Leonardo Bras
@ 2021-06-22 17:38 ` Peter Xu
  2021-06-22 23:31   ` Leonardo Bras Soares Passos
  2021-06-24 17:14 ` Dr. David Alan Gilbert
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Xu @ 2021-06-22 17:38 UTC (permalink / raw)
  To: Leonardo Bras
  Cc: qemu-devel, Lukas Straub, Dr. David Alan Gilbert, Juan Quintela

On Mon, Jun 21, 2021 at 11:42:36PM -0300, Leonardo Bras wrote:
> Currently, if a qemu instance is started with "-incoming defer" and
> an incorect parameter is passed to "migrate_incoming", it will print the
> expected error and reply with "duplicate yank instance" for any upcoming
> "migrate_incoming" command.
> 
> This renders current qemu process unusable, and requires a new qemu
> process to be started before accepting a migration.
> 
> This is caused by a yank_register_instance() that happens in
> qemu_start_incoming_migration() but is never reverted if any error
> happens.
> 
> Solves this by unregistering the instance if anything goes wrong
> in the function, allowing a new "migrate_incoming" command to be
> accepted.
> 
> Fixes: b5eea99ec2f ("migration: Add yank feature", 2021-01-13)
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1974366
> Signed-off-by: Leonardo Bras <leobras@redhat.com>
> 
> ---
>  migration/migration.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index 4228635d18..ddcf9e1868 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -474,9 +474,13 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)
>      } else if (strstart(uri, "fd:", &p)) {
>          fd_start_incoming_migration(p, errp);
>      } else {
> -        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
>          error_setg(errp, "unknown migration protocol: %s", uri);
>      }
> +
> +    if (*errp) {
> +        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
> +    }
> +
>  }

Yes, looks right to me:

Reviewed-by: Peter Xu <peterx@redhat.com>

-- 
Peter Xu



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] migration: Unregister yank if migration setup fails
  2021-06-22 17:38 ` Peter Xu
@ 2021-06-22 23:31   ` Leonardo Bras Soares Passos
  0 siblings, 0 replies; 6+ messages in thread
From: Leonardo Bras Soares Passos @ 2021-06-22 23:31 UTC (permalink / raw)
  To: Peter Xu; +Cc: qemu-devel, Lukas Straub, Dr. David Alan Gilbert, Juan Quintela

On Tue, Jun 22, 2021 at 2:38 PM Peter Xu <peterx@redhat.com> wrote:
[...]
> Yes, looks right to me:
>
> Reviewed-by: Peter Xu <peterx@redhat.com>
>
> --
> Peter Xu

Thanks Peter!



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] migration: Unregister yank if migration setup fails
  2021-06-22  2:42 [PATCH v1 1/1] migration: Unregister yank if migration setup fails Leonardo Bras
  2021-06-22 17:38 ` Peter Xu
@ 2021-06-24 17:14 ` Dr. David Alan Gilbert
  2021-06-24 17:20   ` Dr. David Alan Gilbert
  2021-06-24 17:29   ` Peter Xu
  1 sibling, 2 replies; 6+ messages in thread
From: Dr. David Alan Gilbert @ 2021-06-24 17:14 UTC (permalink / raw)
  To: Leonardo Bras; +Cc: Lukas Straub, qemu-devel, Peter Xu, Juan Quintela

* Leonardo Bras (leobras@redhat.com) wrote:
> Currently, if a qemu instance is started with "-incoming defer" and
> an incorect parameter is passed to "migrate_incoming", it will print the
> expected error and reply with "duplicate yank instance" for any upcoming
> "migrate_incoming" command.
> 
> This renders current qemu process unusable, and requires a new qemu
> process to be started before accepting a migration.
> 
> This is caused by a yank_register_instance() that happens in
> qemu_start_incoming_migration() but is never reverted if any error
> happens.
> 
> Solves this by unregistering the instance if anything goes wrong
> in the function, allowing a new "migrate_incoming" command to be
> accepted.
> 
> Fixes: b5eea99ec2f ("migration: Add yank feature", 2021-01-13)
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1974366
> Signed-off-by: Leonardo Bras <leobras@redhat.com>
> 
> ---
>  migration/migration.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index 4228635d18..ddcf9e1868 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -474,9 +474,13 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)
>      } else if (strstart(uri, "fd:", &p)) {
>          fd_start_incoming_migration(p, errp);
>      } else {
> -        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
>          error_setg(errp, "unknown migration protocol: %s", uri);
>      }
> +
> +    if (*errp) {
> +        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
> +    }

My understanding is that testing *errp isn't allowed, because
it's legal to pass NULL to ignore errors, or legal to pass
&error_abort to mean that any error you do hit will cause the
process to assert; so you need to have something separate you can test.

Dave

>  }
>  
>  static void process_incoming_migration_bh(void *opaque)
> -- 
> 2.32.0
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] migration: Unregister yank if migration setup fails
  2021-06-24 17:14 ` Dr. David Alan Gilbert
@ 2021-06-24 17:20   ` Dr. David Alan Gilbert
  2021-06-24 17:29   ` Peter Xu
  1 sibling, 0 replies; 6+ messages in thread
From: Dr. David Alan Gilbert @ 2021-06-24 17:20 UTC (permalink / raw)
  To: Leonardo Bras; +Cc: Lukas Straub, qemu-devel, Peter Xu, Juan Quintela

* Dr. David Alan Gilbert (dgilbert@redhat.com) wrote:
> * Leonardo Bras (leobras@redhat.com) wrote:
> > Currently, if a qemu instance is started with "-incoming defer" and
> > an incorect parameter is passed to "migrate_incoming", it will print the
> > expected error and reply with "duplicate yank instance" for any upcoming
> > "migrate_incoming" command.
> > 
> > This renders current qemu process unusable, and requires a new qemu
> > process to be started before accepting a migration.
> > 
> > This is caused by a yank_register_instance() that happens in
> > qemu_start_incoming_migration() but is never reverted if any error
> > happens.
> > 
> > Solves this by unregistering the instance if anything goes wrong
> > in the function, allowing a new "migrate_incoming" command to be
> > accepted.
> > 
> > Fixes: b5eea99ec2f ("migration: Add yank feature", 2021-01-13)
> > Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1974366
> > Signed-off-by: Leonardo Bras <leobras@redhat.com>
> > 
> > ---
> >  migration/migration.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/migration/migration.c b/migration/migration.c
> > index 4228635d18..ddcf9e1868 100644
> > --- a/migration/migration.c
> > +++ b/migration/migration.c
> > @@ -474,9 +474,13 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)
> >      } else if (strstart(uri, "fd:", &p)) {
> >          fd_start_incoming_migration(p, errp);
> >      } else {
> > -        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
> >          error_setg(errp, "unknown migration protocol: %s", uri);
> >      }
> > +
> > +    if (*errp) {
> > +        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
> > +    }
> 
> My understanding is that testing *errp isn't allowed, because
> it's legal to pass NULL to ignore errors, or legal to pass
> &error_abort to mean that any error you do hit will cause the
> process to assert; so you need to have something separate you can test.

Ah, and armbru points out there's a 'new' mechanism to make it safe;
you need to use ERRP_GUARD, see include/qapi/error.h if you want to
be able to test it.

Dave

> Dave
> 
> >  }
> >  
> >  static void process_incoming_migration_bh(void *opaque)
> > -- 
> > 2.32.0
> > 
> -- 
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] migration: Unregister yank if migration setup fails
  2021-06-24 17:14 ` Dr. David Alan Gilbert
  2021-06-24 17:20   ` Dr. David Alan Gilbert
@ 2021-06-24 17:29   ` Peter Xu
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Xu @ 2021-06-24 17:29 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: Lukas Straub, Leonardo Bras, qemu-devel, Juan Quintela

On Thu, Jun 24, 2021 at 06:14:39PM +0100, Dr. David Alan Gilbert wrote:
> * Leonardo Bras (leobras@redhat.com) wrote:
> > Currently, if a qemu instance is started with "-incoming defer" and
> > an incorect parameter is passed to "migrate_incoming", it will print the
> > expected error and reply with "duplicate yank instance" for any upcoming
> > "migrate_incoming" command.
> > 
> > This renders current qemu process unusable, and requires a new qemu
> > process to be started before accepting a migration.
> > 
> > This is caused by a yank_register_instance() that happens in
> > qemu_start_incoming_migration() but is never reverted if any error
> > happens.
> > 
> > Solves this by unregistering the instance if anything goes wrong
> > in the function, allowing a new "migrate_incoming" command to be
> > accepted.
> > 
> > Fixes: b5eea99ec2f ("migration: Add yank feature", 2021-01-13)
> > Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1974366
> > Signed-off-by: Leonardo Bras <leobras@redhat.com>
> > 
> > ---
> >  migration/migration.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/migration/migration.c b/migration/migration.c
> > index 4228635d18..ddcf9e1868 100644
> > --- a/migration/migration.c
> > +++ b/migration/migration.c
> > @@ -474,9 +474,13 @@ static void qemu_start_incoming_migration(const char *uri, Error **errp)
> >      } else if (strstart(uri, "fd:", &p)) {
> >          fd_start_incoming_migration(p, errp);
> >      } else {
> > -        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
> >          error_setg(errp, "unknown migration protocol: %s", uri);
> >      }
> > +
> > +    if (*errp) {
> > +        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
> > +    }
> 
> My understanding is that testing *errp isn't allowed, because
> it's legal to pass NULL to ignore errors, or legal to pass
> &error_abort to mean that any error you do hit will cause the
> process to assert; so you need to have something separate you can test.

Per my understanding error_abort should be fine, as the value of error_abort is
still NULL (in error_setg() we only check against &error_abort as the pointer,
and its value seems to be better always be NULL..).

But indeed at least we need "errp && *errp", but that won't capture the case
when errp==NULL.

So I think we may need to define a local error, check here when unregister
yank, and do error_propagate() before return..

-- 
Peter Xu



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-24 17:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22  2:42 [PATCH v1 1/1] migration: Unregister yank if migration setup fails Leonardo Bras
2021-06-22 17:38 ` Peter Xu
2021-06-22 23:31   ` Leonardo Bras Soares Passos
2021-06-24 17:14 ` Dr. David Alan Gilbert
2021-06-24 17:20   ` Dr. David Alan Gilbert
2021-06-24 17:29   ` Peter Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.