MAINTAINERS: add entry for virtio-rng
[qemu/ar7.git] / include / migration / migration.h
blob3cb5ba80c3f17a6ccf3d54389d10a4920219a77f
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;
64 int64_t dirty_sync_count;
67 void process_incoming_migration(QEMUFile *f);
69 void qemu_start_incoming_migration(const char *uri, Error **errp);
71 uint64_t migrate_max_downtime(void);
73 void do_info_migrate_print(Monitor *mon, const QObject *data);
75 void do_info_migrate(Monitor *mon, QObject **ret_data);
77 void exec_start_incoming_migration(const char *host_port, Error **errp);
79 void exec_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
81 void tcp_start_incoming_migration(const char *host_port, Error **errp);
83 void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
85 void unix_start_incoming_migration(const char *path, Error **errp);
87 void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp);
89 void fd_start_incoming_migration(const char *path, Error **errp);
91 void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp);
93 void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp);
95 void rdma_start_incoming_migration(const char *host_port, Error **errp);
97 void migrate_fd_error(MigrationState *s);
99 void migrate_fd_connect(MigrationState *s);
101 int migrate_fd_close(MigrationState *s);
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);
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);
115 void acct_update_position(QEMUFile *f, size_t size, bool zero);
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);
129 void ram_handle_compressed(void *host, uint8_t ch, uint64_t size);
132 * @migrate_add_blocker - prevent migration from proceeding
134 * @reason - an error to be returned whenever migration is attempted
136 void migrate_add_blocker(Error *reason);
139 * @migrate_del_blocker - remove a blocking error from migration
141 * @reason - the error blocking migration
143 void migrate_del_blocker(Error *reason);
145 bool migrate_rdma_pin_all(void);
146 bool migrate_zero_blocks(void);
148 bool migrate_auto_converge(void);
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);
154 int migrate_use_xbzrle(void);
155 int64_t migrate_xbzrle_cache_size(void);
157 int64_t xbzrle_cache_resize(int64_t new_size);
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);
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.
168 #define RAM_SAVE_FLAG_HOOK 0x80
170 #define RAM_SAVE_CONTROL_NOT_SUPP -1000
171 #define RAM_SAVE_CONTROL_DELAYED -2000
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);
177 #endif