Diff for /qemu/migration-tcp.c between versions 1.1.1.3 and 1.1.1.4

version 1.1.1.3, 2018/04/24 17:33:40 version 1.1.1.4, 2018/04/24 18:23:02
Line 22 Line 22
 //#define DEBUG_MIGRATION_TCP  //#define DEBUG_MIGRATION_TCP
   
 #ifdef DEBUG_MIGRATION_TCP  #ifdef DEBUG_MIGRATION_TCP
 #define dprintf(fmt, ...) \  #define DPRINTF(fmt, ...) \
     do { printf("migration-tcp: " fmt, ## __VA_ARGS__); } while (0)      do { printf("migration-tcp: " fmt, ## __VA_ARGS__); } while (0)
 #else  #else
 #define dprintf(fmt, ...) \  #define DPRINTF(fmt, ...) \
     do { } while (0)      do { } while (0)
 #endif  #endif
   
Line 41  static int socket_write(FdMigrationState Line 41  static int socket_write(FdMigrationState
   
 static int tcp_close(FdMigrationState *s)  static int tcp_close(FdMigrationState *s)
 {  {
     dprintf("tcp_close\n");      DPRINTF("tcp_close\n");
     if (s->fd != -1) {      if (s->fd != -1) {
         close(s->fd);          close(s->fd);
         s->fd = -1;          s->fd = -1;
Line 56  static void tcp_wait_for_connect(void *o Line 56  static void tcp_wait_for_connect(void *o
     int val, ret;      int val, ret;
     socklen_t valsize = sizeof(val);      socklen_t valsize = sizeof(val);
   
     dprintf("connect completed\n");      DPRINTF("connect completed\n");
     do {      do {
         ret = getsockopt(s->fd, SOL_SOCKET, SO_ERROR, (void *) &val, &valsize);          ret = getsockopt(s->fd, SOL_SOCKET, SO_ERROR, (void *) &val, &valsize);
     } while (ret == -1 && (s->get_error(s)) == EINTR);      } while (ret == -1 && (s->get_error(s)) == EINTR);
Line 71  static void tcp_wait_for_connect(void *o Line 71  static void tcp_wait_for_connect(void *o
     if (val == 0)      if (val == 0)
         migrate_fd_connect(s);          migrate_fd_connect(s);
     else {      else {
         dprintf("error connecting %d\n", val);          DPRINTF("error connecting %d\n", val);
         migrate_fd_error(s);          migrate_fd_error(s);
     }      }
 }  }
Line 127  MigrationState *tcp_start_outgoing_migra Line 127  MigrationState *tcp_start_outgoing_migra
     } while (ret == -EINTR);      } while (ret == -EINTR);
   
     if (ret < 0 && ret != -EINPROGRESS && ret != -EWOULDBLOCK) {      if (ret < 0 && ret != -EINPROGRESS && ret != -EWOULDBLOCK) {
         dprintf("connect failed\n");          DPRINTF("connect failed\n");
         close(s->fd);          migrate_fd_error(s);
         qemu_free(s);  
         return NULL;  
     } else if (ret >= 0)      } else if (ret >= 0)
         migrate_fd_connect(s);          migrate_fd_connect(s);
   
Line 143  static void tcp_accept_incoming_migratio Line 141  static void tcp_accept_incoming_migratio
     socklen_t addrlen = sizeof(addr);      socklen_t addrlen = sizeof(addr);
     int s = (unsigned long)opaque;      int s = (unsigned long)opaque;
     QEMUFile *f;      QEMUFile *f;
     int c, ret;      int c;
   
     do {      do {
         c = qemu_accept(s, (struct sockaddr *)&addr, &addrlen);          c = qemu_accept(s, (struct sockaddr *)&addr, &addrlen);
     } while (c == -1 && socket_error() == EINTR);      } while (c == -1 && socket_error() == EINTR);
   
     dprintf("accepted migration\n");      DPRINTF("accepted migration\n");
   
     if (c == -1) {      if (c == -1) {
         fprintf(stderr, "could not accept migration connection\n");          fprintf(stderr, "could not accept migration connection\n");
         return;          goto out2;
     }      }
   
     f = qemu_fopen_socket(c);      f = qemu_fopen_socket(c);
Line 162  static void tcp_accept_incoming_migratio Line 160  static void tcp_accept_incoming_migratio
         goto out;          goto out;
     }      }
   
     ret = qemu_loadvm_state(f);      process_incoming_migration(f);
     if (ret < 0) {  
         fprintf(stderr, "load of migration failed\n");  
         goto out_fopen;  
     }  
     qemu_announce_self();  
     dprintf("successfully loaded vm state\n");  
   
     /* we've successfully migrated, close the server socket */  
     qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);  
     close(s);  
     if (autostart)  
         vm_start();  
   
 out_fopen:  
     qemu_fclose(f);      qemu_fclose(f);
 out:  out:
     close(c);      close(c);
   out2:
       qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
       close(s);
 }  }
   
 int tcp_start_incoming_migration(const char *host_port)  int tcp_start_incoming_migration(const char *host_port)

Removed from v.1.1.1.3  
changed lines
  Added in v.1.1.1.4


unix.superglobalmegacorp.com