compat: remove remaining PC_COMPAT macros
[qemu/ar7.git] / migration / fd.c
bloba7c13df4ad3e7ad685ddb3ec01b6373d5003d192
1 /*
2 * QEMU live migration via generic fd
4 * Copyright Red Hat, Inc. 2009-2016
6 * Authors:
7 * Chris Lalancette <clalance@redhat.com>
8 * Daniel P. Berrange <berrange@redhat.com>
10 * This work is licensed under the terms of the GNU GPL, version 2. See
11 * the COPYING file in the top-level directory.
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.
17 #include "qemu/osdep.h"
18 #include "channel.h"
19 #include "fd.h"
20 #include "migration.h"
21 #include "monitor/monitor.h"
22 #include "io/channel-util.h"
23 #include "trace.h"
26 void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp)
28 QIOChannel *ioc;
29 int fd = monitor_get_fd(cur_mon, fdname, errp);
30 if (fd == -1) {
31 return;
34 trace_migration_fd_outgoing(fd);
35 ioc = qio_channel_new_fd(fd, errp);
36 if (!ioc) {
37 close(fd);
38 return;
41 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-outgoing");
42 migration_channel_connect(s, ioc, NULL, NULL);
43 object_unref(OBJECT(ioc));
46 static gboolean fd_accept_incoming_migration(QIOChannel *ioc,
47 GIOCondition condition,
48 gpointer opaque)
50 migration_channel_process_incoming(ioc);
51 object_unref(OBJECT(ioc));
52 return G_SOURCE_REMOVE;
55 void fd_start_incoming_migration(const char *infd, Error **errp)
57 QIOChannel *ioc;
58 int fd;
60 fd = strtol(infd, NULL, 0);
61 trace_migration_fd_incoming(fd);
63 ioc = qio_channel_new_fd(fd, errp);
64 if (!ioc) {
65 close(fd);
66 return;
69 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-incoming");
70 qio_channel_add_watch_full(ioc, G_IO_IN,
71 fd_accept_incoming_migration,
72 NULL, NULL,
73 g_main_context_get_thread_default());