]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | }; | |
65 | ||
66 | void process_incoming_migration(QEMUFile *f); | |
67 | ||
68 | void qemu_start_incoming_migration(const char *uri, Error **errp); | |
69 | ||
70 | uint64_t migrate_max_downtime(void); | |
71 | ||
72 | void do_info_migrate_print(Monitor *mon, const QObject *data); | |
73 | ||
74 | void do_info_migrate(Monitor *mon, QObject **ret_data); | |
75 | ||
76 | void exec_start_incoming_migration(const char *host_port, Error **errp); | |
77 | ||
78 | void exec_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp); | |
79 | ||
80 | void tcp_start_incoming_migration(const char *host_port, Error **errp); | |
81 | ||
82 | void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp); | |
83 | ||
84 | void unix_start_incoming_migration(const char *path, Error **errp); | |
85 | ||
86 | void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp); | |
87 | ||
88 | void fd_start_incoming_migration(const char *path, Error **errp); | |
89 | ||
90 | void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp); | |
91 | ||
92 | void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp); | |
93 | ||
94 | void rdma_start_incoming_migration(const char *host_port, Error **errp); | |
95 | ||
96 | void migrate_fd_error(MigrationState *s); | |
97 | ||
98 | void migrate_fd_connect(MigrationState *s); | |
99 | ||
100 | int migrate_fd_close(MigrationState *s); | |
101 | ||
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); | |
108 | ||
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); | |
113 | ||
114 | void acct_update_position(QEMUFile *f, size_t size, bool zero); | |
115 | ||
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); | |
126 | ||
127 | void ram_handle_compressed(void *host, uint8_t ch, uint64_t size); | |
128 | ||
129 | /** | |
130 | * @migrate_add_blocker - prevent migration from proceeding | |
131 | * | |
132 | * @reason - an error to be returned whenever migration is attempted | |
133 | */ | |
134 | void migrate_add_blocker(Error *reason); | |
135 | ||
136 | /** | |
137 | * @migrate_del_blocker - remove a blocking error from migration | |
138 | * | |
139 | * @reason - the error blocking migration | |
140 | */ | |
141 | void migrate_del_blocker(Error *reason); | |
142 | ||
143 | bool migrate_rdma_pin_all(void); | |
144 | bool migrate_zero_blocks(void); | |
145 | ||
146 | bool migrate_auto_converge(void); | |
147 | ||
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); | |
151 | ||
152 | int migrate_use_xbzrle(void); | |
153 | int64_t migrate_xbzrle_cache_size(void); | |
154 | ||
155 | int64_t xbzrle_cache_resize(int64_t new_size); | |
156 | ||
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); | |
160 | ||
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. | |
165 | */ | |
166 | #define RAM_SAVE_FLAG_HOOK 0x80 | |
167 | ||
168 | #define RAM_SAVE_CONTROL_NOT_SUPP -1000 | |
169 | #define RAM_SAVE_CONTROL_DELAYED -2000 | |
170 | ||
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); | |
174 | ||
175 | #endif |