Patchwork [v3,1/5] Exit if incoming migration fails

login
register
mail settings
Submitter Juan Quintela
Date June 9, 2010, 12:10 p.m.
Message ID <f74cbc2cf372cba1dfeafaae482902ed335fbb48.1276085283.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/55084/
State New
Headers show

Comments

Juan Quintela - June 9, 2010, 12:10 p.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration.c |   16 ++++++++++------
 migration.h |    2 +-
 vl.c        |    7 ++++++-
 3 files changed, 17 insertions(+), 8 deletions(-)
Anthony Liguori - June 23, 2010, 1:47 a.m.
On 06/09/2010 07:10 AM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela<quintela@redhat.com>
>    

Applied 1&2 as we discussed.  Thanks.

Regards,

Anthony Liguori
> ---
>   migration.c |   16 ++++++++++------
>   migration.h |    2 +-
>   vl.c        |    7 ++++++-
>   3 files changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/migration.c b/migration.c
> index fbf2339..ecc67f1 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -36,22 +36,26 @@ 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;
>
>       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
> +    else {
>           fprintf(stderr, "unknown migration protocol: %s\n", uri);
> +        ret = -EPROTONOSUPPORT;
> +    }
> +    return ret;
>   }
>
>   int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
> diff --git a/migration.h b/migration.h
> index 97eef4a..e048bb2 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 7121cd0..c35b46e 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3826,7 +3826,12 @@ int main(int argc, char **argv, char **envp)
>       }
>
>       if (incoming) {
> -        qemu_start_incoming_migration(incoming);
> +        int ret = qemu_start_incoming_migration(incoming);
> +        if (ret<  0) {
> +            fprintf(stderr, "Migration failed. Exit code %s(%d), exiting.\n",
> +                    incoming, ret);
> +            exit(ret);
> +        }
>       } else if (autostart) {
>           vm_start();
>       }
>

Patch

diff --git a/migration.c b/migration.c
index fbf2339..ecc67f1 100644
--- a/migration.c
+++ b/migration.c
@@ -36,22 +36,26 @@  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;

     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
+    else {
         fprintf(stderr, "unknown migration protocol: %s\n", uri);
+        ret = -EPROTONOSUPPORT;
+    }
+    return ret;
 }

 int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
diff --git a/migration.h b/migration.h
index 97eef4a..e048bb2 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 7121cd0..c35b46e 100644
--- a/vl.c
+++ b/vl.c
@@ -3826,7 +3826,12 @@  int main(int argc, char **argv, char **envp)
     }

     if (incoming) {
-        qemu_start_incoming_migration(incoming);
+        int ret = qemu_start_incoming_migration(incoming);
+        if (ret < 0) {
+            fprintf(stderr, "Migration failed. Exit code %s(%d), exiting.\n",
+                    incoming, ret);
+            exit(ret);
+        }
     } else if (autostart) {
         vm_start();
     }