pc-dimm: merge get_(vmstate_)memory_region()
[qemu.git] / migration / exec.c
blob0bbeb63c97e548c4d1fa541dac37c57c34df6493
1 /*
2 * QEMU live migration
4 * Copyright IBM, Corp. 2008
5 * Copyright Dell MessageOne 2008
6 * Copyright Red Hat, Inc. 2015-2016
8 * Authors:
9 * Anthony Liguori <aliguori@us.ibm.com>
10 * Charles Duffy <charles_duffy@messageone.com>
11 * Daniel P. Berrange <berrange@redhat.com>
13 * This work is licensed under the terms of the GNU GPL, version 2. See
14 * the COPYING file in the top-level directory.
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.
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"
28 void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
30 QIOChannel *ioc;
31 const char *argv[] = { "/bin/sh", "-c", command, NULL };
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;
41 qio_channel_set_name(ioc, "migration-exec-outgoing");
42 migration_channel_connect(s, ioc, NULL, NULL);
43 object_unref(OBJECT(ioc));
46 static gboolean exec_accept_incoming_migration(QIOChannel *ioc,
47 GIOCondition condition,
48 gpointer opaque)
50 migration_channel_process_incoming(ioc);
51 object_unref(OBJECT(ioc));
52 if (!migrate_use_multifd()) {
53 migration_incoming_process();
55 return G_SOURCE_REMOVE;
58 void exec_start_incoming_migration(const char *command, Error **errp)
60 QIOChannel *ioc;
61 const char *argv[] = { "/bin/sh", "-c", command, NULL };
63 trace_migration_exec_incoming(command);
64 ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,
65 O_RDWR,
66 errp));
67 if (!ioc) {
68 return;
71 qio_channel_set_name(ioc, "migration-exec-incoming");
72 qio_channel_add_watch_full(ioc, G_IO_IN,
73 exec_accept_incoming_migration,
74 NULL, NULL,
75 g_main_context_get_thread_default());