]>
Commit | Line | Data |
---|---|---|
dd4339c5 JQ |
1 | /* |
2 | * QEMU live migration channel operations | |
3 | * | |
4 | * Copyright Red Hat, Inc. 2016 | |
5 | * | |
6 | * Authors: | |
7 | * Daniel P. Berrange <[email protected]> | |
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" | |
41d64227 | 15 | #include "tls.h" |
6666c96a | 16 | #include "migration.h" |
40014d81 | 17 | #include "qemu-file-channel.h" |
dd4339c5 JQ |
18 | #include "trace.h" |
19 | #include "qapi/error.h" | |
20 | #include "io/channel-tls.h" | |
21 | ||
8e1a1931 JQ |
22 | /** |
23 | * @migration_channel_process_incoming - Create new incoming migration channel | |
24 | * | |
25 | * Notice that TLS is special. For it we listen in a listener socket, | |
26 | * and then create a new client socket from the TLS library. | |
27 | * | |
28 | * @ioc: Channel to which we are connecting | |
29 | */ | |
54314711 | 30 | void migration_channel_process_incoming(QIOChannel *ioc) |
dd4339c5 | 31 | { |
54314711 | 32 | MigrationState *s = migrate_get_current(); |
49ed0d24 | 33 | Error *local_err = NULL; |
54314711 | 34 | |
dd4339c5 JQ |
35 | trace_migration_set_incoming_channel( |
36 | ioc, object_get_typename(OBJECT(ioc))); | |
37 | ||
38 | if (s->parameters.tls_creds && | |
39 | *s->parameters.tls_creds && | |
40 | !object_dynamic_cast(OBJECT(ioc), | |
41 | TYPE_QIO_CHANNEL_TLS)) { | |
dd4339c5 | 42 | migration_tls_channel_process_incoming(s, ioc, &local_err); |
dd4339c5 | 43 | } else { |
49ed0d24 FL |
44 | migration_ioc_process_incoming(ioc, &local_err); |
45 | } | |
46 | ||
47 | if (local_err) { | |
48 | error_report_err(local_err); | |
dd4339c5 JQ |
49 | } |
50 | } | |
51 | ||
52 | ||
8e1a1931 JQ |
53 | /** |
54 | * @migration_channel_connect - Create new outgoing migration channel | |
55 | * | |
56 | * @s: Current migration state | |
57 | * @ioc: Channel to which we are connecting | |
58 | * @hostname: Where we want to connect | |
688a3dcb | 59 | * @error: Error indicating failure to connect, free'd here |
8e1a1931 | 60 | */ |
dd4339c5 JQ |
61 | void migration_channel_connect(MigrationState *s, |
62 | QIOChannel *ioc, | |
688a3dcb DDAG |
63 | const char *hostname, |
64 | Error *error) | |
dd4339c5 JQ |
65 | { |
66 | trace_migration_set_outgoing_channel( | |
688a3dcb | 67 | ioc, object_get_typename(OBJECT(ioc)), hostname, error); |
dd4339c5 | 68 | |
688a3dcb DDAG |
69 | if (!error) { |
70 | if (s->parameters.tls_creds && | |
71 | *s->parameters.tls_creds && | |
72 | !object_dynamic_cast(OBJECT(ioc), | |
73 | TYPE_QIO_CHANNEL_TLS)) { | |
74 | migration_tls_channel_connect(s, ioc, hostname, &error); | |
8b7bf2ba DDAG |
75 | |
76 | if (!error) { | |
77 | /* tls_channel_connect will call back to this | |
78 | * function after the TLS handshake, | |
79 | * so we mustn't call migrate_fd_connect until then | |
80 | */ | |
81 | ||
82 | return; | |
83 | } | |
688a3dcb DDAG |
84 | } else { |
85 | QEMUFile *f = qemu_fopen_channel_output(ioc); | |
dd4339c5 | 86 | |
62df066f | 87 | qemu_mutex_lock(&s->qemu_file_lock); |
688a3dcb | 88 | s->to_dst_file = f; |
62df066f | 89 | qemu_mutex_unlock(&s->qemu_file_lock); |
688a3dcb | 90 | } |
dd4339c5 | 91 | } |
688a3dcb DDAG |
92 | migrate_fd_connect(s, error); |
93 | error_free(error); | |
dd4339c5 | 94 | } |