migration.h 2.9 KB
Newer Older
A
aliguori 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * QEMU live migration
 *
 * Copyright IBM, Corp. 2008
 *
 * Authors:
 *  Anthony Liguori   <aliguori@us.ibm.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2.  See
 * the COPYING file in the top-level directory.
 *
 */

#ifndef QEMU_MIGRATION_H
#define QEMU_MIGRATION_H

17
#include "qdict.h"
A
aliguori 已提交
18
#include "qemu-common.h"
19
#include "notify.h"
A
Anthony Liguori 已提交
20
#include "error.h"
21
#include "vmstate.h"
O
Orit Wasserman 已提交
22
#include "qapi-types.h"
A
aliguori 已提交
23

I
Isaku Yamahata 已提交
24 25 26 27 28
struct MigrationParams {
    bool blk;
    bool shared;
};

29
typedef struct MigrationState MigrationState;
30

31
struct MigrationState
32 33 34 35 36
{
    int64_t bandwidth_limit;
    QEMUFile *file;
    int fd;
    int state;
37 38 39
    int (*get_error)(MigrationState *s);
    int (*close)(MigrationState *s);
    int (*write)(MigrationState *s, const void *buff, size_t size);
40
    void *opaque;
I
Isaku Yamahata 已提交
41
    MigrationParams params;
J
Juan Quintela 已提交
42
    int64_t total_time;
O
Orit Wasserman 已提交
43
    bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
44
    int64_t xbzrle_cache_size;
45 46
};

47 48
void process_incoming_migration(QEMUFile *f);

49
int qemu_start_incoming_migration(const char *uri, Error **errp);
A
aliguori 已提交
50

51 52
uint64_t migrate_max_downtime(void);

53 54 55
void do_info_migrate_print(Monitor *mon, const QObject *data);

void do_info_migrate(Monitor *mon, QObject **ret_data);
A
aliguori 已提交
56

57 58
int exec_start_incoming_migration(const char *host_port);

59
int exec_start_outgoing_migration(MigrationState *s, const char *host_port);
60

61
int tcp_start_incoming_migration(const char *host_port, Error **errp);
A
aliguori 已提交
62

63 64
int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
                                 Error **errp);
A
aliguori 已提交
65

C
Chris Lalancette 已提交
66 67
int unix_start_incoming_migration(const char *path);

68
int unix_start_outgoing_migration(MigrationState *s, const char *path);
C
Chris Lalancette 已提交
69

P
Paolo Bonzini 已提交
70 71
int fd_start_incoming_migration(const char *path);

72
int fd_start_outgoing_migration(MigrationState *s, const char *fdname);
P
Paolo Bonzini 已提交
73

74
void migrate_fd_error(MigrationState *s);
75

76
void migrate_fd_connect(MigrationState *s);
77

78 79
void add_migration_state_change_notifier(Notifier *notify);
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 *);
83

84 85 86 87
uint64_t ram_bytes_remaining(void);
uint64_t ram_bytes_transferred(void);
uint64_t ram_bytes_total(void);

88
extern SaveVMHandlers savevm_ram_handlers;
89

A
Anthony Liguori 已提交
90 91 92 93 94 95 96 97 98 99 100 101 102 103
/**
 * @migrate_add_blocker - prevent migration from proceeding
 *
 * @reason - an error to be returned whenever migration is attempted
 */
void migrate_add_blocker(Error *reason);

/**
 * @migrate_del_blocker - remove a blocking error from migration
 *
 * @reason - the error blocking migration
 */
void migrate_del_blocker(Error *reason);

104 105 106 107
int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
                         uint8_t *dst, int dlen);
int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);

108 109 110
int migrate_use_xbzrle(void);
int64_t migrate_xbzrle_cache_size(void);

111 112
int64_t xbzrle_cache_resize(int64_t new_size);

A
aliguori 已提交
113
#endif