1
2
3
4
5
6
7
8
9
10
11
12
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"
23#include "yank_functions.h"
24
25
26
27
28
29
30
31
32
33void migration_channel_process_incoming(QIOChannel *ioc)
34{
35 MigrationState *s = migrate_get_current();
36 Error *local_err = NULL;
37
38 trace_migration_set_incoming_channel(
39 ioc, object_get_typename(OBJECT(ioc)));
40
41 if (s->parameters.tls_creds &&
42 *s->parameters.tls_creds &&
43 !object_dynamic_cast(OBJECT(ioc),
44 TYPE_QIO_CHANNEL_TLS)) {
45 migration_tls_channel_process_incoming(s, ioc, &local_err);
46 } else {
47 migration_ioc_register_yank(ioc);
48 migration_ioc_process_incoming(ioc, &local_err);
49 }
50
51 if (local_err) {
52 error_report_err(local_err);
53 }
54}
55
56
57
58
59
60
61
62
63
64
65void migration_channel_connect(MigrationState *s,
66 QIOChannel *ioc,
67 const char *hostname,
68 Error *error)
69{
70 trace_migration_set_outgoing_channel(
71 ioc, object_get_typename(OBJECT(ioc)), hostname, error);
72
73 if (!error) {
74 if (s->parameters.tls_creds &&
75 *s->parameters.tls_creds &&
76 !object_dynamic_cast(OBJECT(ioc),
77 TYPE_QIO_CHANNEL_TLS)) {
78 migration_tls_channel_connect(s, ioc, hostname, &error);
79
80 if (!error) {
81
82
83
84
85
86 return;
87 }
88 } else {
89 QEMUFile *f = qemu_fopen_channel_output(ioc);
90
91 migration_ioc_register_yank(ioc);
92
93 qemu_mutex_lock(&s->qemu_file_lock);
94 s->to_dst_file = f;
95 qemu_mutex_unlock(&s->qemu_file_lock);
96 }
97 }
98 migrate_fd_connect(s, error);
99 g_free(s->hostname);
100 error_free(error);
101}
102