]> git.proxmox.com Git - mirror_qemu.git/blame - migration/exec.c
ram: Now POSTCOPY_ACTIVE is the same that STATUS_ACTIVE
[mirror_qemu.git] / migration / exec.c
CommitLineData
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 <aliguori@us.ibm.com>
10 * Charles Duffy <charles_duffy@messageone.com>
527792fa 11 * Daniel P. Berrange <berrange@redhat.com>
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"
065e2813 22#include "qemu-common.h"
dd4339c5 23#include "channel.h"
f4dbe1bf 24#include "exec.h"
caf71f86 25#include "migration/migration.h"
527792fa
DB
26#include "io/channel-command.h"
27#include "trace.h"
065e2813 28
065e2813 29
f37afb5a 30void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
065e2813 31{
527792fa
DB
32 QIOChannel *ioc;
33 const char *argv[] = { "/bin/sh", "-c", command, NULL };
34
35 trace_migration_exec_outgoing(command);
36 ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,
062d81f0 37 O_RDWR,
527792fa
DB
38 errp));
39 if (!ioc) {
f37afb5a 40 return;
065e2813
AL
41 }
42
6f01f136 43 qio_channel_set_name(ioc, "migration-exec-outgoing");
22724f49 44 migration_channel_connect(s, ioc, NULL);
527792fa 45 object_unref(OBJECT(ioc));
065e2813
AL
46}
47
527792fa
DB
48static gboolean exec_accept_incoming_migration(QIOChannel *ioc,
49 GIOCondition condition,
50 gpointer opaque)
065e2813 51{
22724f49 52 migration_channel_process_incoming(migrate_get_current(), ioc);
527792fa
DB
53 object_unref(OBJECT(ioc));
54 return FALSE; /* unregister */
8a43b1ea
CL
55}
56
43eaae28 57void exec_start_incoming_migration(const char *command, Error **errp)
8a43b1ea 58{
527792fa
DB
59 QIOChannel *ioc;
60 const char *argv[] = { "/bin/sh", "-c", command, NULL };
8a43b1ea 61
527792fa
DB
62 trace_migration_exec_incoming(command);
63 ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,
062d81f0 64 O_RDWR,
527792fa
DB
65 errp));
66 if (!ioc) {
43eaae28 67 return;
8a43b1ea
CL
68 }
69
6f01f136 70 qio_channel_set_name(ioc, "migration-exec-incoming");
527792fa
DB
71 qio_channel_add_watch(ioc,
72 G_IO_IN,
73 exec_accept_incoming_migration,
74 NULL,
75 NULL);
065e2813 76}