]> git.proxmox.com Git - mirror_qemu.git/blame - migration/fd.c
migration/postcopy: remove redundant cpu_synchronize_all_post_init
[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"
0efc9142 20#include "migration.h"
83c9089e 21#include "monitor/monitor.h"
64802ee5
DB
22#include "io/channel-util.h"
23#include "trace.h"
5ac1fad3 24
131fe9b8 25
f37afb5a 26void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp)
5ac1fad3 27{
64802ee5 28 QIOChannel *ioc;
f8bbc128
PB
29 int fd = monitor_get_fd(cur_mon, fdname, errp);
30 if (fd == -1) {
f37afb5a 31 return;
5ac1fad3 32 }
131fe9b8 33
64802ee5
DB
34 trace_migration_fd_outgoing(fd);
35 ioc = qio_channel_new_fd(fd, errp);
36 if (!ioc) {
37 close(fd);
38 return;
131fe9b8 39 }
5ac1fad3 40
6f01f136 41 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-outgoing");
688a3dcb 42 migration_channel_connect(s, ioc, NULL, NULL);
64802ee5 43 object_unref(OBJECT(ioc));
5ac1fad3
PB
44}
45
64802ee5
DB
46static gboolean fd_accept_incoming_migration(QIOChannel *ioc,
47 GIOCondition condition,
48 gpointer opaque)
5ac1fad3 49{
54314711 50 migration_channel_process_incoming(ioc);
64802ee5 51 object_unref(OBJECT(ioc));
2a543bfd 52 return G_SOURCE_REMOVE;
5ac1fad3
PB
53}
54
61053d48 55void fd_start_incoming_migration(const char *fdname, Error **errp)
5ac1fad3 56{
64802ee5 57 QIOChannel *ioc;
61053d48
YK
58 int fd = monitor_fd_param(cur_mon, fdname, errp);
59 if (fd == -1) {
60 return;
61 }
5ac1fad3 62
64802ee5
DB
63 trace_migration_fd_incoming(fd);
64
65 ioc = qio_channel_new_fd(fd, errp);
66 if (!ioc) {
67 close(fd);
43eaae28 68 return;
5ac1fad3
PB
69 }
70
6f01f136 71 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-incoming");
e89f5ff2
PX
72 qio_channel_add_watch_full(ioc, G_IO_IN,
73 fd_accept_incoming_migration,
74 NULL, NULL,
75 g_main_context_get_thread_default());
5ac1fad3 76}