1 /* 2 * QEMU live migration channel operations 3 * 4 * Copyright Red Hat, Inc. 2016 5 * 6 * Authors: 7 * Daniel P. Berrange <berrange@redhat.com> 8 * 9 * Contributions after 2012-01-13 are licensed under the terms of the 10 * GNU GPL, version 2 or (at your option) any later version. 11 */ 12 13 #include "qemu/osdep.h" 14 #include "channel.h" 15 #include "migration/migration.h" 16 #include "qemu-file-channel.h" 17 #include "trace.h" 18 #include "qapi/error.h" 19 #include "io/channel-tls.h" 20 21 void migration_channel_process_incoming(MigrationState *s, 22 QIOChannel *ioc) 23 { 24 trace_migration_set_incoming_channel( 25 ioc, object_get_typename(OBJECT(ioc))); 26 27 if (s->parameters.tls_creds && 28 *s->parameters.tls_creds && 29 !object_dynamic_cast(OBJECT(ioc), 30 TYPE_QIO_CHANNEL_TLS)) { 31 Error *local_err = NULL; 32 migration_tls_channel_process_incoming(s, ioc, &local_err); 33 if (local_err) { 34 error_report_err(local_err); 35 } 36 } else { 37 QEMUFile *f = qemu_fopen_channel_input(ioc); 38 migration_fd_process_incoming(f); 39 } 40 } 41 42 43 void migration_channel_connect(MigrationState *s, 44 QIOChannel *ioc, 45 const char *hostname) 46 { 47 trace_migration_set_outgoing_channel( 48 ioc, object_get_typename(OBJECT(ioc)), hostname); 49 50 if (s->parameters.tls_creds && 51 *s->parameters.tls_creds && 52 !object_dynamic_cast(OBJECT(ioc), 53 TYPE_QIO_CHANNEL_TLS)) { 54 Error *local_err = NULL; 55 migration_tls_channel_connect(s, ioc, hostname, &local_err); 56 if (local_err) { 57 migrate_fd_error(s, local_err); 58 error_free(local_err); 59 } 60 } else { 61 QEMUFile *f = qemu_fopen_channel_output(ioc); 62 63 s->to_dst_file = f; 64 65 migrate_fd_connect(s); 66 } 67 } 68