summary refs log tree commit diff stats
path: root/migration-exec.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-11-02 13:06:28 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2012-11-02 13:06:28 -0500
commit2a0dfd004d9fae4adf2ccfcb2e3b1a76906b48a0 (patch)
tree98dbd8f0ee86efb371da9fa605d87f96b51d55e5 /migration-exec.c
parent1ef2a82e8f60779bebdae59f7dad8205cc93db30 (diff)
parent82a4da79fd6c108400637143f8439c2364bdb21e (diff)
downloadfocaccia-qemu-2a0dfd004d9fae4adf2ccfcb2e3b1a76906b48a0.tar.gz
focaccia-qemu-2a0dfd004d9fae4adf2ccfcb2e3b1a76906b48a0.zip
Merge remote-tracking branch 'bonzini/migr-coroutine' into staging
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

* bonzini/migr-coroutine:
  migration: move process_incoming_migration to a coroutine
  migration: handle EAGAIN while reading QEMUFile
  migration: move qemu_fclose to process_incoming_migration
  migration: close socket QEMUFile from socket_close
  migration: xxx_close will only be called once
  migration: use closesocket, not close
  migration: use migrate_fd_close in migrate_fd_cleanup
  migration: clean up server sockets and handlers before invoking process_incoming_migration
  migration: replace qemu_stdio_fd with qemu_get_fd
  migration: add qemu_get_fd
  migration: consolidate QEMUFile methods in a single QEMUFileOps struct
  migration: unify stdio-based QEMUFile operations
Diffstat (limited to 'migration-exec.c')
-rw-r--r--migration-exec.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/migration-exec.c b/migration-exec.c
index 519af57ac7..2b6fcb4262 100644
--- a/migration-exec.c
+++ b/migration-exec.c
@@ -48,14 +48,12 @@ static int exec_close(MigrationState *s)
 {
     int ret = 0;
     DPRINTF("exec_close\n");
-    if (s->opaque) {
-        ret = qemu_fclose(s->opaque);
-        s->opaque = NULL;
-        s->fd = -1;
-        if (ret >= 0 && !(WIFEXITED(ret) && WEXITSTATUS(ret) == 0)) {
-            /* close succeeded, but non-zero exit code: */
-            ret = -EIO; /* fake errno value */
-        }
+    ret = qemu_fclose(s->opaque);
+    s->opaque = NULL;
+    s->fd = -1;
+    if (ret >= 0 && !(WIFEXITED(ret) && WEXITSTATUS(ret) == 0)) {
+        /* close succeeded, but non-zero exit code: */
+        ret = -EIO; /* fake errno value */
     }
     return ret;
 }
@@ -87,9 +85,8 @@ static void exec_accept_incoming_migration(void *opaque)
 {
     QEMUFile *f = opaque;
 
+    qemu_set_fd_handler2(qemu_get_fd(f), NULL, NULL, NULL, NULL);
     process_incoming_migration(f);
-    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
-    qemu_fclose(f);
 }
 
 void exec_start_incoming_migration(const char *command, Error **errp)
@@ -103,6 +100,6 @@ void exec_start_incoming_migration(const char *command, Error **errp)
         return;
     }
 
-    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL,
+    qemu_set_fd_handler2(qemu_get_fd(f), NULL,
 			 exec_accept_incoming_migration, NULL, f);
 }