int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
Error **errp)
{
+ Error *local_err = NULL;
+
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);
- if (error_is_set(errp)) {
+ s->fd = inet_nonblocking_connect(host_port, tcp_wait_for_connect, s, &local_err);
+ if (local_err != NULL) {
migrate_fd_error(s);
+ error_propagate(errp, local_err);
return -1;
}
bool has_inc, bool inc, bool has_detach, bool detach,
Error **errp)
{
+ Error *local_err = NULL;
MigrationState *s = migrate_get_current();
MigrationParams params;
const char *p;
s = migrate_init(¶ms);
if (strstart(uri, "tcp:", &p)) {
- ret = tcp_start_outgoing_migration(s, p, errp);
+ ret = tcp_start_outgoing_migration(s, p, &local_err);
#if !defined(WIN32)
} else if (strstart(uri, "exec:", &p)) {
ret = exec_start_outgoing_migration(s, p);
return;
}
- if (ret < 0) {
- if (!error_is_set(errp)) {
- DPRINTF("migration failed: %s\n", strerror(-ret));
- /* FIXME: we should return meaningful errors */
- error_set(errp, QERR_UNDEFINED_ERROR);
+ if (ret < 0 || local_err) {
+ if (!local_err) {
+ error_set_errno(errp, -ret, QERR_UNDEFINED_ERROR);
+ } else {
+ error_propagate(errp, local_err);
}
return;
}