1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include "qemu/osdep.h"
21#include "channel.h"
22#include "exec.h"
23#include "migration.h"
24#include "io/channel-command.h"
25#include "trace.h"
26
27
28void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
29{
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,
35 O_RDWR,
36 errp));
37 if (!ioc) {
38 return;
39 }
40
41 qio_channel_set_name(ioc, "migration-exec-outgoing");
42 migration_channel_connect(s, ioc, NULL, NULL);
43 object_unref(OBJECT(ioc));
44}
45
46static gboolean exec_accept_incoming_migration(QIOChannel *ioc,
47 GIOCondition condition,
48 gpointer opaque)
49{
50 migration_channel_process_incoming(ioc);
51 object_unref(OBJECT(ioc));
52 return G_SOURCE_REMOVE;
53}
54
55void exec_start_incoming_migration(const char *command, Error **errp)
56{
57 QIOChannel *ioc;
58 const char *argv[] = { "/bin/sh", "-c", command, NULL };
59
60 trace_migration_exec_incoming(command);
61 ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,
62 O_RDWR,
63 errp));
64 if (!ioc) {
65 return;
66 }
67
68 qio_channel_set_name(ioc, "migration-exec-incoming");
69 qio_channel_add_watch_full(ioc, G_IO_IN,
70 exec_accept_incoming_migration,
71 NULL, NULL,
72 g_main_context_get_thread_default());
73}
74