]> Git Repo - qemu.git/blame - migration/channel.c
migration: Route errors down through migration_channel_connect
[qemu.git] / migration / channel.c
CommitLineData
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 30void migration_channel_process_incoming(QIOChannel *ioc)
dd4339c5 31{
54314711
JQ
32 MigrationState *s = migrate_get_current();
33
dd4339c5
JQ
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 {
4f0fae7f 47 migration_ioc_process_incoming(ioc);
dd4339c5
JQ
48 }
49}
50
51
8e1a1931
JQ
52/**
53 * @migration_channel_connect - Create new outgoing migration channel
54 *
55 * @s: Current migration state
56 * @ioc: Channel to which we are connecting
57 * @hostname: Where we want to connect
688a3dcb 58 * @error: Error indicating failure to connect, free'd here
8e1a1931 59 */
dd4339c5
JQ
60void migration_channel_connect(MigrationState *s,
61 QIOChannel *ioc,
688a3dcb
DDAG
62 const char *hostname,
63 Error *error)
dd4339c5
JQ
64{
65 trace_migration_set_outgoing_channel(
688a3dcb 66 ioc, object_get_typename(OBJECT(ioc)), hostname, error);
dd4339c5 67
688a3dcb
DDAG
68 if (!error) {
69 if (s->parameters.tls_creds &&
70 *s->parameters.tls_creds &&
71 !object_dynamic_cast(OBJECT(ioc),
72 TYPE_QIO_CHANNEL_TLS)) {
73 migration_tls_channel_connect(s, ioc, hostname, &error);
74 } else {
75 QEMUFile *f = qemu_fopen_channel_output(ioc);
dd4339c5 76
688a3dcb 77 s->to_dst_file = f;
dd4339c5 78
688a3dcb 79 }
dd4339c5 80 }
688a3dcb
DDAG
81 migrate_fd_connect(s, error);
82 error_free(error);
dd4339c5 83}
This page took 0.050394 seconds and 4 git commands to generate.