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
22
23
24
25
26
27
28
29
30void migration_channel_process_incoming(QIOChannel *ioc)
31{
32 MigrationState *s = migrate_get_current();
33
34 trace_migration_set_incoming_channel(
35 ioc, object_get_typename(OBJECT(ioc)));
36
37 if (s->parameters.tls_creds &&
38 *s->parameters.tls_creds &&
39 !object_dynamic_cast(OBJECT(ioc),
40 TYPE_QIO_CHANNEL_TLS)) {
41 Error *local_err = NULL;
42 migration_tls_channel_process_incoming(s, ioc, &local_err);
43 if (local_err) {
44 error_report_err(local_err);
45 }
46 } else {
47 migration_ioc_process_incoming(ioc);
48 }
49}
50
51
52
53
54
55
56
57
58
59void migration_channel_connect(MigrationState *s,
60 QIOChannel *ioc,
61 const char *hostname)
62{
63 trace_migration_set_outgoing_channel(
64 ioc, object_get_typename(OBJECT(ioc)), hostname);
65
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);
78
79 s->to_dst_file = f;
80
81 migrate_fd_connect(s);
82 }
83}
84