summaryrefslogtreecommitdiff
path: root/migration-fd.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-10-02 10:02:46 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2012-10-23 13:54:56 +0200
commitf37afb5ab1921f42043b5527a517eef95c36acf8 (patch)
tree19e1c5119272e95f86a51180997532ec37ba3ab8 /migration-fd.c
parente08c95ce8d66276198704f21ed9df6d99b3477e0 (diff)
downloadqemu-f37afb5ab1921f42043b5527a517eef95c36acf8.tar.gz
migration (outgoing): add error propagation for all protocols
Error propagation is already there for socket backends. Add it to other protocols, simplifying code that tests for errors that will never happen. With all protocols understanding Error, the code can be simplified further by removing the return value. Unfortunately, the quality of error messages varies depending on where the error is detected, because no Error is passed to the NonBlockingConnectHandler. Thus, the exact error message still cannot be sent to the user if the OS reports it asynchronously via SO_ERROR. If NonBlockingConnectHandler received an Error**, we could for example report the error class and/or message via a new field of the query-migration command even if it is reported asynchronously. Before: (qemu) migrate fd:ffff migrate: An undefined error has occurred (qemu) info migrate (qemu) After: (qemu) migrate fd:ffff migrate: File descriptor named 'ffff' has not been found (qemu) info migrate capabilities: xbzrle: off Migration status: failed total time: 0 milliseconds Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'migration-fd.c')
-rw-r--r--migration-fd.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/migration-fd.c b/migration-fd.c
index 73351678e0..a7c800a852 100644
--- a/migration-fd.c
+++ b/migration-fd.c
@@ -73,30 +73,19 @@ static int fd_close(MigrationState *s)
return 0;
}
-int fd_start_outgoing_migration(MigrationState *s, const char *fdname)
+void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp)
{
- s->fd = monitor_get_fd(cur_mon, fdname, NULL);
+ s->fd = monitor_get_fd(cur_mon, fdname, errp);
if (s->fd == -1) {
- DPRINTF("fd_migration: invalid file descriptor identifier\n");
- goto err_after_get_fd;
- }
-
- if (fcntl(s->fd, F_SETFL, O_NONBLOCK) == -1) {
- DPRINTF("Unable to set nonblocking mode on file descriptor\n");
- goto err_after_open;
+ return;
}
+ fcntl(s->fd, F_SETFL, O_NONBLOCK);
s->get_error = fd_errno;
s->write = fd_write;
s->close = fd_close;
migrate_fd_connect(s);
- return 0;
-
-err_after_open:
- close(s->fd);
-err_after_get_fd:
- return -1;
}
static void fd_accept_incoming_migration(void *opaque)