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

version 1.1.1.3, 2018/04/24 17:35:10 version 1.1.1.4, 2018/04/24 18:24:51
Line 20 Line 20
 #include "sysemu.h"  #include "sysemu.h"
 #include "buffered_file.h"  #include "buffered_file.h"
 #include "block.h"  #include "block.h"
   #include <sys/types.h>
   #include <sys/wait.h>
   
 //#define DEBUG_MIGRATION_EXEC  //#define DEBUG_MIGRATION_EXEC
   
 #ifdef DEBUG_MIGRATION_EXEC  #ifdef DEBUG_MIGRATION_EXEC
 #define dprintf(fmt, ...) \  #define DPRINTF(fmt, ...) \
     do { printf("migration-exec: " fmt, ## __VA_ARGS__); } while (0)      do { printf("migration-exec: " fmt, ## __VA_ARGS__); } while (0)
 #else  #else
 #define dprintf(fmt, ...) \  #define DPRINTF(fmt, ...) \
     do { } while (0)      do { } while (0)
 #endif  #endif
   
Line 43  static int file_write(FdMigrationState * Line 45  static int file_write(FdMigrationState *
   
 static int exec_close(FdMigrationState *s)  static int exec_close(FdMigrationState *s)
 {  {
     dprintf("exec_close\n");      int ret = 0;
       DPRINTF("exec_close\n");
     if (s->opaque) {      if (s->opaque) {
         qemu_fclose(s->opaque);          ret = qemu_fclose(s->opaque);
         s->opaque = NULL;          s->opaque = NULL;
         s->fd = -1;          s->fd = -1;
           if (ret != -1 &&
               WIFEXITED(ret)
               && WEXITSTATUS(ret) == 0) {
               ret = 0;
           } else {
               ret = -1;
           }
     }      }
     return 0;      return ret;
 }  }
   
 MigrationState *exec_start_outgoing_migration(Monitor *mon,  MigrationState *exec_start_outgoing_migration(Monitor *mon,
Line 66  MigrationState *exec_start_outgoing_migr Line 76  MigrationState *exec_start_outgoing_migr
   
     f = popen(command, "w");      f = popen(command, "w");
     if (f == NULL) {      if (f == NULL) {
         dprintf("Unable to popen exec target\n");          DPRINTF("Unable to popen exec target\n");
         goto err_after_alloc;          goto err_after_alloc;
     }      }
   
     s->fd = fileno(f);      s->fd = fileno(f);
     if (s->fd == -1) {      if (s->fd == -1) {
         dprintf("Unable to retrieve file descriptor for popen'd handle\n");          DPRINTF("Unable to retrieve file descriptor for popen'd handle\n");
         goto err_after_open;          goto err_after_open;
     }      }
   
Line 111  err_after_alloc: Line 121  err_after_alloc:
 static void exec_accept_incoming_migration(void *opaque)  static void exec_accept_incoming_migration(void *opaque)
 {  {
     QEMUFile *f = opaque;      QEMUFile *f = opaque;
     int ret;  
   
     ret = qemu_loadvm_state(f);      process_incoming_migration(f);
     if (ret < 0) {  
         fprintf(stderr, "load of migration failed\n");  
         goto err;  
     }  
     qemu_announce_self();  
     dprintf("successfully loaded vm state\n");  
     /* we've successfully migrated, close the fd */  
     qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);      qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
     if (autostart)  
         vm_start();  
   
 err:  
     qemu_fclose(f);      qemu_fclose(f);
 }  }
   
Line 133  int exec_start_incoming_migration(const  Line 131  int exec_start_incoming_migration(const 
 {  {
     QEMUFile *f;      QEMUFile *f;
   
     dprintf("Attempting to start an incoming migration\n");      DPRINTF("Attempting to start an incoming migration\n");
     f = qemu_popen_cmd(command, "r");      f = qemu_popen_cmd(command, "r");
     if(f == NULL) {      if(f == NULL) {
         dprintf("Unable to apply qemu wrapper to popen file\n");          DPRINTF("Unable to apply qemu wrapper to popen file\n");
         return -errno;          return -errno;
     }      }
   
     qemu_set_fd_handler2(qemu_stdio_fd(f), NULL,      qemu_set_fd_handler2(qemu_stdio_fd(f), NULL,
                          exec_accept_incoming_migration, NULL,                           exec_accept_incoming_migration, NULL, f);
                          (void *)(unsigned long)f);  
   
     return 0;      return 0;
 }  }

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


unix.superglobalmegacorp.com