qemu_migration.h 8.2 KB
Newer Older
1 2 3
/*
 * qemu_migration.h: QEMU migration handling
 *
4
 * Copyright (C) 2006-2011, 2014 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library.  If not, see
O
Osier Yang 已提交
18
 * <http://www.gnu.org/licenses/>.
19 20 21 22 23 24 25
 *
 */

#ifndef __QEMU_MIGRATION_H__
# define __QEMU_MIGRATION_H__

# include "qemu_conf.h"
26
# include "qemu_domain.h"
27

28 29 30 31 32 33 34 35 36
/* All supported qemu migration flags.  */
# define QEMU_MIGRATION_FLAGS                   \
    (VIR_MIGRATE_LIVE |                         \
     VIR_MIGRATE_PEER2PEER |                    \
     VIR_MIGRATE_TUNNELLED |                    \
     VIR_MIGRATE_PERSIST_DEST |                 \
     VIR_MIGRATE_UNDEFINE_SOURCE |              \
     VIR_MIGRATE_PAUSED |                       \
     VIR_MIGRATE_NON_SHARED_DISK |              \
37
     VIR_MIGRATE_NON_SHARED_INC |               \
38
     VIR_MIGRATE_CHANGE_PROTECTION |            \
L
liguang 已提交
39
     VIR_MIGRATE_UNSAFE |                       \
40
     VIR_MIGRATE_OFFLINE |                      \
41
     VIR_MIGRATE_COMPRESSED |                   \
42
     VIR_MIGRATE_ABORT_ON_ERROR |               \
43 44
     VIR_MIGRATE_AUTO_CONVERGE |                \
     VIR_MIGRATE_RDMA_PIN_ALL)
45

46
/* All supported migration parameters and their types. */
47 48 49 50 51 52 53 54 55
# define QEMU_MIGRATION_PARAMETERS                                \
    VIR_MIGRATE_PARAM_URI,              VIR_TYPED_PARAM_STRING,   \
    VIR_MIGRATE_PARAM_DEST_NAME,        VIR_TYPED_PARAM_STRING,   \
    VIR_MIGRATE_PARAM_DEST_XML,         VIR_TYPED_PARAM_STRING,   \
    VIR_MIGRATE_PARAM_BANDWIDTH,        VIR_TYPED_PARAM_ULLONG,   \
    VIR_MIGRATE_PARAM_GRAPHICS_URI,     VIR_TYPED_PARAM_STRING,   \
    VIR_MIGRATE_PARAM_LISTEN_ADDRESS,   VIR_TYPED_PARAM_STRING,   \
    VIR_MIGRATE_PARAM_MIGRATE_DISKS,    VIR_TYPED_PARAM_STRING |  \
                                        VIR_TYPED_PARAM_MULTIPLE, \
56 57 58
    NULL


59
typedef enum {
60 61 62 63 64 65 66 67 68 69 70 71
    QEMU_MIGRATION_PHASE_NONE = 0,
    QEMU_MIGRATION_PHASE_PERFORM2,
    QEMU_MIGRATION_PHASE_BEGIN3,
    QEMU_MIGRATION_PHASE_PERFORM3,
    QEMU_MIGRATION_PHASE_PERFORM3_DONE,
    QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED,
    QEMU_MIGRATION_PHASE_CONFIRM3,
    QEMU_MIGRATION_PHASE_PREPARE,
    QEMU_MIGRATION_PHASE_FINISH2,
    QEMU_MIGRATION_PHASE_FINISH3,

    QEMU_MIGRATION_PHASE_LAST
72
} qemuMigrationJobPhase;
73 74
VIR_ENUM_DECL(qemuMigrationJobPhase)

75
int qemuMigrationJobStart(virQEMUDriverPtr driver,
76
                          virDomainObjPtr vm,
77
                          qemuDomainAsyncJob job)
78
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
79
void qemuMigrationJobSetPhase(virQEMUDriverPtr driver,
80
                              virDomainObjPtr vm,
81
                              qemuMigrationJobPhase phase)
82
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
83
void qemuMigrationJobStartPhase(virQEMUDriverPtr driver,
84
                                virDomainObjPtr vm,
85
                                qemuMigrationJobPhase phase)
