diff mbox

[1/5] Exit if incoming migration fails

Message ID 9fed8fc8d5a596bd8fdf125ffadc8f55dc39eb2b.1274688090.git.quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela May 24, 2010, 8:25 a.m. UTC
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration.c |   14 +++++++-------
 migration.h |    2 +-
 vl.c        |    5 ++++-
 3 files changed, 12 insertions(+), 9 deletions(-)

Comments

Paolo Bonzini May 24, 2010, 9:02 a.m. UTC | #1
> -void qemu_start_incoming_migration(const char *uri)
> +int qemu_start_incoming_migration(const char *uri)
>   {
>       const char *p;
> +    int ret = -1;

Maybe -ENOSYS or -EPROTONOSUPPORT, since the *_start_incoming_migration 
functions return a negative errno value?

>       if (incoming) {
> -        qemu_start_incoming_migration(incoming);
> +        if (qemu_start_incoming_migration(incoming)<  0) {
> +            fprintf(stderr, "unknown migration protocol: %s\n", incoming);
> +            exit(1);
> +        }

Dually, if you have a failure from *_start_incoming_migration, this 
fprintf is spurious.

Paolo
Michael S. Tsirkin May 24, 2010, 11:53 a.m. UTC | #2
On Mon, May 24, 2010 at 10:25:25AM +0200, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  migration.c |   14 +++++++-------
>  migration.h |    2 +-
>  vl.c        |    5 ++++-
>  3 files changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/migration.c b/migration.c
> index 05f6cc5..cf30a8e 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -36,22 +36,22 @@ static uint32_t max_throttle = (32 << 20);
> 
>  static MigrationState *current_migration;
> 
> -void qemu_start_incoming_migration(const char *uri)
> +int qemu_start_incoming_migration(const char *uri)
>  {
>      const char *p;
> +    int ret = -1;
> 
>      if (strstart(uri, "tcp:", &p))
> -        tcp_start_incoming_migration(p);
> +        ret = tcp_start_incoming_migration(p);
>  #if !defined(WIN32)
>      else if (strstart(uri, "exec:", &p))
> -        exec_start_incoming_migration(p);
> +        ret =  exec_start_incoming_migration(p);
>      else if (strstart(uri, "unix:", &p))
> -        unix_start_incoming_migration(p);
> +        ret = unix_start_incoming_migration(p);
>      else if (strstart(uri, "fd:", &p))
> -        fd_start_incoming_migration(p);
> +        ret = fd_start_incoming_migration(p);
>  #endif
> -    else
> -        fprintf(stderr, "unknown migration protocol: %s\n", uri);

I think we need this message, this is where we know
reason for failure is bad protocol.

> +    return ret;
>  }
> 
>  int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
> diff --git a/migration.h b/migration.h
> index 385423f..dd423a1 100644
> --- a/migration.h
> +++ b/migration.h
> @@ -50,7 +50,7 @@ struct FdMigrationState
>      void *opaque;
>  };
> 
> -void qemu_start_incoming_migration(const char *uri);
> +int qemu_start_incoming_migration(const char *uri);
> 
>  int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data);
> 
> diff --git a/vl.c b/vl.c
> index d77b47c..3dfab9e 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3841,7 +3841,10 @@ int main(int argc, char **argv, char **envp)
>      }
> 
>      if (incoming) {
> -        qemu_start_incoming_migration(incoming);
> +        if (qemu_start_incoming_migration(incoming) < 0) {
> +            fprintf(stderr, "unknown migration protocol: %s\n", incoming);
> +            exit(1);
> +        }

Let's put here: 'Migration failed. Exit code %s(%d), exiting.\n'
and then exit(ret);

>      } else if (autostart) {
>          vm_start();
>      }
> -- 
> 1.6.6.1
>
diff mbox

Patch

diff --git a/migration.c b/migration.c
index 05f6cc5..cf30a8e 100644
--- a/migration.c
+++ b/migration.c
@@ -36,22 +36,22 @@  static uint32_t max_throttle = (32 << 20);

 static MigrationState *current_migration;

-void qemu_start_incoming_migration(const char *uri)
+int qemu_start_incoming_migration(const char *uri)
 {
     const char *p;
+    int ret = -1;

     if (strstart(uri, "tcp:", &p))
-        tcp_start_incoming_migration(p);
+        ret = tcp_start_incoming_migration(p);
 #if !defined(WIN32)
     else if (strstart(uri, "exec:", &p))
-        exec_start_incoming_migration(p);
+        ret =  exec_start_incoming_migration(p);
     else if (strstart(uri, "unix:", &p))
-        unix_start_incoming_migration(p);
+        ret = unix_start_incoming_migration(p);
     else if (strstart(uri, "fd:", &p))
-        fd_start_incoming_migration(p);
+        ret = fd_start_incoming_migration(p);
 #endif
-    else
-        fprintf(stderr, "unknown migration protocol: %s\n", uri);
+    return ret;
 }

 int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
diff --git a/migration.h b/migration.h
index 385423f..dd423a1 100644
--- a/migration.h
+++ b/migration.h
@@ -50,7 +50,7 @@  struct FdMigrationState
     void *opaque;
 };

-void qemu_start_incoming_migration(const char *uri);
+int qemu_start_incoming_migration(const char *uri);

 int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data);

diff --git a/vl.c b/vl.c
index d77b47c..3dfab9e 100644
--- a/vl.c
+++ b/vl.c
@@ -3841,7 +3841,10 @@  int main(int argc, char **argv, char **envp)
     }

     if (incoming) {
-        qemu_start_incoming_migration(incoming);
+        if (qemu_start_incoming_migration(incoming) < 0) {
+            fprintf(stderr, "unknown migration protocol: %s\n", incoming);
+            exit(1);
+        }
     } else if (autostart) {
         vm_start();
     }