crypto: introduce generic cipher API & built-in implementation
[qemu/ar7.git] / include / migration / migration.h
blob9387c8c9d4a395d6e46e3f5175689b5db2a94f06
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_SECTION_FOOTER 0x7e
39 struct MigrationParams {
40 bool blk;
41 bool shared;
44 typedef struct MigrationState MigrationState;
46 typedef QLIST_HEAD(, LoadStateEntry) LoadStateEntry_Head;
48 /* State for the incoming migration */
49 struct MigrationIncomingState {
50 QEMUFile *file;
52 /* See savevm.c */
53 LoadStateEntry_Head loadvm_handlers;
56 MigrationIncomingState *migration_incoming_get_current(void);
57 MigrationIncomingState *migration_incoming_state_new(QEMUFile *f);
58 void migration_incoming_state_destroy(void);
60 struct MigrationState
62 int64_t bandwidth_limit;
63 size_t bytes_xfer;
64 size_t xfer_limit;
65 QemuThread thread;
66 QEMUBH *cleanup_bh;
67 QEMUFile *file;
68 int parameters[MIGRATION_PARAMETER_MAX];
70 int state;
71 MigrationParams params;
72 double mbps;
73 int64_t total_time;
74 int64_t downtime;
75 int64_t expected_downtime;
76 int64_t dirty_pages_rate;
77 int64_t dirty_bytes_rate;
78 bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
79 int64_t xbzrle_cache_size;
80 int64_t setup_time;
81 int64_t dirty_sync_count;
84 void process_incoming_migration(QEMUFile *f);
86 void qemu_start_incoming_migration(const char *uri, Error **errp);
88 uint64_t migrate_max_downtime(void);
90 void exec_start_incoming_migration(const char *host_port, Error **errp);
92 void exec_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
94 void tcp_start_incoming_migration(const char *host_port, Error **errp);
96 void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
98 void unix_start_incoming_migration(const char *path, Error **errp);
100 void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp);
102 void fd_start_incoming_migration(const char *path, Error **errp);
104 void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp);
106 void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp);
108 void rdma_start_incoming_migration(const char *host_port, Error **errp);
110 void migrate_fd_error(MigrationState *s);
112 void migrate_fd_connect(MigrationState *s);
114 int migrate_fd_close(MigrationState *s);
116 void add_migration_state_change_notifier(Notifier *notify);
117 void remove_migration_state_change_notifier(Notifier *notify);
118 bool migration_in_setup(MigrationState *);
119 bool migration_has_finished(MigrationState *);
120 bool migration_has_failed(MigrationState *);
121 MigrationState *migrate_get_current(void);
123 void migrate_compress_threads_create(void);
124 void migrate_compress_threads_join(void);
125 void migrate_decompress_threads_create(void);
126 void migrate_decompress_threads_join(void);
127 uint64_t ram_bytes_remaining(void);
128 uint64_t ram_bytes_transferred(void);
129 uint64_t ram_bytes_total(void);
130 void free_xbzrle_decoded_buf(void);
132 void acct_update_position(QEMUFile *f, size_t size, bool zero);
134 uint64_t dup_mig_bytes_transferred(void);
135 uint64_t dup_mig_pages_transferred(void);
136 uint64_t skipped_mig_bytes_transferred(void);
137 uint64_t skipped_mig_pages_transferred(void);
138 uint64_t norm_mig_bytes_transferred(void);
139 uint64_t norm_mig_pages_transferred(void);
140 uint64_t xbzrle_mig_bytes_transferred(void);
141 uint64_t xbzrle_mig_pages_transferred(void);
142 uint64_t xbzrle_mig_pages_overflow(void);
143 uint64_t xbzrle_mig_pages_cache_miss(void);
144 double xbzrle_mig_cache_miss_rate(void);
146 void ram_handle_compressed(void *host, uint8_t ch, uint64_t size);
149 * @migrate_add_blocker - prevent migration from proceeding
151 * @reason - an error to be returned whenever migration is attempted
153 void migrate_add_blocker(Error *reason);
156 * @migrate_del_blocker - remove a blocking error from migration
158 * @reason - the error blocking migration
160 void migrate_del_blocker(Error *reason);
162 bool migrate_zero_blocks(void);
164 bool migrate_auto_converge(void);
166 int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
167 uint8_t *dst, int dlen);
168 int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
170 int migrate_use_xbzrle(void);
171 int64_t migrate_xbzrle_cache_size(void);
173 int64_t xbzrle_cache_resize(int64_t new_size);
175 bool migrate_use_compression(void);
176 int migrate_compress_level(void);
177 int migrate_compress_threads(void);
178 int migrate_decompress_threads(void);
180 void ram_control_before_iterate(QEMUFile *f, uint64_t flags);
181 void ram_control_after_iterate(QEMUFile *f, uint64_t flags);
182 void ram_control_load_hook(QEMUFile *f, uint64_t flags);
184 /* Whenever this is found in the data stream, the flags
185 * will be passed to ram_control_load_hook in the incoming-migration
186 * side. This lets before_ram_iterate/after_ram_iterate add
187 * transport-specific sections to the RAM migration data.
189 #define RAM_SAVE_FLAG_HOOK 0x80
191 #define RAM_SAVE_CONTROL_NOT_SUPP -1000
192 #define RAM_SAVE_CONTROL_DELAYED -2000
194 size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
195 ram_addr_t offset, size_t size,
196 uint64_t *bytes_sent);
198 void ram_mig_init(void);
199 void savevm_skip_section_footers(void);
200 #endif