]>
Commit | Line | Data |
---|---|---|
065e2813 AL |
1 | /* |
2 | * QEMU live migration | |
3 | * | |
4 | * Copyright IBM, Corp. 2008 | |
5 | * Copyright Dell MessageOne 2008 | |
527792fa | 6 | * Copyright Red Hat, Inc. 2015-2016 |
065e2813 AL |
7 | * |
8 | * Authors: | |
9 | * Anthony Liguori <[email protected]> | |
10 | * Charles Duffy <[email protected]> | |
527792fa | 11 | * Daniel P. Berrange <[email protected]> |
065e2813 AL |
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 | * | |
6b620ca3 PB |
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. | |
065e2813 AL |
18 | */ |
19 | ||
1393a485 | 20 | #include "qemu/osdep.h" |
da34e65c | 21 | #include "qapi/error.h" |
dd4339c5 | 22 | #include "channel.h" |
f4dbe1bf | 23 | #include "exec.h" |
527792fa DB |
24 | #include "io/channel-command.h" |
25 | #include "trace.h" | |
065e2813 | 26 | |
065e2813 | 27 | |
f37afb5a | 28 | void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp) |
065e2813 | 29 | { |
527792fa DB |
30 | QIOChannel *ioc; |
31 | const char *argv[] = { "/bin/sh", "-c", command, NULL }; | |
32 | ||
33 | trace_migration_exec_outgoing(command); | |
34 | ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv, | |
062d81f0 | 35 | O_RDWR, |
527792fa DB |
36 | errp)); |
37 | if (!ioc) { | |
f37afb5a | 38 | return; |
065e2813 AL |
39 | } |
40 | ||
6f01f136 | 41 | qio_channel_set_name(ioc, "migration-exec-outgoing"); |
22724f49 | 42 | migration_channel_connect(s, ioc, NULL); |
527792fa | 43 | object_unref(OBJECT(ioc)); |
065e2813 AL |
44 | } |
45 | ||
527792fa DB |
46 | static gboolean exec_accept_incoming_migration(QIOChannel *ioc, |
47 | GIOCondition condition, | |
48 | gpointer opaque) | |
065e2813 | 49 | { |
54314711 | 50 | migration_channel_process_incoming(ioc); |
527792fa DB |
51 | object_unref(OBJECT(ioc)); |
52 | return FALSE; /* unregister */ | |
8a43b1ea CL |
53 | } |
54 | ||
43eaae28 | 55 | void exec_start_incoming_migration(const char *command, Error **errp) |
8a43b1ea | 56 | { |
527792fa DB |
57 | QIOChannel *ioc; |
58 | const char *argv[] = { "/bin/sh", "-c", command, NULL }; | |
8a43b1ea | 59 | |
527792fa DB |
60 | trace_migration_exec_incoming(command); |
61 | ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv, | |
062d81f0 | 62 | O_RDWR, |
527792fa DB |
63 | errp)); |
64 | if (!ioc) { | |
43eaae28 | 65 | return; |
8a43b1ea CL |
66 | } |
67 | ||
6f01f136 | 68 | qio_channel_set_name(ioc, "migration-exec-incoming"); |
527792fa DB |
69 | qio_channel_add_watch(ioc, |
70 | G_IO_IN, | |
71 | exec_accept_incoming_migration, | |
72 | NULL, | |
73 | NULL); | |
065e2813 | 74 | } |