numa: add -numa node,memdev= option
[qemu.git] / include / migration / migration.h
1 /*
2 * QEMU live migration
3 *
4 * Copyright IBM, Corp. 2008
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
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
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"
25
26 #define QEMU_VM_FILE_MAGIC 0x5145564d
27 #define QEMU_VM_FILE_VERSION_COMPAT 0x00000002
28 #define QEMU_VM_FILE_VERSION 0x00000003
29
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
37 struct MigrationParams {
38 bool blk;
39 bool shared;
40 };
41
42 typedef struct MigrationState MigrationState;
43
44 struct MigrationState
45 {
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;
52
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;
64 int64_t dirty_sync_count;
65 };
66
67 void process_incoming_migration(QEMUFile *f);
68
69 void qemu_start_incoming_migration(const char *uri, Error **errp);
70
71 uint64_t migrate_max_downtime(void);
72
73 void do_info_migrate_print(Monitor *mon, const QObject *data);
74
75 void do_info_migrate(Monitor *mon, QObject **ret_data);
76
77 void exec_start_incoming_migration(const char *host_port, Error **errp);
78
79 void exec_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
80
81 void tcp_start_incoming_migration(const char *host_port, Error **errp);
82
83 void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
84
85 void unix_start_incoming_migration(const char *path, Error **errp);
86
87 void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp);
88
89 void fd_start_incoming_migration(const char *path, Error **errp);
90
91 void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp);
92
93 void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp);
94
95 void rdma_start_incoming_migration(const char *host_port, Error **errp);
96
97 void migrate_fd_error(MigrationState *s);
98
99 void migrate_fd_connect(MigrationState *s);
100
101 int migrate_fd_close(MigrationState *s);
102
103 void add_migration_state_change_notifier(Notifier *notify);
104 void remove_migration_state_change_notifier(Notifier *notify);
105 bool migration_in_setup(MigrationState *);
106 bool migration_has_finished(MigrationState *);
107 bool migration_has_failed(MigrationState *);
108 MigrationState *migrate_get_current(void);
109
110 uint64_t ram_bytes_remaining(void);
111 uint64_t ram_bytes_transferred(void);
112 uint64_t ram_bytes_total(void);
113 void free_xbzrle_decoded_buf(void);
114
115 void acct_update_position(QEMUFile *f, size_t size, bool zero);
116
117 uint64_t dup_mig_bytes_transferred(void);
118 uint64_t dup_mig_pages_transferred(void);
119 uint64_t skipped_mig_bytes_transferred(void);
120 uint64_t skipped_mig_pages_transferred(void);
121 uint64_t norm_mig_bytes_transferred(void);
122 uint64_t norm_mig_pages_transferred(void);
123 uint64_t xbzrle_mig_bytes_transferred(void);
124 uint64_t xbzrle_mig_pages_transferred(void);
125 uint64_t xbzrle_mig_pages_overflow(void);
126 uint64_t xbzrle_mig_pages_cache_miss(void);
127 double xbzrle_mig_cache_miss_rate(void);
128
129 void ram_handle_compressed(void *host, uint8_t ch, uint64_t size);
130
131 /**
132 * @migrate_add_blocker - prevent migration from proceeding
133 *
134 * @reason - an error to be returned whenever migration is attempted
135 */
136 void migrate_add_blocker(Error *reason);
137
138 /**
139 * @migrate_del_blocker - remove a blocking error from migration
140 *
141 * @reason - the error blocking migration
142 */
143 void migrate_del_blocker(Error *reason);
144
145 bool migrate_rdma_pin_all(void);
146 bool migrate_zero_blocks(void);
147
148 bool migrate_auto_converge(void);
149
150 int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
151 uint8_t *dst, int dlen);
152 int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
153
154 int migrate_use_xbzrle(void);
155 int64_t migrate_xbzrle_cache_size(void);
156
157 int64_t xbzrle_cache_resize(int64_t new_size);
158
159 void ram_control_before_iterate(QEMUFile *f, uint64_t flags);
160 void ram_control_after_iterate(QEMUFile *f, uint64_t flags);
161 void ram_control_load_hook(QEMUFile *f, uint64_t flags);
162
163 /* Whenever this is found in the data stream, the flags
164 * will be passed to ram_control_load_hook in the incoming-migration
165 * side. This lets before_ram_iterate/after_ram_iterate add
166 * transport-specific sections to the RAM migration data.
167 */
168 #define RAM_SAVE_FLAG_HOOK 0x80
169
170 #define RAM_SAVE_CONTROL_NOT_SUPP -1000
171 #define RAM_SAVE_CONTROL_DELAYED -2000
172
173 size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
174 ram_addr_t offset, size_t size,
175 int *bytes_sent);
176
177 #endif