]> git.proxmox.com Git - mirror_qemu.git/blame - migration/fd.c
migration: Export exec.c functions in its own file
[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"
da34e65c 18#include "qapi/error.h"
5ac1fad3 19#include "qemu-common.h"
dd4339c5 20#include "channel.h"
caf71f86 21#include "migration/migration.h"
83c9089e 22#include "monitor/monitor.h"
64802ee5
DB
23#include "io/channel-util.h"
24#include "trace.h"
5ac1fad3 25
131fe9b8 26
f37afb5a 27void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp)
5ac1fad3 28{
64802ee5 29 QIOChannel *ioc;
f8bbc128
PB
30 int fd = monitor_get_fd(cur_mon, fdname, errp);
31 if (fd == -1) {
f37afb5a 32 return;
5ac1fad3 33 }
131fe9b8 34
64802ee5
DB
35 trace_migration_fd_outgoing(fd);
36 ioc = qio_channel_new_fd(fd, errp);
37 if (!ioc) {
38 close(fd);
39 return;
131fe9b8 40 }
5ac1fad3 41
6f01f136 42 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-outgoing");
22724f49 43 migration_channel_connect(s, ioc, NULL);
64802ee5 44 object_unref(OBJECT(ioc));
5ac1fad3
PB
45}
46
64802ee5
DB
47static gboolean fd_accept_incoming_migration(QIOChannel *ioc,
48 GIOCondition condition,
49 gpointer opaque)
5ac1fad3 50{
22724f49 51 migration_channel_process_incoming(migrate_get_current(), ioc);
64802ee5
DB
52 object_unref(OBJECT(ioc));
53 return FALSE; /* unregister */
5ac1fad3
PB
54}
55
43eaae28 56void fd_start_incoming_migration(const char *infd, Error **errp)
5ac1fad3 57{
64802ee5 58 QIOChannel *ioc;
5ac1fad3 59 int fd;
5ac1fad3
PB
60
61 fd = strtol(infd, NULL, 0);
64802ee5
DB
62 trace_migration_fd_incoming(fd);
63
64 ioc = qio_channel_new_fd(fd, errp);
65 if (!ioc) {
66 close(fd);
43eaae28 67 return;
5ac1fad3
PB
68 }
69
6f01f136 70 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-incoming");
64802ee5
DB
71 qio_channel_add_watch(ioc,
72 G_IO_IN,
73 fd_accept_incoming_migration,
74 NULL,
75 NULL);
5ac1fad3 76}