target-arm: Implement ccmp branchless
[qemu/kevin.git] / include / migration / migration.h
blob83346210b11172efbbd2f1853214327edd325a23
1 /*
2 * QEMU live migration
4 * Copyright IBM, Corp. 2008
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
14 #ifndef QEMU_MIGRATION_H
15 #define QEMU_MIGRATION_H
17 #include "qapi/qmp/qdict.h"
18 #include "qemu-common.h"
19 #include "qemu/thread.h"
20 #include "qemu/notify.h"
21 #include "qapi/error.h"
22 #include "migration/vmstate.h"
23 #include "qapi-types.h"
24 #include "exec/cpu-common.h"
26 #define QEMU_VM_FILE_MAGIC 0x5145564d
27 #define QEMU_VM_FILE_VERSION_COMPAT 0x00000002
28 #define QEMU_VM_FILE_VERSION 0x00000003
30 #define QEMU_VM_EOF 0x00
31 #define QEMU_VM_SECTION_START 0x01
32 #define QEMU_VM_SECTION_PART 0x02
33 #define QEMU_VM_SECTION_END 0x03
34 #define QEMU_VM_SECTION_FULL 0x04
35 #define QEMU_VM_SUBSECTION 0x05
36 #define QEMU_VM_VMDESCRIPTION 0x06
37 #define QEMU_VM_CONFIGURATION 0x07
38 #define QEMU_VM_SECTION_FOOTER 0x7e
40 struct MigrationParams {
41 bool blk;
42 bool shared;
45 typedef struct MigrationState MigrationState;
47 typedef QLIST_HEAD(, LoadStateEntry) LoadStateEntry_Head;
49 /* State for the incoming migration */
50 struct MigrationIncomingState {
51 QEMUFile *file;
53 /* See savevm.c */
54 LoadStateEntry_Head loadvm_handlers;
57 MigrationIncomingState *migration_incoming_get_current(void);
58 MigrationIncomingState *migration_incoming_state_new(QEMUFile *f);
59 void migration_incoming_state_destroy(void);
61 struct MigrationState
63 int64_t bandwidth_limit;
64 size_t bytes_xfer;
65 size_t xfer_limit;
66 QemuThread thread;
67 QEMUBH *cleanup_bh;
68 QEMUFile *file;
69 int parameters[MIGRATION_PARAMETER_MAX];
71 int state;
72 MigrationParams params;
73 double mbps;
74 int64_t total_time;
75 int64_t downtime;
76 int64_t expected_downtime;
77 int64_t dirty_pages_rate;
78 int64_t dirty_bytes_rate;
79 bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
80 int64_t xbzrle_cache_size;
81 int64_t setup_time;
82 int64_t dirty_sync_count;
85 void process_incoming_migration(QEMUFile *f);
87 void qemu_start_incoming_migration(const char *uri, Error **errp);
89 uint64_t migrate_max_downtime(void);
91 void exec_start_incoming_migration(const char *host_port, Error **errp);
93 void exec_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
95 void tcp_start_incoming_migration(const char *host_port, Error **errp);
97 void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
99 void unix_start_incoming_migration(const char *path, Error **errp);
101 void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp);
103 void fd_start_incoming_migration(const char *path, Error **errp);
105 void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp);
107 void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp);
109 void rdma_start_incoming_migration(const char *host_port, Error **errp);
111 void migrate_fd_error(MigrationState *s);
113 void migrate_fd_connect(MigrationState *s);
115 int migrate_fd_close(MigrationState *s);
117 void add_migration_state_change_notifier(Notifier *notify);
118 void remove_migration_state_change_notifier(Notifier *notify);
119 bool migration_in_setup(MigrationState *);
120 bool migration_has_finished(MigrationState *);
121 bool migration_has_failed(MigrationState *);
122 MigrationState *migrate_get_current(void);
124 void migrate_compress_threads_create(void);
125 void migrate_compress_threads_join(void);
126 void migrate_decompress_threads_create(void);
127 void migrate_decompress_threads_join(void);
128 uint64_t ram_bytes_remaining(void);
129 uint64_t ram_bytes_transferred(void);
130 uint64_t ram_bytes_total(void);
131 void free_xbzrle_decoded_buf(void);
133 void acct_update_position(QEMUFile *f, size_t size, bool zero);
135 uint64_t dup_mig_bytes_transferred(void);
136 uint64_t dup_mig_pages_transferred(void);
137 uint64_t skipped_mig_bytes_transferred(void);
138 uint64_t skipped_mig_pages_transferred(void);
139 uint64_t norm_mig_bytes_transferred(void);
140 uint64_t norm_mig_pages_transferred(void);
141 uint64_t xbzrle_mig_bytes_transferred(void);
142 uint64_t xbzrle_mig_pages_transferred(void);
143 uint64_t xbzrle_mig_pages_overflow(void);
144 uint64_t xbzrle_mig_pages_cache_miss(void);
145 double xbzrle_mig_cache_miss_rate(void);
147 void ram_handle_compressed(void *host, uint8_t ch, uint64_t size);
150 * @migrate_add_blocker - prevent migration from proceeding
152 * @reason - an error to be returned whenever migration is attempted
154 void migrate_add_blocker(Error *reason);
157 * @migrate_del_blocker - remove a blocking error from migration
159 * @reason - the error blocking migration
161 void migrate_del_blocker(Error *reason);
163 bool migrate_zero_blocks(void);
165 bool migrate_auto_converge(void);
167 int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
168 uint8_t *dst, int dlen);
169 int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
171 int migrate_use_xbzrle(void);
172 int64_t migrate_xbzrle_cache_size(void);
174 int64_t xbzrle_cache_resize(int64_t new_size);
176 bool migrate_use_compression(void);
177 int migrate_compress_level(void);
178 int migrate_compress_threads(void);
179 int migrate_decompress_threads(void);
180 bool migrate_use_events(void);
182 void ram_control_before_iterate(QEMUFile *f, uint64_t flags);
183 void ram_control_after_iterate(QEMUFile *f, uint64_t flags);
184 void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data);
186 /* Whenever this is found in the data stream, the flags
187 * will be passed to ram_control_load_hook in the incoming-migration
188 * side. This lets before_ram_iterate/after_ram_iterate add
189 * transport-specific sections to the RAM migration data.
191 #define RAM_SAVE_FLAG_HOOK 0x80
193 #define RAM_SAVE_CONTROL_NOT_SUPP -1000
194 #define RAM_SAVE_CONTROL_DELAYED -2000
196 size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
197 ram_addr_t offset, size_t size,
198 uint64_t *bytes_sent);
200 void ram_mig_init(void);
201 void savevm_skip_section_footers(void);
202 void register_global_state(void);
203 void global_state_set_optional(void);
204 void savevm_skip_configuration(void);
205 int global_state_store(void);
206 void global_state_store_running(void);
207 #endif