Provide init function for ram migration
[qemu/ar7.git] / include / migration / migration.h
blob31fbf174d210e143427587ad28fb53c2e677ac20
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
37 struct MigrationParams {
38 bool blk;
39 bool shared;
42 typedef struct MigrationState MigrationState;
44 struct MigrationState
46 int64_t bandwidth_limit;
47 size_t bytes_xfer;
48 size_t xfer_limit;
49 QemuThread thread;
50 QEMUBH *cleanup_bh;
51 QEMUFile *file;
53 int state;
54 MigrationParams params;
55 double mbps;
56 int64_t total_time;
57 int64_t downtime;
58 int64_t expected_downtime;
59 int64_t dirty_pages_rate;
60 int64_t dirty_bytes_rate;
61 bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
62 int64_t xbzrle_cache_size;
63 int64_t setup_time;
66 void process_incoming_migration(QEMUFile *f);
68 void qemu_start_incoming_migration(const char *uri, Error **errp);
70 uint64_t migrate_max_downtime(void);
72 void do_info_migrate_print(Monitor *mon, const QObject *data);
74 void do_info_migrate(Monitor *mon, QObject **ret_data);
76 void exec_start_incoming_migration(const char *host_port, Error **errp);
78 void exec_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
80 void tcp_start_incoming_migration(const char *host_port, Error **errp);
82 void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
84 void unix_start_incoming_migration(const char *path, Error **errp);
86 void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp);
88 void fd_start_incoming_migration(const char *path, Error **errp);
90 void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp);
92 void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp);
94 void rdma_start_incoming_migration(const char *host_port, Error **errp);
96 void migrate_fd_error(MigrationState *s);
98 void migrate_fd_connect(MigrationState *s);
100 int migrate_fd_close(MigrationState *s);
102 void add_migration_state_change_notifier(Notifier *notify);
103 void remove_migration_state_change_notifier(Notifier *notify);
104 bool migration_in_setup(MigrationState *);
105 bool migration_has_finished(MigrationState *);
106 bool migration_has_failed(MigrationState *);
107 MigrationState *migrate_get_current(void);
109 uint64_t ram_bytes_remaining(void);
110 uint64_t ram_bytes_transferred(void);
111 uint64_t ram_bytes_total(void);
112 void free_xbzrle_decoded_buf(void);
114 void acct_update_position(QEMUFile *f, size_t size, bool zero);
116 uint64_t dup_mig_bytes_transferred(void);
117 uint64_t dup_mig_pages_transferred(void);
118 uint64_t skipped_mig_bytes_transferred(void);
119 uint64_t skipped_mig_pages_transferred(void);
120 uint64_t norm_mig_bytes_transferred(void);
121 uint64_t norm_mig_pages_transferred(void);
122 uint64_t xbzrle_mig_bytes_transferred(void);
123 uint64_t xbzrle_mig_pages_transferred(void);
124 uint64_t xbzrle_mig_pages_overflow(void);
125 uint64_t xbzrle_mig_pages_cache_miss(void);
127 void ram_handle_compressed(void *host, uint8_t ch, uint64_t size);
130 * @migrate_add_blocker - prevent migration from proceeding
132 * @reason - an error to be returned whenever migration is attempted
134 void migrate_add_blocker(Error *reason);
137 * @migrate_del_blocker - remove a blocking error from migration
139 * @reason - the error blocking migration
141 void migrate_del_blocker(Error *reason);
143 bool migrate_rdma_pin_all(void);
144 bool migrate_zero_blocks(void);
146 bool migrate_auto_converge(void);
148 int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
149 uint8_t *dst, int dlen);
150 int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
152 int migrate_use_xbzrle(void);
153 int64_t migrate_xbzrle_cache_size(void);
155 int64_t xbzrle_cache_resize(int64_t new_size);
157 void ram_control_before_iterate(QEMUFile *f, uint64_t flags);
158 void ram_control_after_iterate(QEMUFile *f, uint64_t flags);
159 void ram_control_load_hook(QEMUFile *f, uint64_t flags);
161 /* Whenever this is found in the data stream, the flags
162 * will be passed to ram_control_load_hook in the incoming-migration
163 * side. This lets before_ram_iterate/after_ram_iterate add
164 * transport-specific sections to the RAM migration data.
166 #define RAM_SAVE_FLAG_HOOK 0x80
168 #define RAM_SAVE_CONTROL_NOT_SUPP -1000
169 #define RAM_SAVE_CONTROL_DELAYED -2000
171 size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
172 ram_addr_t offset, size_t size,
173 int *bytes_sent);
175 #endif