]> Git Repo - qemu.git/blame - migration/migration.h
migration: Wait for semaphore before completing migration
[qemu.git] / migration / migration.h
CommitLineData
5bb7910a
AL
1/*
2 * QEMU live migration
3 *
4 * Copyright IBM, Corp. 2008
5 *
6 * Authors:
7 * Anthony Liguori <[email protected]>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
12 */
13
14#ifndef QEMU_MIGRATION_H
15#define QEMU_MIGRATION_H
16
376253ec 17#include "qemu-common.h"
9848a404 18#include "qemu/thread.h"
bbf6da32 19#include "qapi-types.h"
43487c67 20#include "exec/cpu-common.h"
25d0c16f 21#include "qemu/coroutine_int.h"
e5cb7e76 22#include "hw/qdev.h"
4f0fae7f 23#include "io/channel.h"
376253ec 24
bca7856a
DDAG
25/* State for the incoming migration */
26struct MigrationIncomingState {
42e2aa56 27 QEMUFile *from_src_file;
1a8f46f8 28
7b89bf27
DDAG
29 /*
30 * Free at the start of the main state load, set as the main thread finishes
31 * loading state.
32 */
33 QemuEvent main_thread_load_event;
34
67f11b5c 35 size_t largest_page_size;
c4faeed2 36 bool have_fault_thread;
f0a227ad
DDAG
37 QemuThread fault_thread;
38 QemuSemaphore fault_thread_sem;
39
c76201ab
DDAG
40 bool have_listen_thread;
41 QemuThread listen_thread;
42 QemuSemaphore listen_thread_sem;
43
1caddf8a
DDAG
44 /* For the kernel to send us notifications */
45 int userfault_fd;
c4faeed2
DDAG
46 /* To tell the fault_thread to quit */
47 int userfault_quit_fd;
2e37701e 48 QEMUFile *to_src_file;
6decec93 49 QemuMutex rp_mutex; /* We send replies from multiple threads */
696ed9a9 50 void *postcopy_tmp_page;
41d84210 51 void *postcopy_tmp_zero_page;
2e37701e 52
0aa6aefc
DL
53 QEMUBH *bh;
54
93d7af6f 55 int state;
25d0c16f
HZ
56
57 bool have_colo_incoming_thread;
58 QemuThread colo_incoming_thread;
59 /* The coroutine we should enter (back) after failover */
60 Coroutine *migration_incoming_co;
c937b9a6 61 QemuSemaphore colo_incoming_sem;
bca7856a
DDAG
62};
63
64MigrationIncomingState *migration_incoming_get_current(void);
bca7856a
DDAG
65void migration_incoming_state_destroy(void);
66
e5cb7e76
PX
67#define TYPE_MIGRATION "migration"
68
69#define MIGRATION_CLASS(klass) \
70 OBJECT_CLASS_CHECK(MigrationClass, (klass), TYPE_MIGRATION)
71#define MIGRATION_OBJ(obj) \
72 OBJECT_CHECK(MigrationState, (obj), TYPE_MIGRATION)
73#define MIGRATION_GET_CLASS(obj) \
74 OBJECT_GET_CLASS(MigrationClass, (obj), TYPE_MIGRATION)
75
76typedef struct MigrationClass {
77 /*< private >*/
78 DeviceClass parent_class;
79} MigrationClass;
80
22f00a44 81struct MigrationState
065e2813 82{
e5cb7e76
PX
83 /*< private >*/
84 DeviceState parent_obj;
85
86 /*< public >*/
9848a404
JQ
87 size_t bytes_xfer;
88 size_t xfer_limit;
9848a404 89 QemuThread thread;
bb1fadc4 90 QEMUBH *cleanup_bh;
89a02a9f 91 QEMUFile *to_dst_file;
2594f56d 92
a0762d9e 93 /* params from 'migrate-set-parameters' */
2594f56d 94 MigrationParameters parameters;
f8bbc128 95
f8bbc128 96 int state;
70b20477
DDAG
97
98 /* State related to return path */
99 struct {
100 QEMUFile *from_dst_file;
101 QemuThread rp_thread;
102 bool error;
103 } rp_state;
104
7e114f8c 105 double mbps;
d5f8a570 106 int64_t total_time;
9c5a9fcf 107 int64_t downtime;
2c52ddf1 108 int64_t expected_downtime;
7fb1cf16 109 bool enabled_capabilities[MIGRATION_CAPABILITY__MAX];
17ad9b35 110 int64_t xbzrle_cache_size;
ed4fbd10 111 int64_t setup_time;
4886a1bc
DDAG
112
113 /* Flag set once the migration has been asked to enter postcopy */
114 bool start_postcopy;
b82fc321
DDAG
115 /* Flag set after postcopy has sent the device state */
116 bool postcopy_after_devices;
1d34e4bf
DDAG
117
118 /* Flag set once the migration thread is running (and needs joining) */
119 bool migration_thread_running;
6c595cde 120
1d2acc31
HZ
121 /* Flag set once the migration thread called bdrv_inactivate_all */
122 bool block_inactive;
123
e91d8951
DDAG
124 /* Migration is paused due to pause-before-switchover */
125 QemuSemaphore pause_sem;
126
c937b9a6
HZ
127 /* The semaphore is used to notify COLO thread that failover is finished */
128 QemuSemaphore colo_exit_sem;
d59ce6f3 129
479125d5
HZ
130 /* The semaphore is used to notify COLO thread to do checkpoint */
131 QemuSemaphore colo_checkpoint_sem;
132 int64_t colo_checkpoint_time;
133 QEMUTimer *colo_delay_timer;
134
d59ce6f3
DB
135 /* The last error that occurred */
136 Error *error;
2833c59b
JQ
137 /* Do we have to clean up -b/-i from old migrate parameters */
138 /* This feature is deprecated and will be removed */
139 bool must_remove_block_options;
5272298c
PX
140
141 /*
142 * Global switch on whether we need to store the global state
143 * during migration.
144 */
145 bool store_global_state;
3df663e5
PX
146
147 /* Whether the VM is only allowing for migratable devices */
148 bool only_migratable;
71dd4c1a
PX
149
150 /* Whether we send QEMU_VM_CONFIGURATION during migration */
151 bool send_configuration;
15c38503
PX
152 /* Whether we send section footer during migration */
153 bool send_section_footer;
065e2813
AL
154};
155
48781e5b
HZ
156void migrate_set_state(int *state, int old_state, int new_state);
157
22724f49 158void migration_fd_process_incoming(QEMUFile *f);
4f0fae7f 159void migration_ioc_process_incoming(QIOChannel *ioc);
511c0231 160
428d8908
JQ
161bool migration_has_all_channels(void);
162
a0a3fd60
GC
163uint64_t migrate_max_downtime(void);
164
d59ce6f3 165void migrate_fd_error(MigrationState *s, const Error *error);
065e2813 166
22f00a44 167void migrate_fd_connect(MigrationState *s);
065e2813 168
a0762d9e 169MigrationState *migrate_init(void);
24f3902b 170bool migration_is_blocked(Error **errp);
9ec055ae 171/* True if outgoing migration has entered postcopy phase */
5727309d 172bool migration_in_postcopy(void);
859bc756 173MigrationState *migrate_get_current(void);
99a0db9b 174
58110f0a
VSO
175bool migrate_postcopy(void);
176
53f09a10 177bool migrate_release_ram(void);
53dd370c 178bool migrate_postcopy_ram(void);
323004a3 179bool migrate_zero_blocks(void);
60d9222c 180
bde1e2ec 181bool migrate_auto_converge(void);
30126bbf 182bool migrate_use_multifd(void);
93fbd031 183bool migrate_pause_before_switchover(void);
4075fb1c 184int migrate_multifd_channels(void);
0fb86605 185int migrate_multifd_page_count(void);
bde1e2ec 186
17ad9b35
OW
187int migrate_use_xbzrle(void);
188int64_t migrate_xbzrle_cache_size(void);
35a6ed4f 189bool migrate_colo_enabled(void);
17ad9b35 190
2833c59b
JQ
191bool migrate_use_block(void);
192bool migrate_use_block_incremental(void);
c788ada8 193bool migrate_use_return_path(void);
2833c59b 194
8706d2d5
LL
195bool migrate_use_compression(void);
196int migrate_compress_level(void);
197int migrate_compress_threads(void);
3fcb38c2 198int migrate_decompress_threads(void);
b05dc723 199bool migrate_use_events(void);
8706d2d5 200
6decec93 201/* Sending on the return path - generic and then for each message type */
6decec93
DDAG
202void migrate_send_rp_shut(MigrationIncomingState *mis,
203 uint32_t value);
204void migrate_send_rp_pong(MigrationIncomingState *mis,
205 uint32_t value);
1e2d90eb
DDAG
206void migrate_send_rp_req_pages(MigrationIncomingState *mis, const char* rbname,
207 ram_addr_t start, size_t len);
6decec93 208
5bb7910a 209#endif
This page took 0.633374 seconds and 4 git commands to generate.