root / migration-exec.c @ 7443b437
History | View | Annotate | Download (1.7 kB)
1 | 065e2813 | aliguori | /*
|
---|---|---|---|
2 | 065e2813 | aliguori | * QEMU live migration
|
3 | 065e2813 | aliguori | *
|
4 | 065e2813 | aliguori | * Copyright IBM, Corp. 2008
|
5 | 065e2813 | aliguori | * Copyright Dell MessageOne 2008
|
6 | 065e2813 | aliguori | *
|
7 | 065e2813 | aliguori | * Authors:
|
8 | 065e2813 | aliguori | * Anthony Liguori <aliguori@us.ibm.com>
|
9 | 065e2813 | aliguori | * Charles Duffy <charles_duffy@messageone.com>
|
10 | 065e2813 | aliguori | *
|
11 | 065e2813 | aliguori | * This work is licensed under the terms of the GNU GPL, version 2. See
|
12 | 065e2813 | aliguori | * the COPYING file in the top-level directory.
|
13 | 065e2813 | aliguori | *
|
14 | 6b620ca3 | Paolo Bonzini | * Contributions after 2012-01-13 are licensed under the terms of the
|
15 | 6b620ca3 | Paolo Bonzini | * GNU GPL, version 2 or (at your option) any later version.
|
16 | 065e2813 | aliguori | */
|
17 | 065e2813 | aliguori | |
18 | 065e2813 | aliguori | #include "qemu-common.h" |
19 | 1de7afc9 | Paolo Bonzini | #include "qemu/sockets.h" |
20 | caf71f86 | Paolo Bonzini | #include "migration/migration.h" |
21 | 557ec5a0 | Juan Quintela | #include "migration/qemu-file.h" |
22 | 737e150e | Paolo Bonzini | #include "block/block.h" |
23 | 0ffbba35 | Blue Swirl | #include <sys/types.h> |
24 | 0ffbba35 | Blue Swirl | #include <sys/wait.h> |
25 | 065e2813 | aliguori | |
26 | 065e2813 | aliguori | //#define DEBUG_MIGRATION_EXEC
|
27 | 065e2813 | aliguori | |
28 | 065e2813 | aliguori | #ifdef DEBUG_MIGRATION_EXEC
|
29 | d0f2c4c6 | malc | #define DPRINTF(fmt, ...) \
|
30 | 065e2813 | aliguori | do { printf("migration-exec: " fmt, ## __VA_ARGS__); } while (0) |
31 | 065e2813 | aliguori | #else
|
32 | d0f2c4c6 | malc | #define DPRINTF(fmt, ...) \
|
33 | 065e2813 | aliguori | do { } while (0) |
34 | 065e2813 | aliguori | #endif
|
35 | 065e2813 | aliguori | |
36 | f37afb5a | Paolo Bonzini | void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp) |
37 | 065e2813 | aliguori | { |
38 | b352365f | Paolo Bonzini | s->file = qemu_popen_cmd(command, "w");
|
39 | b352365f | Paolo Bonzini | if (s->file == NULL) { |
40 | f37afb5a | Paolo Bonzini | error_setg_errno(errp, errno, "failed to popen the migration target");
|
41 | f37afb5a | Paolo Bonzini | return;
|
42 | 065e2813 | aliguori | } |
43 | 065e2813 | aliguori | |
44 | 065e2813 | aliguori | migrate_fd_connect(s); |
45 | 065e2813 | aliguori | } |
46 | 065e2813 | aliguori | |
47 | 8a43b1ea | Chris Lalancette | static void exec_accept_incoming_migration(void *opaque) |
48 | 065e2813 | aliguori | { |
49 | 8a43b1ea | Chris Lalancette | QEMUFile *f = opaque; |
50 | 065e2813 | aliguori | |
51 | d263a20b | Paolo Bonzini | qemu_set_fd_handler2(qemu_get_fd(f), NULL, NULL, NULL, NULL); |
52 | a6ef2909 | Paolo Bonzini | process_incoming_migration(f); |
53 | 8a43b1ea | Chris Lalancette | } |
54 | 8a43b1ea | Chris Lalancette | |
55 | 43eaae28 | Paolo Bonzini | void exec_start_incoming_migration(const char *command, Error **errp) |
56 | 8a43b1ea | Chris Lalancette | { |
57 | 8a43b1ea | Chris Lalancette | QEMUFile *f; |
58 | 8a43b1ea | Chris Lalancette | |
59 | d0f2c4c6 | malc | DPRINTF("Attempting to start an incoming migration\n");
|
60 | 8a43b1ea | Chris Lalancette | f = qemu_popen_cmd(command, "r");
|
61 | 8a43b1ea | Chris Lalancette | if(f == NULL) { |
62 | 43eaae28 | Paolo Bonzini | error_setg_errno(errp, errno, "failed to popen the migration source");
|
63 | 43eaae28 | Paolo Bonzini | return;
|
64 | 8a43b1ea | Chris Lalancette | } |
65 | 8a43b1ea | Chris Lalancette | |
66 | d263a20b | Paolo Bonzini | qemu_set_fd_handler2(qemu_get_fd(f), NULL,
|
67 | 1c39e2a2 | Juan Quintela | exec_accept_incoming_migration, NULL, f);
|
68 | 065e2813 | aliguori | } |