]>
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" | |
15 | #include "migration/migration.h" | |
16 | #include "trace.h" | |
17 | #include "qapi/error.h" | |
18 | #include "io/channel-tls.h" | |
19 | ||
20 | void migration_channel_process_incoming(MigrationState *s, | |
21 | QIOChannel *ioc) | |
22 | { | |
23 | trace_migration_set_incoming_channel( | |
24 | ioc, object_get_typename(OBJECT(ioc))); | |
25 | ||
26 | if (s->parameters.tls_creds && | |
27 | *s->parameters.tls_creds && | |
28 | !object_dynamic_cast(OBJECT(ioc), | |
29 | TYPE_QIO_CHANNEL_TLS)) { | |
30 | Error *local_err = NULL; | |
31 | migration_tls_channel_process_incoming(s, ioc, &local_err); | |
32 | if (local_err) { | |
33 | error_report_err(local_err); | |
34 | } | |
35 | } else { | |
36 | QEMUFile *f = qemu_fopen_channel_input(ioc); | |
37 | migration_fd_process_incoming(f); | |
38 | } | |
39 | } | |
40 | ||
41 | ||
42 | void migration_channel_connect(MigrationState *s, | |
43 | QIOChannel *ioc, | |
44 | const char *hostname) | |
45 | { | |
46 | trace_migration_set_outgoing_channel( | |
47 | ioc, object_get_typename(OBJECT(ioc)), hostname); | |
48 | ||
49 | if (s->parameters.tls_creds && | |
50 | *s->parameters.tls_creds && | |
51 | !object_dynamic_cast(OBJECT(ioc), | |
52 | TYPE_QIO_CHANNEL_TLS)) { | |
53 | Error *local_err = NULL; | |
54 | migration_tls_channel_connect(s, ioc, hostname, &local_err); | |
55 | if (local_err) { | |
56 | migrate_fd_error(s, local_err); | |
57 | error_free(local_err); | |
58 | } | |
59 | } else { | |
60 | QEMUFile *f = qemu_fopen_channel_output(ioc); | |
61 | ||
62 | s->to_dst_file = f; | |
63 | ||
64 | migrate_fd_connect(s); | |
65 | } | |
66 | } |