megasas: do not read DCMD opcode more than once from frame
[qemu/ar7.git] / migration / fd.c
blobb2384bf133804b870536d84e68fc1e616edf2e38
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 "qapi/error.h"
19 #include "qemu-common.h"
20 #include "channel.h"
21 #include "fd.h"
22 #include "migration.h"
23 #include "monitor/monitor.h"
24 #include "io/channel-util.h"
25 #include "trace.h"
28 void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp)
30 QIOChannel *ioc;
31 int fd = monitor_get_fd(cur_mon, fdname, errp);
32 if (fd == -1) {
33 return;
36 trace_migration_fd_outgoing(fd);
37 ioc = qio_channel_new_fd(fd, errp);
38 if (!ioc) {
39 close(fd);
40 return;
43 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-outgoing");
44 migration_channel_connect(s, ioc, NULL);
45 object_unref(OBJECT(ioc));
48 static gboolean fd_accept_incoming_migration(QIOChannel *ioc,
49 GIOCondition condition,
50 gpointer opaque)
52 migration_channel_process_incoming(ioc);
53 object_unref(OBJECT(ioc));
54 return FALSE; /* unregister */
57 void fd_start_incoming_migration(const char *infd, Error **errp)
59 QIOChannel *ioc;
60 int fd;
62 fd = strtol(infd, NULL, 0);
63 trace_migration_fd_incoming(fd);
65 ioc = qio_channel_new_fd(fd, errp);
66 if (!ioc) {
67 close(fd);
68 return;
71 qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-incoming");
72 qio_channel_add_watch(ioc,
73 G_IO_IN,
74 fd_accept_incoming_migration,
75 NULL,
76 NULL);