diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2013-03-11 08:30:34 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-03-11 08:30:34 -0500 |
commit | fe3cc14fd83e0c8f376d849ccd0fc3433388442d (patch) | |
tree | 8a354b91eab8a1ac16b4186f9fbb2a75772b75fe /migration-tcp.c | |
parent | bba18e23f7266d63734fd31045fec7794cc34a38 (diff) | |
parent | ee0b44aa9d9450e873a761ca2030b2fa3ec52eb0 (diff) |
Merge remote-tracking branch 'quintela/migration.next' into staging
# By Paolo Bonzini (40) and others
# Via Juan Quintela
* quintela/migration.next: (46 commits)
page_cache: dup memory on insert
page_cache: fix memory leak
Fix cache_resize to keep old entry age
Fix page_cache leak in cache_resize
migration: inline migrate_fd_close
migration: eliminate s->migration_file
migration: move contents of migration_close to migrate_fd_cleanup
migration: move rate limiting to QEMUFile
migration: small changes around rate-limiting
migration: use qemu_ftell to compute bandwidth
migration: use QEMUFile for writing outgoing migration data
migration: use QEMUFile for migration channel lifetime
qemu-file: simplify and export qemu_ftell
qemu-file: add writable socket QEMUFile
qemu-file: check exit status when closing a pipe QEMUFile
qemu-file: fsync a writable stdio QEMUFile
migration: merge qemu_popen_cmd with qemu_popen
migration: use qemu_file_rate_limit consistently
migration: remove useless qemu_file_get_error check
migration: detect error before sleeping
...
Diffstat (limited to 'migration-tcp.c')
-rw-r--r-- | migration-tcp.c | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/migration-tcp.c b/migration-tcp.c index e78a296137..b20ee58f55 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -29,49 +29,24 @@ do { } while (0) #endif -static int socket_errno(MigrationState *s) -{ - return socket_error(); -} - -static int socket_write(MigrationState *s, const void * buf, size_t size) -{ - return send(s->fd, buf, size, 0); -} - -static int tcp_close(MigrationState *s) -{ - int r = 0; - DPRINTF("tcp_close\n"); - if (closesocket(s->fd) < 0) { - r = -socket_error(); - } - return r; -} - static void tcp_wait_for_connect(int fd, void *opaque) { MigrationState *s = opaque; if (fd < 0) { DPRINTF("migrate connect error\n"); - s->fd = -1; + s->file = NULL; migrate_fd_error(s); } else { DPRINTF("migrate connect success\n"); - s->fd = fd; - socket_set_block(s->fd); + s->file = qemu_fopen_socket(fd, "wb"); migrate_fd_connect(s); } } void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp) { - s->get_error = socket_errno; - s->write = socket_write; - s->close = tcp_close; - - s->fd = inet_nonblocking_connect(host_port, tcp_wait_for_connect, s, errp); + inet_nonblocking_connect(host_port, tcp_wait_for_connect, s, errp); } static void tcp_accept_incoming_migration(void *opaque) @@ -95,7 +70,7 @@ static void tcp_accept_incoming_migration(void *opaque) goto out; } - f = qemu_fopen_socket(c); + f = qemu_fopen_socket(c, "rb"); if (f == NULL) { fprintf(stderr, "could not qemu_fopen socket\n"); goto out; |