]> git.proxmox.com Git - qemu.git/commitdiff
Factorize common migration incoming code
authorJuan Quintela <quintela@redhat.com>
Wed, 9 Jun 2010 12:10:55 +0000 (14:10 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 22 Jun 2010 20:15:51 +0000 (15:15 -0500)
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
migration-exec.c
migration-fd.c
migration-tcp.c
migration-unix.c
migration.c
migration.h

index a8813b4fbf7a0e5ac63be2c9c352b1216d01a5bf..14718dd1d1fdbcd5e2f814ba10b658301cb57591 100644 (file)
@@ -121,20 +121,8 @@ err_after_alloc:
 static void exec_accept_incoming_migration(void *opaque)
 {
     QEMUFile *f = opaque;
-    int ret;
 
-    ret = qemu_loadvm_state(f);
-    if (ret < 0) {
-        fprintf(stderr, "load of migration failed\n");
-        goto err;
-    }
-    qemu_announce_self();
-    DPRINTF("successfully loaded vm state\n");
-
-    if (autostart)
-        vm_start();
-
-err:
+    process_incoming_migration(f);
     qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
     qemu_fclose(f);
 }
index 0abd372af5b42027c507082ce53b4fe6ea5c8803..6d145056324bd7238ec6282c0632494f7cc6e54f 100644 (file)
@@ -104,20 +104,8 @@ err_after_alloc:
 static void fd_accept_incoming_migration(void *opaque)
 {
     QEMUFile *f = opaque;
-    int ret;
 
-    ret = qemu_loadvm_state(f);
-    if (ret < 0) {
-        fprintf(stderr, "load of migration failed\n");
-        goto err;
-    }
-    qemu_announce_self();
-    DPRINTF("successfully loaded vm state\n");
-
-    if (autostart)
-        vm_start();
-
-err:
+    process_incoming_migration(f);
     qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
     qemu_fclose(f);
 }
index 43af2e04505c7450478270903b22c7760b76307f..78b56dc3f6a7f81f8a44479a70a5b40e9465bcfc 100644 (file)
@@ -141,7 +141,7 @@ static void tcp_accept_incoming_migration(void *opaque)
     socklen_t addrlen = sizeof(addr);
     int s = (unsigned long)opaque;
     QEMUFile *f;
-    int c, ret;
+    int c;
 
     do {
         c = qemu_accept(s, (struct sockaddr *)&addr, &addrlen);
@@ -160,18 +160,7 @@ static void tcp_accept_incoming_migration(void *opaque)
         goto out;
     }
 
-    ret = qemu_loadvm_state(f);
-    if (ret < 0) {
-        fprintf(stderr, "load of migration failed\n");
-        goto out_fopen;
-    }
-    qemu_announce_self();
-    DPRINTF("successfully loaded vm state\n");
-
-    if (autostart)
-        vm_start();
-
-out_fopen:
+    process_incoming_migration(f);
     qemu_fclose(f);
 out:
     qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
index 49de1b9e84353dfc454cbf6d62046b0af29a333a..57232c07a934156ff8948418970ce925d0da5191 100644 (file)
@@ -149,7 +149,7 @@ static void unix_accept_incoming_migration(void *opaque)
     socklen_t addrlen = sizeof(addr);
     int s = (unsigned long)opaque;
     QEMUFile *f;
-    int c, ret;
+    int c;
 
     do {
         c = qemu_accept(s, (struct sockaddr *)&addr, &addrlen);
@@ -168,18 +168,7 @@ static void unix_accept_incoming_migration(void *opaque)
         goto out;
     }
 
-    ret = qemu_loadvm_state(f);
-    if (ret < 0) {
-        fprintf(stderr, "load of migration failed\n");
-        goto out_fopen;
-    }
-    qemu_announce_self();
-    DPRINTF("successfully loaded vm state\n");
-
-    if (autostart)
-        vm_start();
-
-out_fopen:
+    process_incoming_migration(f);
     qemu_fclose(f);
 out:
     qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
index 85c81e098335f001c46af23b28b3a27225a08c75..b49964c5e3a3c81a4b8b8d87be8c7923d0f4d21b 100644 (file)
@@ -58,6 +58,19 @@ int qemu_start_incoming_migration(const char *uri)
     return ret;
 }
 
+void process_incoming_migration(QEMUFile *f)
+{
+    if (qemu_loadvm_state(f) < 0) {
+        fprintf(stderr, "load of migration failed\n");
+        exit(0);
+    }
+    qemu_announce_self();
+    DPRINTF("successfully loaded vm state\n");
+
+    if (autostart)
+        vm_start();
+}
+
 int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     MigrationState *s = NULL;
index e048bb2e8b11d91aa734b7fe2178c9882aab8a04..d13ed4fca956f81c748f860ac1925ad1842f1f0a 100644 (file)
@@ -50,6 +50,8 @@ struct FdMigrationState
     void *opaque;
 };
 
+void process_incoming_migration(QEMUFile *f);
+
 int qemu_start_incoming_migration(const char *uri);
 
 int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data);