mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
migration: use QEMUFile for migration channel lifetime
As a start, use QEMUFile to store the destination and close it. qemu_get_fd gets a file descriptor that will be used by the write callbacks. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
3f2d38faab
commit
f8bbc12863
7 changed files with 21 additions and 89 deletions
|
@ -39,28 +39,17 @@ 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->migration_file = NULL;
|
||||
migrate_fd_error(s);
|
||||
} else {
|
||||
DPRINTF("migrate connect success\n");
|
||||
s->fd = fd;
|
||||
socket_set_block(s->fd);
|
||||
s->migration_file = qemu_fopen_socket(fd, "wb");
|
||||
migrate_fd_connect(s);
|
||||
}
|
||||
}
|
||||
|
@ -69,9 +58,7 @@ void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Erro
|
|||
{
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue