Skip to contentSkip to conversation

migration: Unregister yank if migration setup fails

PATCH Superseded Leonardo Bras 3 participants 6 messages Jun 22, 2021 – Jun 24, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 migration: Unregister yank if migration setup fails

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)
---
 migration/migration.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
migration/migration.c +5 -1
index 4228635d18..ddcf9e1868 100644
@@ -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)
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 31 lines · Leonardo Bras

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)
---
 migration/migration.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
migration/migration.c +0 -0
index 4228635d18..ddcf9e1868 100644
@@ -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);

migration/migration.c static void qemu_start_incoming_migration(const char *uri, Error **errp) · line 484

Quoted 10 lines
migration/migration.c +5 -1
     } 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:

Signature · 1 line
Peter Xu
#3 lore raw
In reply to Leonardo Bras
Quoted 29 lines · * Leonardo Bras ([email protected]) 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)
---
 migration/migration.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
migration/migration.c +0 -0
index 4228635d18..ddcf9e1868 100644

migration/migration.c static void qemu_start_incoming_migration(const char *uri, Error **errp) · line 482

Quoted 10 lines
migration/migration.c +4 -1
@@ -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

Quoted 6 lines
migration/migration.c +0 -0
 }
 
 static void process_incoming_migration_bh(void *opaque)
Signature · 1 line
2.32.0
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#4 lore raw
Quoted 37 lines · * Dr. David Alan Gilbert ([email protected]) wrote:
Quoted 36 lines · * Leonardo Bras ([email protected]) 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)
---
 migration/migration.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
migration/migration.c +1 -1
index 4228635d18..ddcf9e1868 100644
@@ -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);
     }
+
Quoted 8 lines

migration/migration.c static void qemu_start_incoming_migration(const char *uri, Error **errp) · line 482

Quoted 3 lines
migration/migration.c +3 -0
+    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

Quoted 10 lines

Dave

Quoted 6 lines
migration/migration.c +0 -0
 }
 
 static void process_incoming_migration_bh(void *opaque)
Signature · 1 line
2.32.0
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#5 lore raw
In reply to Dr. David Alan Gilbert
Quoted 37 lines · Dr. David Alan Gilbert
Quoted 36 lines · * Leonardo Bras ([email protected]) 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)
---
 migration/migration.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
migration/migration.c +1 -1
index 4228635d18..ddcf9e1868 100644
@@ -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);
     }
+
Quoted 8 lines

migration/migration.c static void qemu_start_incoming_migration(const char *uri, Error **errp) · line 482

Quoted 3 lines
migration/migration.c +3 -0
+    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..

Signature · 1 line
Peter Xu