]> git.proxmox.com Git - mirror_qemu.git/blame - migration/fd.c
Include qapi/error.h exactly where needed
[mirror_qemu.git] / migration / fd.c
CommitLineData
5ac1fad3
PB
1/*
2 * QEMU live migration via generic fd
3 *
64802ee5 4 * Copyright Red Hat, Inc. 2009-2016
5ac1fad3
PB
5 *
6 * Authors:
7 * Chris Lalancette <clalance@redhat.com>
64802ee5 8 * Daniel P. Berrange <berrange@redhat.com>
5ac1fad3
PB
9 *
10 * This work is licensed under the terms of the GNU GPL, version 2. See
11 * the COPYING file in the top-level directory.
12 *
6b620ca3
PB
13 * Contributions after 2012-01-13 are licensed under the terms of the
14 * GNU GPL, version 2 or (at your option) any later version.
5ac1fad3
PB
15 */
16
1393a485 17#include "qemu/osdep.h"
dd4339c5 18#include "channel.h"
7fcac4a2 19#include "fd.h"
83c9089e 20#include "monitor/monitor.h"
64802ee5
DB
21#include "io/channel-util.h"
22#include "trace.h"
5ac1fad3 23
131fe9b8 24
f37afb5a 25void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp)
5ac1fad3 26{
64802ee5 27 QIOChannel *ioc;
f8bbc128
PB
28 int fd = monitor_get_fd(cur_mon, fdname, errp);
29 if (fd == -1) {
f37afb5a 30 return;
5ac1fad3 31 }
131fe9b8 32
64802ee5
DB
33 trace_migration_fd_outgoing(fd);
34 ioc = qio_channel_new_fd(fd, errp);
35 if (!ioc) {
36 close(fd);
37 return;
131fe9b8 38 }
5ac1fad3 39
6f01f136 40 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-outgoing");
688a3dcb 41 migration_channel_connect(s, ioc, NULL, NULL);
64802ee5 42 object_unref(OBJECT(ioc));
5ac1fad3
PB
43}
44
64802ee5
DB
45static gboolean fd_accept_incoming_migration(QIOChannel *ioc,
46 GIOCondition condition,
47 gpointer opaque)
5ac1fad3 48{
54314711 49 migration_channel_process_incoming(ioc);
64802ee5 50 object_unref(OBJECT(ioc));
2a543bfd 51 return G_SOURCE_REMOVE;
5ac1fad3
PB
52}
53
43eaae28 54void fd_start_incoming_migration(const char *infd, Error **errp)
5ac1fad3 55{
64802ee5 56 QIOChannel *ioc;
5ac1fad3 57 int fd;
5ac1fad3
PB
58
59 fd = strtol(infd, NULL, 0);
64802ee5
DB
60 trace_migration_fd_incoming(fd);
61
62 ioc = qio_channel_new_fd(fd, errp);
63 if (!ioc) {
64 close(fd);
43eaae28 65 return;
5ac1fad3
PB
66 }
67
6f01f136 68 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-incoming");
64802ee5
DB
69 qio_channel_add_watch(ioc,
70 G_IO_IN,
71 fd_accept_incoming_migration,
72 NULL,
73 NULL);
5ac1fad3 74}