qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

migration: Route errors down through migration_channel_connect

Route async errors (especially from sockets) down through
migration_channel_connect and on to migrate_fd_connect where they
can be cleaned up.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

+23 -25
+16 -16
migration/channel.c
··· 55 55 * @s: Current migration state 56 56 * @ioc: Channel to which we are connecting 57 57 * @hostname: Where we want to connect 58 + * @error: Error indicating failure to connect, free'd here 58 59 */ 59 60 void migration_channel_connect(MigrationState *s, 60 61 QIOChannel *ioc, 61 - const char *hostname) 62 + const char *hostname, 63 + Error *error) 62 64 { 63 65 trace_migration_set_outgoing_channel( 64 - ioc, object_get_typename(OBJECT(ioc)), hostname); 66 + ioc, object_get_typename(OBJECT(ioc)), hostname, error); 65 67 66 - if (s->parameters.tls_creds && 67 - *s->parameters.tls_creds && 68 - !object_dynamic_cast(OBJECT(ioc), 69 - TYPE_QIO_CHANNEL_TLS)) { 70 - Error *local_err = NULL; 71 - migration_tls_channel_connect(s, ioc, hostname, &local_err); 72 - if (local_err) { 73 - migrate_fd_error(s, local_err); 74 - error_free(local_err); 75 - } 76 - } else { 77 - QEMUFile *f = qemu_fopen_channel_output(ioc); 68 + if (!error) { 69 + if (s->parameters.tls_creds && 70 + *s->parameters.tls_creds && 71 + !object_dynamic_cast(OBJECT(ioc), 72 + TYPE_QIO_CHANNEL_TLS)) { 73 + migration_tls_channel_connect(s, ioc, hostname, &error); 74 + } else { 75 + QEMUFile *f = qemu_fopen_channel_output(ioc); 78 76 79 - s->to_dst_file = f; 77 + s->to_dst_file = f; 80 78 81 - migrate_fd_connect(s, NULL); 79 + } 82 80 } 81 + migrate_fd_connect(s, error); 82 + error_free(error); 83 83 }
+2 -1
migration/channel.h
··· 22 22 23 23 void migration_channel_connect(MigrationState *s, 24 24 QIOChannel *ioc, 25 - const char *hostname); 25 + const char *hostname, 26 + Error *error_in); 26 27 #endif
+1 -1
migration/exec.c
··· 39 39 } 40 40 41 41 qio_channel_set_name(ioc, "migration-exec-outgoing"); 42 - migration_channel_connect(s, ioc, NULL); 42 + migration_channel_connect(s, ioc, NULL, NULL); 43 43 object_unref(OBJECT(ioc)); 44 44 } 45 45
+1 -1
migration/fd.c
··· 39 39 } 40 40 41 41 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-outgoing"); 42 - migration_channel_connect(s, ioc, NULL); 42 + migration_channel_connect(s, ioc, NULL, NULL); 43 43 object_unref(OBJECT(ioc)); 44 44 } 45 45
+1 -3
migration/socket.c
··· 79 79 80 80 if (qio_task_propagate_error(task, &err)) { 81 81 trace_migration_socket_outgoing_error(error_get_pretty(err)); 82 - migrate_fd_error(data->s, err); 83 - error_free(err); 84 82 } else { 85 83 trace_migration_socket_outgoing_connected(data->hostname); 86 - migration_channel_connect(data->s, sioc, data->hostname); 87 84 } 85 + migration_channel_connect(data->s, sioc, data->hostname, err); 88 86 object_unref(OBJECT(sioc)); 89 87 } 90 88
+1 -2
migration/tls.c
··· 118 118 119 119 if (qio_task_propagate_error(task, &err)) { 120 120 trace_migration_tls_outgoing_handshake_error(error_get_pretty(err)); 121 - migrate_fd_error(s, err); 122 121 } else { 123 122 trace_migration_tls_outgoing_handshake_complete(); 124 - migration_channel_connect(s, ioc, NULL); 125 123 } 124 + migration_channel_connect(s, ioc, NULL, err); 126 125 object_unref(OBJECT(ioc)); 127 126 } 128 127
+1 -1
migration/trace-events
··· 114 114 process_incoming_migration_co_end(int ret, int ps) "ret=%d postcopy-state=%d" 115 115 process_incoming_migration_co_postcopy_end_main(void) "" 116 116 migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=%p ioctype=%s" 117 - migration_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname) "ioc=%p ioctype=%s hostname=%s" 117 + migration_set_outgoing_channel(void *ioc, const char *ioctype, const char *hostname, void *err) "ioc=%p ioctype=%s hostname=%s err=%p" 118 118 119 119 # migration/rdma.c 120 120 qemu_rdma_accept_incoming_migration(void) ""