]> git.proxmox.com Git - mirror_qemu.git/blame - migration/fd.c
migration: Deprecate fd: for file migration
[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"
74228c59 20#include "file.h"
0efc9142 21#include "migration.h"
83c9089e 22#include "monitor/monitor.h"
c55deb86
FR
23#include "qemu/error-report.h"
24#include "qemu/sockets.h"
64802ee5
DB
25#include "io/channel-util.h"
26#include "trace.h"
5ac1fad3 27
131fe9b8 28
f37afb5a 29void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp)
5ac1fad3 30{
64802ee5 31 QIOChannel *ioc;
947e4744 32 int fd = monitor_get_fd(monitor_cur(), fdname, errp);
f8bbc128 33 if (fd == -1) {
f37afb5a 34 return;
5ac1fad3 35 }
131fe9b8 36
c55deb86
FR
37 if (!fd_is_socket(fd)) {
38 warn_report("fd: migration to a file is deprecated."
39 " Use file: instead.");
40 }
41
64802ee5
DB
42 trace_migration_fd_outgoing(fd);
43 ioc = qio_channel_new_fd(fd, errp);
44 if (!ioc) {
45 close(fd);
46 return;
131fe9b8 47 }
5ac1fad3 48
7d5b0d68 49 qio_channel_set_name(ioc, "migration-fd-outgoing");
688a3dcb 50 migration_channel_connect(s, ioc, NULL, NULL);
64802ee5 51 object_unref(OBJECT(ioc));
5ac1fad3
PB
52}
53
64802ee5
DB
54static gboolean fd_accept_incoming_migration(QIOChannel *ioc,
55 GIOCondition condition,
56 gpointer opaque)
5ac1fad3 57{
54314711 58 migration_channel_process_incoming(ioc);
64802ee5 59 object_unref(OBJECT(ioc));
2a543bfd 60 return G_SOURCE_REMOVE;
5ac1fad3
PB
61}
62
61053d48 63void fd_start_incoming_migration(const char *fdname, Error **errp)
5ac1fad3 64{
64802ee5 65 QIOChannel *ioc;
947e4744 66 int fd = monitor_fd_param(monitor_cur(), fdname, errp);
61053d48
YK
67 if (fd == -1) {
68 return;
69 }
5ac1fad3 70
c55deb86
FR
71 if (!fd_is_socket(fd)) {
72 warn_report("fd: migration to a file is deprecated."
73 " Use file: instead.");
74 }
75
64802ee5
DB
76 trace_migration_fd_incoming(fd);
77
78 ioc = qio_channel_new_fd(fd, errp);
79 if (!ioc) {
80 close(fd);
43eaae28 81 return;
5ac1fad3
PB
82 }
83
bd4480b0
FR
84 qio_channel_set_name(ioc, "migration-fd-incoming");
85 qio_channel_add_watch_full(ioc, G_IO_IN,
86 fd_accept_incoming_migration,
87 NULL, NULL,
88 g_main_context_get_thread_default());
5ac1fad3 89}