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 "io/channel-command.h"
24#include "trace.h"
25
26
27void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
28{
29 QIOChannel *ioc;
30 const char *argv[] = { "/bin/sh", "-c", command, NULL };
31
32 trace_migration_exec_outgoing(command);
33 ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,
34 O_RDWR,
35 errp));
36 if (!ioc) {
37 return;
38 }
39
40 qio_channel_set_name(ioc, "migration-exec-outgoing");
41 migration_channel_connect(s, ioc, NULL, NULL);
42 object_unref(OBJECT(ioc));
43}
44
45static gboolean exec_accept_incoming_migration(QIOChannel *ioc,
46 GIOCondition condition,
47 gpointer opaque)
48{
49 migration_channel_process_incoming(ioc);
50 object_unref(OBJECT(ioc));
51 return G_SOURCE_REMOVE;
52}
53
54void exec_start_incoming_migration(const char *command, Error **errp)
55{
56 QIOChannel *ioc;
57 const char *argv[] = { "/bin/sh", "-c", command, NULL };
58
59 trace_migration_exec_incoming(command);
60 ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,
61 O_RDWR,
62 errp));
63 if (!ioc) {
64 return;
65 }
66
67 qio_channel_set_name(ioc, "migration-exec-incoming");
68 qio_channel_add_watch(ioc,
69 G_IO_IN,
70 exec_accept_incoming_migration,
71 NULL,
72 NULL);
73}
74