]> Git Repo - qemu.git/blame - migration/fd.c
migration: remove register_savevm()
[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 <[email protected]>
64802ee5 8 * Daniel P. Berrange <[email protected]>
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"
7fcac4a2 21#include "fd.h"
caf71f86 22#include "migration/migration.h"
83c9089e 23#include "monitor/monitor.h"
64802ee5
DB
24#include "io/channel-util.h"
25#include "trace.h"
5ac1fad3 26
131fe9b8 27
f37afb5a 28void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp)
5ac1fad3 29{
64802ee5 30 QIOChannel *ioc;
f8bbc128
PB
31 int fd = monitor_get_fd(cur_mon, fdname, errp);
32 if (fd == -1) {
f37afb5a 33 return;
5ac1fad3 34 }
131fe9b8 35
64802ee5
DB
36 trace_migration_fd_outgoing(fd);
37 ioc = qio_channel_new_fd(fd, errp);
38 if (!ioc) {
39 close(fd);
40 return;
131fe9b8 41 }
5ac1fad3 42
6f01f136 43 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-outgoing");
22724f49 44 migration_channel_connect(s, ioc, NULL);
64802ee5 45 object_unref(OBJECT(ioc));
5ac1fad3
PB
46}
47
64802ee5
DB
48static gboolean fd_accept_incoming_migration(QIOChannel *ioc,
49 GIOCondition condition,
50 gpointer opaque)
5ac1fad3 51{
22724f49 52 migration_channel_process_incoming(migrate_get_current(), ioc);
64802ee5
DB
53 object_unref(OBJECT(ioc));
54 return FALSE; /* unregister */
5ac1fad3
PB
55}
56
43eaae28 57void fd_start_incoming_migration(const char *infd, Error **errp)
5ac1fad3 58{
64802ee5 59 QIOChannel *ioc;
5ac1fad3 60 int fd;
5ac1fad3
PB
61
62 fd = strtol(infd, NULL, 0);
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");
64802ee5
DB
72 qio_channel_add_watch(ioc,
73 G_IO_IN,
74 fd_accept_incoming_migration,
75 NULL,
76 NULL);
5ac1fad3 77}
This page took 0.47967 seconds and 4 git commands to generate.