86
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
87 88
void qemuMigrationJobContinue(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
89
bool qemuMigrationJobIsActive(virDomainObjPtr vm,
90
                              qemuDomainAsyncJob job)
91
    ATTRIBUTE_NONNULL(1);
92 93
void qemuMigrationJobFinish(virQEMUDriverPtr driver, virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
94

95
int qemuMigrationSetOffline(virQEMUDriverPtr driver,
96 97
                            virDomainObjPtr vm);

98
char *qemuMigrationBegin(virConnectPtr conn,
99
                         virDomainObjPtr vm,
100
                         const char *xmlin,
101
                         const char *dname,
102
                         char **cookieout,
103
                         int *cookieoutlen,
104 105
                         size_t nmigrate_disks,
                         const char **migrate_disks,
106
                         unsigned long flags);
107

108 109
virDomainDefPtr qemuMigrationPrepareDef(virQEMUDriverPtr driver,
                                        const char *dom_xml,
110 111
                                        const char *dname,
                                        char **origname);
112

113
int qemuMigrationPrepareTunnel(virQEMUDriverPtr driver,
114
                               virConnectPtr dconn,
115 116 117 118
                               const char *cookiein,
                               int cookieinlen,
                               char **cookieout,
                               int *cookieoutlen,
119
                               virStreamPtr st,
120
                               virDomainDefPtr *def,
121
                               const char *origname,
L
liguang 已提交
122
                               unsigned long flags);
123

124
int qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
125
                               virConnectPtr dconn,
126 127 128 129
                               const char *cookiein,
                               int cookieinlen,
                               char **cookieout,
                               int *cookieoutlen,
130 131
                               const char *uri_in,
                               char **uri_out,
132
                               virDomainDefPtr *def,
133
                               const char *origname,
134
                               const char *listenAddress,
135 136
                               size_t nmigrate_disks,
                               const char **migrate_disks,
L
liguang 已提交
137
                               unsigned long flags);
138

139
int qemuMigrationPerform(virQEMUDriverPtr driver,
140 141
                         virConnectPtr conn,
                         virDomainObjPtr vm,
142
                         const char *xmlin,
143
                         const char *dconnuri,
144
                         const char *uri,
145
                         const char *graphicsuri,
146
                         const char *listenAddress,
147 148
                         size_t nmigrate_disks,
                         const char **migrate_disks,
149 150 151 152
                         const char *cookiein,
                         int cookieinlen,
                         char **cookieout,
                         int *cookieoutlen,
153 154
                         unsigned long flags,
                         const char *dname,
155
                         unsigned long resource,
156
                         bool v3proto);
157

158
virDomainPtr qemuMigrationFinish(virQEMUDriverPtr driver,
159 160
                                 virConnectPtr dconn,
                                 virDomainObjPtr vm,
161 162 163 164
                                 const char *cookiein,
                                 int cookieinlen,
                                 char **cookieout,
                                 int *cookieoutlen,
165
                                 unsigned long flags,
166 167
                                 int retcode,
                                 bool v3proto);
168

169
int qemuMigrationConfirm(virConnectPtr conn,
170 171 172 173
                         virDomainObjPtr vm,
                         const char *cookiein,
                         int cookieinlen,
                         unsigned int flags,
174
                         int cancelled);
175

176
bool qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
177 178
                            virDomainDefPtr def, bool remote,
                            bool abort_on_error);
179

180
int qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
181 182
                        int fd, off_t offset, const char *path,
                        const char *compressor,
E
Eric Blake 已提交
183
                        bool bypassSecurityDriver,
184
                        qemuDomainAsyncJob asyncJob)
185
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5)
186 187
    ATTRIBUTE_RETURN_CHECK;

188 189 190
int qemuMigrationCancel(virQEMUDriverPtr driver,
                        virDomainObjPtr vm);

191 192 193 194 195
int qemuMigrationFetchJobStatus(virQEMUDriverPtr driver,
                                virDomainObjPtr vm,
                                qemuDomainAsyncJob asyncJob,
                                qemuDomainJobInfoPtr jobInfo);

196
#endif /* __QEMU_MIGRATION_H__ */