4 * Copyright IBM, Corp. 2008
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
18 #include "qemu-common.h"
22 #include "qapi-types.h"
24 struct MigrationParams
{
29 typedef struct MigrationState MigrationState
;
33 int64_t bandwidth_limit
;
37 int (*get_error
)(MigrationState
*s
);
38 int (*close
)(MigrationState
*s
);
39 int (*write
)(MigrationState
*s
, const void *buff
, size_t size
);
41 MigrationParams params
;
43 bool enabled_capabilities
[MIGRATION_CAPABILITY_MAX
];
44 int64_t xbzrle_cache_size
;
47 void process_incoming_migration(QEMUFile
*f
);
49 int qemu_start_incoming_migration(const char *uri
, Error
**errp
);
51 uint64_t migrate_max_downtime(void);
53 void do_info_migrate_print(Monitor
*mon
, const QObject
*data
);
55 void do_info_migrate(Monitor
*mon
, QObject
**ret_data
);
57 int exec_start_incoming_migration(const char *host_port
);
59 int exec_start_outgoing_migration(MigrationState
*s
, const char *host_port
);
61 int tcp_start_incoming_migration(const char *host_port
, Error
**errp
);
63 int tcp_start_outgoing_migration(MigrationState
*s
, const char *host_port
,
66 int unix_start_incoming_migration(const char *path
);
68 int unix_start_outgoing_migration(MigrationState
*s
, const char *path
);
70 int fd_start_incoming_migration(const char *path
);
72 int fd_start_outgoing_migration(MigrationState
*s
, const char *fdname
);
74 void migrate_fd_error(MigrationState
*s
);
76 void migrate_fd_connect(MigrationState
*s
);
78 void add_migration_state_change_notifier(Notifier
*notify
);
79 void remove_migration_state_change_notifier(Notifier
*notify
);
80 bool migration_is_active(MigrationState
*);
81 bool migration_has_finished(MigrationState
*);
82 bool migration_has_failed(MigrationState
*);
84 uint64_t ram_bytes_remaining(void);
85 uint64_t ram_bytes_transferred(void);
86 uint64_t ram_bytes_total(void);
88 extern SaveVMHandlers savevm_ram_handlers
;
90 uint64_t dup_mig_bytes_transferred(void);
91 uint64_t dup_mig_pages_transferred(void);
92 uint64_t norm_mig_bytes_transferred(void);
93 uint64_t norm_mig_pages_transferred(void);
94 uint64_t xbzrle_mig_bytes_transferred(void);
95 uint64_t xbzrle_mig_pages_transferred(void);
96 uint64_t xbzrle_mig_pages_overflow(void);
97 uint64_t xbzrle_mig_pages_cache_miss(void);
100 * @migrate_add_blocker - prevent migration from proceeding
102 * @reason - an error to be returned whenever migration is attempted
104 void migrate_add_blocker(Error
*reason
);
107 * @migrate_del_blocker - remove a blocking error from migration
109 * @reason - the error blocking migration
111 void migrate_del_blocker(Error
*reason
);
113 int xbzrle_encode_buffer(uint8_t *old_buf
, uint8_t *new_buf
, int slen
,
114 uint8_t *dst
, int dlen
);
115 int xbzrle_decode_buffer(uint8_t *src
, int slen
, uint8_t *dst
, int dlen
);
117 int migrate_use_xbzrle(void);
118 int64_t migrate_xbzrle_cache_size(void);
120 int64_t xbzrle_cache_resize(int64_t new_size
);