1 /*
2  * qemu_migration_params.h: QEMU migration parameters handling
3  *
4  * Copyright (C) 2006-2018 Red Hat, Inc.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library.  If not, see
18  * <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #pragma once
23 
24 #include "internal.h"
25 
26 #include "virbuffer.h"
27 #include "virxml.h"
28 #include "qemu_monitor.h"
29 #include "qemu_conf.h"
30 #include "virenum.h"
31 
32 typedef enum {
33     QEMU_MIGRATION_CAP_XBZRLE,
34     QEMU_MIGRATION_CAP_AUTO_CONVERGE,
35     QEMU_MIGRATION_CAP_RDMA_PIN_ALL,
36     QEMU_MIGRATION_CAP_EVENTS,
37     QEMU_MIGRATION_CAP_POSTCOPY,
38     QEMU_MIGRATION_CAP_COMPRESS,
39     QEMU_MIGRATION_CAP_PAUSE_BEFORE_SWITCHOVER,
40     QEMU_MIGRATION_CAP_LATE_BLOCK_ACTIVATE,
41     QEMU_MIGRATION_CAP_MULTIFD,
42     QEMU_MIGRATION_CAP_BLOCK_DIRTY_BITMAPS,
43 
44     QEMU_MIGRATION_CAP_LAST
45 } qemuMigrationCapability;
46 VIR_ENUM_DECL(qemuMigrationCapability);
47 
48 typedef enum {
49     QEMU_MIGRATION_PARAM_COMPRESS_LEVEL,
50     QEMU_MIGRATION_PARAM_COMPRESS_THREADS,
51     QEMU_MIGRATION_PARAM_DECOMPRESS_THREADS,
52     QEMU_MIGRATION_PARAM_THROTTLE_INITIAL,
53     QEMU_MIGRATION_PARAM_THROTTLE_INCREMENT,
54     QEMU_MIGRATION_PARAM_TLS_CREDS,
55     QEMU_MIGRATION_PARAM_TLS_HOSTNAME,
56     QEMU_MIGRATION_PARAM_MAX_BANDWIDTH,
57     QEMU_MIGRATION_PARAM_DOWNTIME_LIMIT,
58     QEMU_MIGRATION_PARAM_BLOCK_INCREMENTAL,
59     QEMU_MIGRATION_PARAM_XBZRLE_CACHE_SIZE,
60     QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH,
61     QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS,
62 
63     QEMU_MIGRATION_PARAM_LAST
64 } qemuMigrationParam;
65 
66 typedef struct _qemuMigrationParams qemuMigrationParams;
67 
68 typedef enum {
69     QEMU_MIGRATION_SOURCE = (1 << 0),
70     QEMU_MIGRATION_DESTINATION = (1 << 1),
71 } qemuMigrationParty;
72 
73 
74 virBitmap *
75 qemuMigrationParamsGetAlwaysOnCaps(qemuMigrationParty party);
76 
77 qemuMigrationParams *
78 qemuMigrationParamsFromFlags(virTypedParameterPtr params,
79                              int nparams,
80                              unsigned long flags,
81                              qemuMigrationParty party);
82 
83 int
84 qemuMigrationParamsDump(qemuMigrationParams *migParams,
85                         virTypedParameterPtr *params,
86                         int *nparams,
87                         int *maxparams,
88                         unsigned long *flags);
89 
90 qemuMigrationParams *
91 qemuMigrationParamsNew(void);
92 
93 void
94 qemuMigrationParamsFree(qemuMigrationParams *migParams);
95 G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMigrationParams, qemuMigrationParamsFree);
96 
97 int
98 qemuMigrationParamsApply(virQEMUDriver *driver,
99                          virDomainObj *vm,
100                          int asyncJob,
101                          qemuMigrationParams *migParams);
102 
103 int
104 qemuMigrationParamsEnableTLS(virQEMUDriver *driver,
105                              virDomainObj *vm,
106                              bool tlsListen,
107                              int asyncJob,
108                              char **tlsAlias,
109                              const char *hostname,
110                              qemuMigrationParams *migParams);
111 
112 int
113 qemuMigrationParamsDisableTLS(virDomainObj *vm,
114                               qemuMigrationParams *migParams);
115 
116 bool
117 qemuMigrationParamsTLSHostnameIsSet(qemuMigrationParams *migParams);
118 
119 int
120 qemuMigrationParamsFetch(virQEMUDriver *driver,
121                          virDomainObj *vm,
122                          int asyncJob,
123                          qemuMigrationParams **migParams);
124 
125 int
126 qemuMigrationParamsSetULL(qemuMigrationParams *migParams,
127                           qemuMigrationParam param,
128                           unsigned long long value);
129 
130 int
131 qemuMigrationParamsGetULL(qemuMigrationParams *migParams,
132                           qemuMigrationParam param,
133                           unsigned long long *value);
134 
135 void
136 qemuMigrationParamsSetBlockDirtyBitmapMapping(qemuMigrationParams *migParams,
137                                               virJSONValue **params);
138 
139 int
140 qemuMigrationParamsCheck(virQEMUDriver *driver,
141                          virDomainObj *vm,
142                          int asyncJob,
143                          qemuMigrationParams *migParams,
144                          virBitmap *remoteCaps);
145 
146 void
147 qemuMigrationParamsReset(virQEMUDriver *driver,
148                          virDomainObj *vm,
149                          int asyncJob,
150                          qemuMigrationParams *origParams,
151                          unsigned long apiFlags);
152 
153 void
154 qemuMigrationParamsFormat(virBuffer *buf,
155                           qemuMigrationParams *migParams);
156 
157 int
158 qemuMigrationParamsParse(xmlXPathContextPtr ctxt,
159                          qemuMigrationParams **migParams);
160 
161 int
162 qemuMigrationCapsCheck(virQEMUDriver *driver,
163                        virDomainObj *vm,
164                        int asyncJob);
165 
166 bool
167 qemuMigrationCapsGet(virDomainObj *vm,
168                      qemuMigrationCapability cap);
169