Monitor: Convert do_migrate() to cmd_new_ret()
authorLuiz Capitulino <lcapitulino@redhat.com>
Thu, 11 Feb 2010 01:49:57 +0000 (23:49 -0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 19 Feb 2010 21:18:17 +0000 (15:18 -0600)
While there I'm also dropping a unneeded else clause (the last
one in the function).

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
migration.c
migration.h
qemu-monitor.hx

index 557bec4f2a4c86bdc82b7369ecd2877b909413e8..05f6cc5a0f5004301ff0cd0f5fa9163301480ba2 100644 (file)
@@ -54,7 +54,7 @@ void qemu_start_incoming_migration(const char *uri)
         fprintf(stderr, "unknown migration protocol: %s\n", uri);
 }
 
-void do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
+int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     MigrationState *s = NULL;
     const char *p;
@@ -64,38 +64,43 @@ void do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
     if (current_migration &&
         current_migration->get_status(current_migration) == MIG_STATE_ACTIVE) {
         monitor_printf(mon, "migration already in progress\n");
-        return;
+        return -1;
     }
 
-    if (strstart(uri, "tcp:", &p))
+    if (strstart(uri, "tcp:", &p)) {
         s = tcp_start_outgoing_migration(mon, p, max_throttle, detach,
                                          (int)qdict_get_int(qdict, "blk"), 
                                          (int)qdict_get_int(qdict, "inc"));
 #if !defined(WIN32)
-    else if (strstart(uri, "exec:", &p))
+    } else if (strstart(uri, "exec:", &p)) {
         s = exec_start_outgoing_migration(mon, p, max_throttle, detach,
                                           (int)qdict_get_int(qdict, "blk"), 
                                           (int)qdict_get_int(qdict, "inc"));
-    else if (strstart(uri, "unix:", &p))
+    } else if (strstart(uri, "unix:", &p)) {
         s = unix_start_outgoing_migration(mon, p, max_throttle, detach,
                                          (int)qdict_get_int(qdict, "blk"), 
                                           (int)qdict_get_int(qdict, "inc"));
-    else if (strstart(uri, "fd:", &p))
+    } else if (strstart(uri, "fd:", &p)) {
         s = fd_start_outgoing_migration(mon, p, max_throttle, detach, 
                                         (int)qdict_get_int(qdict, "blk"), 
                                         (int)qdict_get_int(qdict, "inc"));
 #endif
-    else
+    } else {
         monitor_printf(mon, "unknown migration protocol: %s\n", uri);
+        return -1;
+    }
 
-    if (s == NULL)
+    if (s == NULL) {
         monitor_printf(mon, "migration failed\n");
-    else {
-        if (current_migration)
-            current_migration->release(current_migration);
+        return -1;
+    }
 
-        current_migration = s;
+    if (current_migration) {
+        current_migration->release(current_migration);
     }
+
+    current_migration = s;
+    return 0;
 }
 
 int do_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data)
index 9345d9749472f5ee24e596ee5c1aeb933cdb2acd..385423f11d266c3a75409d9daaab5409d6c141e2 100644 (file)
@@ -52,7 +52,7 @@ struct FdMigrationState
 
 void qemu_start_incoming_migration(const char *uri);
 
-void do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data);
+int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data);
 
 int do_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data);
 
index e987cf100c066a6e6f92ef96c0d0a20452f41ef9..3a1f9bc5184c146fe63f1a063cb40107d373ab6d 100644 (file)
@@ -773,7 +773,7 @@ ETEXI
                      "shared storage with incremental copy of disk "
                      "(base image shared between src and destination)",
         .user_print = monitor_user_noop,       
-       .mhandler.cmd_new = do_migrate,
+       .cmd_new_ret = do_migrate,
     },