migration.h 2.7 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 45
};

46 47
void process_incoming_migration(QEMUFile *f);

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

50 51
uint64_t migrate_max_downtime(void);

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

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

56 57
int exec_start_incoming_migration(const char *host_port);

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

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

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

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

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

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

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

73
void migrate_fd_error(MigrationState *s);
74

75
void migrate_fd_connect(MigrationState *s);
76

77 78
void add_migration_state_change_notifier(Notifier *notify);
void remove_migration_state_change_notifier(Notifier *notify);
79
bool migration_is_active(MigrationState *);
80
bool migration_has_finished(MigrationState *);
81
bool migration_has_failed(MigrationState *);
82

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

87
extern SaveVMHandlers savevm_ram_handlers;
88

A
Anthony Liguori 已提交
89 90 91 92 93 94 95 96 97 98 99 100 101 102
/**
 * @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);

103 104 105 106
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);

A
aliguori 已提交
107
#endif