iotests/129: Do not check @busy
[qemu/ar7.git] / migration / channel.c
blob35fe234e9c2efa675eb6994b5992fccd45264ce8
1 /*
2 * QEMU live migration channel operations
4 * Copyright Red Hat, Inc. 2016
6 * Authors:
7 * Daniel P. Berrange <berrange@redhat.com>
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.
13 #include "qemu/osdep.h"
14 #include "channel.h"
15 #include "tls.h"
16 #include "migration.h"
17 #include "qemu-file-channel.h"
18 #include "trace.h"
19 #include "qapi/error.h"
20 #include "io/channel-tls.h"
21 #include "io/channel-socket.h"
22 #include "qemu/yank.h"
24 /**
25 * @migration_channel_process_incoming - Create new incoming migration channel
27 * Notice that TLS is special. For it we listen in a listener socket,
28 * and then create a new client socket from the TLS library.
30 * @ioc: Channel to which we are connecting
32 void migration_channel_process_incoming(QIOChannel *ioc)
34 MigrationState *s = migrate_get_current();
35 Error *local_err = NULL;
37 trace_migration_set_incoming_channel(
38 ioc, object_get_typename(OBJECT(ioc)));
40 if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET)) {
41 yank_register_function(MIGRATION_YANK_INSTANCE, yank_generic_iochannel,
42 QIO_CHANNEL(ioc));
45 if (s->parameters.tls_creds &&
46 *s->parameters.tls_creds &&
47 !object_dynamic_cast(OBJECT(ioc),
48 TYPE_QIO_CHANNEL_TLS)) {
49 migration_tls_channel_process_incoming(s, ioc, &local_err);
50 } else {
51 migration_ioc_process_incoming(ioc, &local_err);
54 if (local_err) {
55 error_report_err(local_err);
60 /**
61 * @migration_channel_connect - Create new outgoing migration channel
63 * @s: Current migration state
64 * @ioc: Channel to which we are connecting
65 * @hostname: Where we want to connect
66 * @error: Error indicating failure to connect, free'd here
68 void migration_channel_connect(MigrationState *s,
69 QIOChannel *ioc,
70 const char *hostname,
71 Error *error)
73 trace_migration_set_outgoing_channel(
74 ioc, object_get_typename(OBJECT(ioc)), hostname, error);
76 if (!error) {
77 if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET)) {
78 yank_register_function(MIGRATION_YANK_INSTANCE,
79 yank_generic_iochannel,
80 QIO_CHANNEL(ioc));
83 if (s->parameters.tls_creds &&
84 *s->parameters.tls_creds &&
85 !object_dynamic_cast(OBJECT(ioc),
86 TYPE_QIO_CHANNEL_TLS)) {
87 migration_tls_channel_connect(s, ioc, hostname, &error);
89 if (!error) {
90 /* tls_channel_connect will call back to this
91 * function after the TLS handshake,
92 * so we mustn't call migrate_fd_connect until then
95 return;
97 } else {
98 QEMUFile *f = qemu_fopen_channel_output(ioc);
100 qemu_mutex_lock(&s->qemu_file_lock);
101 s->to_dst_file = f;
102 qemu_mutex_unlock(&s->qemu_file_lock);
105 migrate_fd_connect(s, error);
106 g_free(s->hostname);
107 error_free(error);