Merge branch 'master' of /home/nchip/public_html/qemu into garage-push
[qemu] / migration-tcp.c
index 100644b..1f4358e 100644 (file)
@@ -16,7 +16,6 @@
 #include "migration.h"
 #include "qemu-char.h"
 #include "sysemu.h"
-#include "console.h"
 #include "buffered_file.h"
 #include "block.h"
 
@@ -32,7 +31,7 @@
 
 static int socket_errno(FdMigrationState *s)
 {
-    return (s->get_error(s));
+    return socket_error();
 }
 
 static int socket_write(FdMigrationState *s, const void * buf, size_t size)
@@ -59,7 +58,7 @@ static void tcp_wait_for_connect(void *opaque)
 
     dprintf("connect completed\n");
     do {
-        ret = getsockopt(s->fd, SOL_SOCKET, SO_ERROR, &val, &valsize);
+        ret = getsockopt(s->fd, SOL_SOCKET, SO_ERROR, (void *) &val, &valsize);
     } while (ret == -1 && (s->get_error(s)) == EINTR);
 
     if (ret < 0) {
@@ -79,7 +78,7 @@ static void tcp_wait_for_connect(void *opaque)
 
 MigrationState *tcp_start_outgoing_migration(const char *host_port,
                                              int64_t bandwidth_limit,
-                                             int async)
+                                             int detach)
 {
     struct sockaddr_in addr;
     FdMigrationState *s;
@@ -89,8 +88,6 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,
         return NULL;
 
     s = qemu_mallocz(sizeof(*s));
-    if (s == NULL)
-        return NULL;
 
     s->get_error = socket_errno;
     s->write = socket_write;
@@ -100,7 +97,7 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,
     s->mig_state.release = migrate_fd_release;
 
     s->state = MIG_STATE_ACTIVE;
-    s->detach = !async;
+    s->mon_resume = NULL;
     s->bandwidth_limit = bandwidth_limit;
     s->fd = socket(PF_INET, SOCK_STREAM, 0);
     if (s->fd == -1) {
@@ -110,11 +107,8 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,
 
     socket_set_nonblock(s->fd);
 
-    if (s->detach == 1) {
-        dprintf("detaching from monitor\n");
-        monitor_suspend();
-        s->detach = 2;
-    }
+    if (!detach)
+        migrate_fd_monitor_suspend(s);
 
     do {
         ret = connect(s->fd, (struct sockaddr *)&addr, sizeof(addr));