]> git.proxmox.com Git - mirror_qemu.git/blob - migration/exec.c
migration: Split migration/channel.c for channel operations
[mirror_qemu.git] / migration / exec.c
1 /*
2 * QEMU live migration
3 *
4 * Copyright IBM, Corp. 2008
5 * Copyright Dell MessageOne 2008
6 * Copyright Red Hat, Inc. 2015-2016
7 *
8 * Authors:
9 * Anthony Liguori <aliguori@us.ibm.com>
10 * Charles Duffy <charles_duffy@messageone.com>
11 * Daniel P. Berrange <berrange@redhat.com>
12 *
13 * This work is licensed under the terms of the GNU GPL, version 2. See
14 * the COPYING file in the top-level directory.
15 *
16 * Contributions after 2012-01-13 are licensed under the terms of the
17 * GNU GPL, version 2 or (at your option) any later version.
18 */
19
20 #include "qemu/osdep.h"
21 #include "qapi/error.h"
22 #include "qemu-common.h"
23 #include "channel.h"
24 #include "migration/migration.h"
25 #include "io/channel-command.h"
26 #include "trace.h"
27
28
29 void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
30 {
31 QIOChannel *ioc;
32 const char *argv[] = { "/bin/sh", "-c", command, NULL };
33
34 trace_migration_exec_outgoing(command);
35 ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,
36 O_RDWR,
37 errp));
38 if (!ioc) {
39 return;
40 }
41
42 qio_channel_set_name(ioc, "migration-exec-outgoing");
43 migration_channel_connect(s, ioc, NULL);
44 object_unref(OBJECT(ioc));
45 }
46
47 static gboolean exec_accept_incoming_migration(QIOChannel *ioc,
48 GIOCondition condition,
49 gpointer opaque)
50 {
51 migration_channel_process_incoming(migrate_get_current(), ioc);
52 object_unref(OBJECT(ioc));
53 return FALSE; /* unregister */
54 }
55
56 void exec_start_incoming_migration(const char *command, Error **errp)
57 {
58 QIOChannel *ioc;
59 const char *argv[] = { "/bin/sh", "-c", command, NULL };
60
61 trace_migration_exec_incoming(command);
62 ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,
63 O_RDWR,
64 errp));
65 if (!ioc) {
66 return;
67 }
68
69 qio_channel_set_name(ioc, "migration-exec-incoming");
70 qio_channel_add_watch(ioc,
71 G_IO_IN,
72 exec_accept_incoming_migration,
73 NULL,
74 NULL);
75 }