2 * QEMU migration capabilities
4 * Copyright (c) 2012-2023 Red Hat Inc
7 * Orit Wasserman <owasserm@redhat.com>
8 * Juan Quintela <quintela@redhat.com>
10 * This work is licensed under the terms of the GNU GPL, version 2 or later.
11 * See the COPYING file in the top-level directory.
14 #include "qemu/osdep.h"
15 #include "exec/target_page.h"
16 #include "qapi/clone-visitor.h"
17 #include "qapi/error.h"
18 #include "qapi/qapi-commands-migration.h"
19 #include "qapi/qapi-visit-migration.h"
20 #include "qapi/qmp/qerror.h"
21 #include "qapi/qmp/qnull.h"
22 #include "sysemu/runstate.h"
23 #include "migration/colo.h"
24 #include "migration/misc.h"
25 #include "migration.h"
26 #include "migration-stats.h"
27 #include "qemu-file.h"
30 #include "sysemu/kvm.h"
32 /* Maximum migrate downtime set to 2000 seconds */
33 #define MAX_MIGRATE_DOWNTIME_SECONDS 2000
34 #define MAX_MIGRATE_DOWNTIME (MAX_MIGRATE_DOWNTIME_SECONDS * 1000)
36 #define MAX_THROTTLE (128 << 20) /* Migration transfer speed throttling */
38 /* Time in milliseconds we are allowed to stop the source,
39 * for sending the last part */
40 #define DEFAULT_MIGRATE_SET_DOWNTIME 300
42 /* Default compression thread count */
43 #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8
44 /* Default decompression thread count, usually decompression is at
45 * least 4 times as fast as compression.*/
46 #define DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT 2
47 /*0: means nocompress, 1: best speed, ... 9: best compress ratio */
48 #define DEFAULT_MIGRATE_COMPRESS_LEVEL 1
49 /* Define default autoconverge cpu throttle migration parameters */
50 #define DEFAULT_MIGRATE_THROTTLE_TRIGGER_THRESHOLD 50
51 #define DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL 20
52 #define DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT 10
53 #define DEFAULT_MIGRATE_MAX_CPU_THROTTLE 99
55 /* Migration XBZRLE default cache size */
56 #define DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE (64 * 1024 * 1024)
58 /* The delay time (in ms) between two COLO checkpoints */
59 #define DEFAULT_MIGRATE_X_CHECKPOINT_DELAY (200 * 100)
60 #define DEFAULT_MIGRATE_MULTIFD_CHANNELS 2
61 #define DEFAULT_MIGRATE_MULTIFD_COMPRESSION MULTIFD_COMPRESSION_NONE
62 /* 0: means nocompress, 1: best speed, ... 9: best compress ratio */
63 #define DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL 1
64 /* 0: means nocompress, 1: best speed, ... 20: best compress ratio */
65 #define DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL 1
67 /* Background transfer rate for postcopy, 0 means unlimited, note
68 * that page requests can still exceed this limit.
70 #define DEFAULT_MIGRATE_MAX_POSTCOPY_BANDWIDTH 0
73 * Parameters for self_announce_delay giving a stream of RARP/ARP
74 * packets after migration.
76 #define DEFAULT_MIGRATE_ANNOUNCE_INITIAL 50
77 #define DEFAULT_MIGRATE_ANNOUNCE_MAX 550
78 #define DEFAULT_MIGRATE_ANNOUNCE_ROUNDS 5
79 #define DEFAULT_MIGRATE_ANNOUNCE_STEP 100
81 #define DEFINE_PROP_MIG_CAP(name, x) \
82 DEFINE_PROP_BOOL(name, MigrationState, capabilities[x], false)
84 #define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD 1000 /* milliseconds */
85 #define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT 1 /* MB/s */
87 Property migration_properties
[] = {
88 DEFINE_PROP_BOOL("store-global-state", MigrationState
,
89 store_global_state
, true),
90 DEFINE_PROP_BOOL("send-configuration", MigrationState
,
91 send_configuration
, true),
92 DEFINE_PROP_BOOL("send-section-footer", MigrationState
,
93 send_section_footer
, true),
94 DEFINE_PROP_BOOL("decompress-error-check", MigrationState
,
95 decompress_error_check
, true),
96 DEFINE_PROP_BOOL("multifd-flush-after-each-section", MigrationState
,
97 multifd_flush_after_each_section
, false),
98 DEFINE_PROP_UINT8("x-clear-bitmap-shift", MigrationState
,
99 clear_bitmap_shift
, CLEAR_BITMAP_SHIFT_DEFAULT
),
100 DEFINE_PROP_BOOL("x-preempt-pre-7-2", MigrationState
,
101 preempt_pre_7_2
, false),
103 /* Migration parameters */
104 DEFINE_PROP_UINT8("x-compress-level", MigrationState
,
105 parameters
.compress_level
,
106 DEFAULT_MIGRATE_COMPRESS_LEVEL
),
107 DEFINE_PROP_UINT8("x-compress-threads", MigrationState
,
108 parameters
.compress_threads
,
109 DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT
),
110 DEFINE_PROP_BOOL("x-compress-wait-thread", MigrationState
,
111 parameters
.compress_wait_thread
, true),
112 DEFINE_PROP_UINT8("x-decompress-threads", MigrationState
,
113 parameters
.decompress_threads
,
114 DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT
),
115 DEFINE_PROP_UINT8("x-throttle-trigger-threshold", MigrationState
,
116 parameters
.throttle_trigger_threshold
,
117 DEFAULT_MIGRATE_THROTTLE_TRIGGER_THRESHOLD
),
118 DEFINE_PROP_UINT8("x-cpu-throttle-initial", MigrationState
,
119 parameters
.cpu_throttle_initial
,
120 DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL
),
121 DEFINE_PROP_UINT8("x-cpu-throttle-increment", MigrationState
,
122 parameters
.cpu_throttle_increment
,
123 DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT
),
124 DEFINE_PROP_BOOL("x-cpu-throttle-tailslow", MigrationState
,
125 parameters
.cpu_throttle_tailslow
, false),
126 DEFINE_PROP_SIZE("x-max-bandwidth", MigrationState
,
127 parameters
.max_bandwidth
, MAX_THROTTLE
),
128 DEFINE_PROP_UINT64("x-downtime-limit", MigrationState
,
129 parameters
.downtime_limit
,
130 DEFAULT_MIGRATE_SET_DOWNTIME
),
131 DEFINE_PROP_UINT32("x-checkpoint-delay", MigrationState
,
132 parameters
.x_checkpoint_delay
,
133 DEFAULT_MIGRATE_X_CHECKPOINT_DELAY
),
134 DEFINE_PROP_UINT8("multifd-channels", MigrationState
,
135 parameters
.multifd_channels
,
136 DEFAULT_MIGRATE_MULTIFD_CHANNELS
),
137 DEFINE_PROP_MULTIFD_COMPRESSION("multifd-compression", MigrationState
,
138 parameters
.multifd_compression
,
139 DEFAULT_MIGRATE_MULTIFD_COMPRESSION
),
140 DEFINE_PROP_UINT8("multifd-zlib-level", MigrationState
,
141 parameters
.multifd_zlib_level
,
142 DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL
),
143 DEFINE_PROP_UINT8("multifd-zstd-level", MigrationState
,
144 parameters
.multifd_zstd_level
,
145 DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL
),
146 DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState
,
147 parameters
.xbzrle_cache_size
,
148 DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE
),
149 DEFINE_PROP_SIZE("max-postcopy-bandwidth", MigrationState
,
150 parameters
.max_postcopy_bandwidth
,
151 DEFAULT_MIGRATE_MAX_POSTCOPY_BANDWIDTH
),
152 DEFINE_PROP_UINT8("max-cpu-throttle", MigrationState
,
153 parameters
.max_cpu_throttle
,
154 DEFAULT_MIGRATE_MAX_CPU_THROTTLE
),
155 DEFINE_PROP_SIZE("announce-initial", MigrationState
,
156 parameters
.announce_initial
,
157 DEFAULT_MIGRATE_ANNOUNCE_INITIAL
),
158 DEFINE_PROP_SIZE("announce-max", MigrationState
,
159 parameters
.announce_max
,
160 DEFAULT_MIGRATE_ANNOUNCE_MAX
),
161 DEFINE_PROP_SIZE("announce-rounds", MigrationState
,
162 parameters
.announce_rounds
,
163 DEFAULT_MIGRATE_ANNOUNCE_ROUNDS
),
164 DEFINE_PROP_SIZE("announce-step", MigrationState
,
165 parameters
.announce_step
,
166 DEFAULT_MIGRATE_ANNOUNCE_STEP
),
167 DEFINE_PROP_STRING("tls-creds", MigrationState
, parameters
.tls_creds
),
168 DEFINE_PROP_STRING("tls-hostname", MigrationState
, parameters
.tls_hostname
),
169 DEFINE_PROP_STRING("tls-authz", MigrationState
, parameters
.tls_authz
),
170 DEFINE_PROP_UINT64("x-vcpu-dirty-limit-period", MigrationState
,
171 parameters
.x_vcpu_dirty_limit_period
,
172 DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD
),
173 DEFINE_PROP_UINT64("vcpu-dirty-limit", MigrationState
,
174 parameters
.vcpu_dirty_limit
,
175 DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT
),
177 /* Migration capabilities */
178 DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE
),
179 DEFINE_PROP_MIG_CAP("x-rdma-pin-all", MIGRATION_CAPABILITY_RDMA_PIN_ALL
),
180 DEFINE_PROP_MIG_CAP("x-auto-converge", MIGRATION_CAPABILITY_AUTO_CONVERGE
),
181 DEFINE_PROP_MIG_CAP("x-zero-blocks", MIGRATION_CAPABILITY_ZERO_BLOCKS
),
182 DEFINE_PROP_MIG_CAP("x-compress", MIGRATION_CAPABILITY_COMPRESS
),
183 DEFINE_PROP_MIG_CAP("x-events", MIGRATION_CAPABILITY_EVENTS
),
184 DEFINE_PROP_MIG_CAP("x-postcopy-ram", MIGRATION_CAPABILITY_POSTCOPY_RAM
),
185 DEFINE_PROP_MIG_CAP("x-postcopy-preempt",
186 MIGRATION_CAPABILITY_POSTCOPY_PREEMPT
),
187 DEFINE_PROP_MIG_CAP("x-colo", MIGRATION_CAPABILITY_X_COLO
),
188 DEFINE_PROP_MIG_CAP("x-release-ram", MIGRATION_CAPABILITY_RELEASE_RAM
),
189 DEFINE_PROP_MIG_CAP("x-block", MIGRATION_CAPABILITY_BLOCK
),
190 DEFINE_PROP_MIG_CAP("x-return-path", MIGRATION_CAPABILITY_RETURN_PATH
),
191 DEFINE_PROP_MIG_CAP("x-multifd", MIGRATION_CAPABILITY_MULTIFD
),
192 DEFINE_PROP_MIG_CAP("x-background-snapshot",
193 MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT
),
195 DEFINE_PROP_MIG_CAP("x-zero-copy-send",
196 MIGRATION_CAPABILITY_ZERO_COPY_SEND
),
198 DEFINE_PROP_MIG_CAP("x-switchover-ack",
199 MIGRATION_CAPABILITY_SWITCHOVER_ACK
),
200 DEFINE_PROP_MIG_CAP("x-dirty-limit", MIGRATION_CAPABILITY_DIRTY_LIMIT
),
201 DEFINE_PROP_END_OF_LIST(),
204 bool migrate_auto_converge(void)
206 MigrationState
*s
= migrate_get_current();
208 return s
->capabilities
[MIGRATION_CAPABILITY_AUTO_CONVERGE
];
211 bool migrate_background_snapshot(void)
213 MigrationState
*s
= migrate_get_current();
215 return s
->capabilities
[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT
];
218 bool migrate_block(void)
220 MigrationState
*s
= migrate_get_current();
222 return s
->capabilities
[MIGRATION_CAPABILITY_BLOCK
];
225 bool migrate_colo(void)
227 MigrationState
*s
= migrate_get_current();
229 return s
->capabilities
[MIGRATION_CAPABILITY_X_COLO
];
232 bool migrate_compress(void)
234 MigrationState
*s
= migrate_get_current();
236 return s
->capabilities
[MIGRATION_CAPABILITY_COMPRESS
];
239 bool migrate_dirty_bitmaps(void)
241 MigrationState
*s
= migrate_get_current();
243 return s
->capabilities
[MIGRATION_CAPABILITY_DIRTY_BITMAPS
];
246 bool migrate_dirty_limit(void)
248 MigrationState
*s
= migrate_get_current();
250 return s
->capabilities
[MIGRATION_CAPABILITY_DIRTY_LIMIT
];
253 bool migrate_events(void)
255 MigrationState
*s
= migrate_get_current();
257 return s
->capabilities
[MIGRATION_CAPABILITY_EVENTS
];
260 bool migrate_ignore_shared(void)
262 MigrationState
*s
= migrate_get_current();
264 return s
->capabilities
[MIGRATION_CAPABILITY_X_IGNORE_SHARED
];
267 bool migrate_late_block_activate(void)
269 MigrationState
*s
= migrate_get_current();
271 return s
->capabilities
[MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE
];
274 bool migrate_multifd(void)
276 MigrationState
*s
= migrate_get_current();
278 return s
->capabilities
[MIGRATION_CAPABILITY_MULTIFD
];
281 bool migrate_pause_before_switchover(void)
283 MigrationState
*s
= migrate_get_current();
285 return s
->capabilities
[MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER
];
288 bool migrate_postcopy_blocktime(void)
290 MigrationState
*s
= migrate_get_current();
292 return s
->capabilities
[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME
];
295 bool migrate_postcopy_preempt(void)
297 MigrationState
*s
= migrate_get_current();
299 return s
->capabilities
[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT
];
302 bool migrate_postcopy_ram(void)
304 MigrationState
*s
= migrate_get_current();
306 return s
->capabilities
[MIGRATION_CAPABILITY_POSTCOPY_RAM
];
309 bool migrate_rdma_pin_all(void)
311 MigrationState
*s
= migrate_get_current();
313 return s
->capabilities
[MIGRATION_CAPABILITY_RDMA_PIN_ALL
];
316 bool migrate_release_ram(void)
318 MigrationState
*s
= migrate_get_current();
320 return s
->capabilities
[MIGRATION_CAPABILITY_RELEASE_RAM
];
323 bool migrate_return_path(void)
325 MigrationState
*s
= migrate_get_current();
327 return s
->capabilities
[MIGRATION_CAPABILITY_RETURN_PATH
];
330 bool migrate_switchover_ack(void)
332 MigrationState
*s
= migrate_get_current();
334 return s
->capabilities
[MIGRATION_CAPABILITY_SWITCHOVER_ACK
];
337 bool migrate_validate_uuid(void)
339 MigrationState
*s
= migrate_get_current();
341 return s
->capabilities
[MIGRATION_CAPABILITY_VALIDATE_UUID
];
344 bool migrate_xbzrle(void)
346 MigrationState
*s
= migrate_get_current();
348 return s
->capabilities
[MIGRATION_CAPABILITY_XBZRLE
];
351 bool migrate_zero_blocks(void)
353 MigrationState
*s
= migrate_get_current();
355 return s
->capabilities
[MIGRATION_CAPABILITY_ZERO_BLOCKS
];
358 bool migrate_zero_copy_send(void)
360 MigrationState
*s
= migrate_get_current();
362 return s
->capabilities
[MIGRATION_CAPABILITY_ZERO_COPY_SEND
];
365 /* pseudo capabilities */
367 bool migrate_multifd_flush_after_each_section(void)
369 MigrationState
*s
= migrate_get_current();
371 return s
->multifd_flush_after_each_section
;
374 bool migrate_postcopy(void)
376 return migrate_postcopy_ram() || migrate_dirty_bitmaps();
379 bool migrate_tls(void)
381 MigrationState
*s
= migrate_get_current();
383 return s
->parameters
.tls_creds
&& *s
->parameters
.tls_creds
;
386 typedef enum WriteTrackingSupport
{
387 WT_SUPPORT_UNKNOWN
= 0,
389 WT_SUPPORT_AVAILABLE
,
390 WT_SUPPORT_COMPATIBLE
391 } WriteTrackingSupport
;
394 WriteTrackingSupport
migrate_query_write_tracking(void)
396 /* Check if kernel supports required UFFD features */
397 if (!ram_write_tracking_available()) {
398 return WT_SUPPORT_ABSENT
;
401 * Check if current memory configuration is
402 * compatible with required UFFD features.
404 if (!ram_write_tracking_compatible()) {
405 return WT_SUPPORT_AVAILABLE
;
408 return WT_SUPPORT_COMPATIBLE
;
411 /* Migration capabilities set */
412 struct MigrateCapsSet
{
413 int size
; /* Capability set size */
414 MigrationCapability caps
[]; /* Variadic array of capabilities */
416 typedef struct MigrateCapsSet MigrateCapsSet
;
418 /* Define and initialize MigrateCapsSet */
419 #define INITIALIZE_MIGRATE_CAPS_SET(_name, ...) \
420 MigrateCapsSet _name = { \
421 .size = sizeof((int []) { __VA_ARGS__ }) / sizeof(int), \
422 .caps = { __VA_ARGS__ } \
425 /* Background-snapshot compatibility check list */
427 INITIALIZE_MIGRATE_CAPS_SET(check_caps_background_snapshot
,
428 MIGRATION_CAPABILITY_POSTCOPY_RAM
,
429 MIGRATION_CAPABILITY_DIRTY_BITMAPS
,
430 MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME
,
431 MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE
,
432 MIGRATION_CAPABILITY_RETURN_PATH
,
433 MIGRATION_CAPABILITY_MULTIFD
,
434 MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER
,
435 MIGRATION_CAPABILITY_AUTO_CONVERGE
,
436 MIGRATION_CAPABILITY_RELEASE_RAM
,
437 MIGRATION_CAPABILITY_RDMA_PIN_ALL
,
438 MIGRATION_CAPABILITY_COMPRESS
,
439 MIGRATION_CAPABILITY_XBZRLE
,
440 MIGRATION_CAPABILITY_X_COLO
,
441 MIGRATION_CAPABILITY_VALIDATE_UUID
,
442 MIGRATION_CAPABILITY_ZERO_COPY_SEND
);
445 * @migration_caps_check - check capability compatibility
447 * @old_caps: old capability list
448 * @new_caps: new capability list
449 * @errp: set *errp if the check failed, with reason
451 * Returns true if check passed, otherwise false.
453 bool migrate_caps_check(bool *old_caps
, bool *new_caps
, Error
**errp
)
455 MigrationIncomingState
*mis
= migration_incoming_get_current();
458 #ifndef CONFIG_LIVE_BLOCK_MIGRATION
459 if (new_caps
[MIGRATION_CAPABILITY_BLOCK
]) {
460 error_setg(errp
, "QEMU compiled without old-style (blk/-b, inc/-i) "
462 error_append_hint(errp
, "Use drive_mirror+NBD instead.\n");
467 #ifndef CONFIG_REPLICATION
468 if (new_caps
[MIGRATION_CAPABILITY_X_COLO
]) {
469 error_setg(errp
, "QEMU compiled without replication module"
470 " can't enable COLO");
471 error_append_hint(errp
, "Please enable replication before COLO.\n");
476 if (new_caps
[MIGRATION_CAPABILITY_POSTCOPY_RAM
]) {
477 /* This check is reasonably expensive, so only when it's being
478 * set the first time, also it's only the destination that needs
481 if (!old_caps
[MIGRATION_CAPABILITY_POSTCOPY_RAM
] &&
482 runstate_check(RUN_STATE_INMIGRATE
) &&
483 !postcopy_ram_supported_by_host(mis
, errp
)) {
484 error_prepend(errp
, "Postcopy is not supported: ");
488 if (new_caps
[MIGRATION_CAPABILITY_X_IGNORE_SHARED
]) {
489 error_setg(errp
, "Postcopy is not compatible with ignore-shared");
493 if (new_caps
[MIGRATION_CAPABILITY_MULTIFD
]) {
494 error_setg(errp
, "Postcopy is not yet compatible with multifd");
499 if (new_caps
[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT
]) {
500 WriteTrackingSupport wt_support
;
503 * Check if 'background-snapshot' capability is supported by
504 * host kernel and compatible with guest memory configuration.
506 wt_support
= migrate_query_write_tracking();
507 if (wt_support
< WT_SUPPORT_AVAILABLE
) {
508 error_setg(errp
, "Background-snapshot is not supported by host kernel");
511 if (wt_support
< WT_SUPPORT_COMPATIBLE
) {
512 error_setg(errp
, "Background-snapshot is not compatible "
513 "with guest memory configuration");
518 * Check if there are any migration capabilities
519 * incompatible with 'background-snapshot'.
521 for (idx
= 0; idx
< check_caps_background_snapshot
.size
; idx
++) {
522 int incomp_cap
= check_caps_background_snapshot
.caps
[idx
];
523 if (new_caps
[incomp_cap
]) {
525 "Background-snapshot is not compatible with %s",
526 MigrationCapability_str(incomp_cap
));
533 if (new_caps
[MIGRATION_CAPABILITY_ZERO_COPY_SEND
] &&
534 (!new_caps
[MIGRATION_CAPABILITY_MULTIFD
] ||
535 new_caps
[MIGRATION_CAPABILITY_COMPRESS
] ||
536 new_caps
[MIGRATION_CAPABILITY_XBZRLE
] ||
537 migrate_multifd_compression() ||
540 "Zero copy only available for non-compressed non-TLS multifd migration");
544 if (new_caps
[MIGRATION_CAPABILITY_ZERO_COPY_SEND
]) {
546 "Zero copy currently only available on Linux");
551 if (new_caps
[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT
]) {
552 if (!new_caps
[MIGRATION_CAPABILITY_POSTCOPY_RAM
]) {
553 error_setg(errp
, "Postcopy preempt requires postcopy-ram");
558 * Preempt mode requires urgent pages to be sent in separate
559 * channel, OTOH compression logic will disorder all pages into
560 * different compression channels, which is not compatible with the
561 * preempt assumptions on channel assignments.
563 if (new_caps
[MIGRATION_CAPABILITY_COMPRESS
]) {
564 error_setg(errp
, "Postcopy preempt not compatible with compress");
569 if (new_caps
[MIGRATION_CAPABILITY_MULTIFD
]) {
570 if (new_caps
[MIGRATION_CAPABILITY_COMPRESS
]) {
571 error_setg(errp
, "Multifd is not compatible with compress");
576 if (new_caps
[MIGRATION_CAPABILITY_SWITCHOVER_ACK
]) {
577 if (!new_caps
[MIGRATION_CAPABILITY_RETURN_PATH
]) {
578 error_setg(errp
, "Capability 'switchover-ack' requires capability "
583 if (new_caps
[MIGRATION_CAPABILITY_DIRTY_LIMIT
]) {
584 if (new_caps
[MIGRATION_CAPABILITY_AUTO_CONVERGE
]) {
585 error_setg(errp
, "dirty-limit conflicts with auto-converge"
586 " either of then available currently");
590 if (!kvm_enabled() || !kvm_dirty_ring_enabled()) {
591 error_setg(errp
, "dirty-limit requires KVM with accelerator"
592 " property 'dirty-ring-size' set");
600 bool migrate_cap_set(int cap
, bool value
, Error
**errp
)
602 MigrationState
*s
= migrate_get_current();
603 bool new_caps
[MIGRATION_CAPABILITY__MAX
];
605 if (migration_is_running(s
->state
)) {
606 error_setg(errp
, QERR_MIGRATION_ACTIVE
);
610 memcpy(new_caps
, s
->capabilities
, sizeof(new_caps
));
611 new_caps
[cap
] = value
;
613 if (!migrate_caps_check(s
->capabilities
, new_caps
, errp
)) {
616 s
->capabilities
[cap
] = value
;
620 MigrationCapabilityStatusList
*qmp_query_migrate_capabilities(Error
**errp
)
622 MigrationCapabilityStatusList
*head
= NULL
, **tail
= &head
;
623 MigrationCapabilityStatus
*caps
;
624 MigrationState
*s
= migrate_get_current();
627 for (i
= 0; i
< MIGRATION_CAPABILITY__MAX
; i
++) {
628 #ifndef CONFIG_LIVE_BLOCK_MIGRATION
629 if (i
== MIGRATION_CAPABILITY_BLOCK
) {
633 caps
= g_malloc0(sizeof(*caps
));
634 caps
->capability
= i
;
635 caps
->state
= s
->capabilities
[i
];
636 QAPI_LIST_APPEND(tail
, caps
);
642 void qmp_migrate_set_capabilities(MigrationCapabilityStatusList
*params
,
645 MigrationState
*s
= migrate_get_current();
646 MigrationCapabilityStatusList
*cap
;
647 bool new_caps
[MIGRATION_CAPABILITY__MAX
];
649 if (migration_is_running(s
->state
) || migration_in_colo_state()) {
650 error_setg(errp
, QERR_MIGRATION_ACTIVE
);
654 memcpy(new_caps
, s
->capabilities
, sizeof(new_caps
));
655 for (cap
= params
; cap
; cap
= cap
->next
) {
656 new_caps
[cap
->value
->capability
] = cap
->value
->state
;
659 if (!migrate_caps_check(s
->capabilities
, new_caps
, errp
)) {
663 for (cap
= params
; cap
; cap
= cap
->next
) {
664 s
->capabilities
[cap
->value
->capability
] = cap
->value
->state
;
670 const BitmapMigrationNodeAliasList
*migrate_block_bitmap_mapping(void)
672 MigrationState
*s
= migrate_get_current();
674 return s
->parameters
.block_bitmap_mapping
;
677 bool migrate_has_block_bitmap_mapping(void)
679 MigrationState
*s
= migrate_get_current();
681 return s
->parameters
.has_block_bitmap_mapping
;
684 bool migrate_block_incremental(void)
686 MigrationState
*s
= migrate_get_current();
688 return s
->parameters
.block_incremental
;
691 uint32_t migrate_checkpoint_delay(void)
693 MigrationState
*s
= migrate_get_current();
695 return s
->parameters
.x_checkpoint_delay
;
698 int migrate_compress_level(void)
700 MigrationState
*s
= migrate_get_current();
702 return s
->parameters
.compress_level
;
705 int migrate_compress_threads(void)
707 MigrationState
*s
= migrate_get_current();
709 return s
->parameters
.compress_threads
;
712 int migrate_compress_wait_thread(void)
714 MigrationState
*s
= migrate_get_current();
716 return s
->parameters
.compress_wait_thread
;
719 uint8_t migrate_cpu_throttle_increment(void)
721 MigrationState
*s
= migrate_get_current();
723 return s
->parameters
.cpu_throttle_increment
;
726 uint8_t migrate_cpu_throttle_initial(void)
728 MigrationState
*s
= migrate_get_current();
730 return s
->parameters
.cpu_throttle_initial
;
733 bool migrate_cpu_throttle_tailslow(void)
735 MigrationState
*s
= migrate_get_current();
737 return s
->parameters
.cpu_throttle_tailslow
;
740 int migrate_decompress_threads(void)
742 MigrationState
*s
= migrate_get_current();
744 return s
->parameters
.decompress_threads
;
747 uint64_t migrate_downtime_limit(void)
749 MigrationState
*s
= migrate_get_current();
751 return s
->parameters
.downtime_limit
;
754 uint8_t migrate_max_cpu_throttle(void)
756 MigrationState
*s
= migrate_get_current();
758 return s
->parameters
.max_cpu_throttle
;
761 uint64_t migrate_max_bandwidth(void)
763 MigrationState
*s
= migrate_get_current();
765 return s
->parameters
.max_bandwidth
;
768 uint64_t migrate_max_postcopy_bandwidth(void)
770 MigrationState
*s
= migrate_get_current();
772 return s
->parameters
.max_postcopy_bandwidth
;
775 int migrate_multifd_channels(void)
777 MigrationState
*s
= migrate_get_current();
779 return s
->parameters
.multifd_channels
;
782 MultiFDCompression
migrate_multifd_compression(void)
784 MigrationState
*s
= migrate_get_current();
786 assert(s
->parameters
.multifd_compression
< MULTIFD_COMPRESSION__MAX
);
787 return s
->parameters
.multifd_compression
;
790 int migrate_multifd_zlib_level(void)
792 MigrationState
*s
= migrate_get_current();
794 return s
->parameters
.multifd_zlib_level
;
797 int migrate_multifd_zstd_level(void)
799 MigrationState
*s
= migrate_get_current();
801 return s
->parameters
.multifd_zstd_level
;
804 uint8_t migrate_throttle_trigger_threshold(void)
806 MigrationState
*s
= migrate_get_current();
808 return s
->parameters
.throttle_trigger_threshold
;
811 const char *migrate_tls_authz(void)
813 MigrationState
*s
= migrate_get_current();
815 return s
->parameters
.tls_authz
;
818 const char *migrate_tls_creds(void)
820 MigrationState
*s
= migrate_get_current();
822 return s
->parameters
.tls_creds
;
825 const char *migrate_tls_hostname(void)
827 MigrationState
*s
= migrate_get_current();
829 return s
->parameters
.tls_hostname
;
832 uint64_t migrate_xbzrle_cache_size(void)
834 MigrationState
*s
= migrate_get_current();
836 return s
->parameters
.xbzrle_cache_size
;
839 /* parameter setters */
841 void migrate_set_block_incremental(bool value
)
843 MigrationState
*s
= migrate_get_current();
845 s
->parameters
.block_incremental
= value
;
848 /* parameters helpers */
850 void block_cleanup_parameters(void)
852 MigrationState
*s
= migrate_get_current();
854 if (s
->must_remove_block_options
) {
855 /* setting to false can never fail */
856 migrate_cap_set(MIGRATION_CAPABILITY_BLOCK
, false, &error_abort
);
857 migrate_set_block_incremental(false);
858 s
->must_remove_block_options
= false;
862 AnnounceParameters
*migrate_announce_params(void)
864 static AnnounceParameters ap
;
866 MigrationState
*s
= migrate_get_current();
868 ap
.initial
= s
->parameters
.announce_initial
;
869 ap
.max
= s
->parameters
.announce_max
;
870 ap
.rounds
= s
->parameters
.announce_rounds
;
871 ap
.step
= s
->parameters
.announce_step
;
876 MigrationParameters
*qmp_query_migrate_parameters(Error
**errp
)
878 MigrationParameters
*params
;
879 MigrationState
*s
= migrate_get_current();
881 /* TODO use QAPI_CLONE() instead of duplicating it inline */
882 params
= g_malloc0(sizeof(*params
));
883 params
->has_compress_level
= true;
884 params
->compress_level
= s
->parameters
.compress_level
;
885 params
->has_compress_threads
= true;
886 params
->compress_threads
= s
->parameters
.compress_threads
;
887 params
->has_compress_wait_thread
= true;
888 params
->compress_wait_thread
= s
->parameters
.compress_wait_thread
;
889 params
->has_decompress_threads
= true;
890 params
->decompress_threads
= s
->parameters
.decompress_threads
;
891 params
->has_throttle_trigger_threshold
= true;
892 params
->throttle_trigger_threshold
= s
->parameters
.throttle_trigger_threshold
;
893 params
->has_cpu_throttle_initial
= true;
894 params
->cpu_throttle_initial
= s
->parameters
.cpu_throttle_initial
;
895 params
->has_cpu_throttle_increment
= true;
896 params
->cpu_throttle_increment
= s
->parameters
.cpu_throttle_increment
;
897 params
->has_cpu_throttle_tailslow
= true;
898 params
->cpu_throttle_tailslow
= s
->parameters
.cpu_throttle_tailslow
;
899 params
->tls_creds
= g_strdup(s
->parameters
.tls_creds
);
900 params
->tls_hostname
= g_strdup(s
->parameters
.tls_hostname
);
901 params
->tls_authz
= g_strdup(s
->parameters
.tls_authz
?
902 s
->parameters
.tls_authz
: "");
903 params
->has_max_bandwidth
= true;
904 params
->max_bandwidth
= s
->parameters
.max_bandwidth
;
905 params
->has_downtime_limit
= true;
906 params
->downtime_limit
= s
->parameters
.downtime_limit
;
907 params
->has_x_checkpoint_delay
= true;
908 params
->x_checkpoint_delay
= s
->parameters
.x_checkpoint_delay
;
909 params
->has_block_incremental
= true;
910 params
->block_incremental
= s
->parameters
.block_incremental
;
911 params
->has_multifd_channels
= true;
912 params
->multifd_channels
= s
->parameters
.multifd_channels
;
913 params
->has_multifd_compression
= true;
914 params
->multifd_compression
= s
->parameters
.multifd_compression
;
915 params
->has_multifd_zlib_level
= true;
916 params
->multifd_zlib_level
= s
->parameters
.multifd_zlib_level
;
917 params
->has_multifd_zstd_level
= true;
918 params
->multifd_zstd_level
= s
->parameters
.multifd_zstd_level
;
919 params
->has_xbzrle_cache_size
= true;
920 params
->xbzrle_cache_size
= s
->parameters
.xbzrle_cache_size
;
921 params
->has_max_postcopy_bandwidth
= true;
922 params
->max_postcopy_bandwidth
= s
->parameters
.max_postcopy_bandwidth
;
923 params
->has_max_cpu_throttle
= true;
924 params
->max_cpu_throttle
= s
->parameters
.max_cpu_throttle
;
925 params
->has_announce_initial
= true;
926 params
->announce_initial
= s
->parameters
.announce_initial
;
927 params
->has_announce_max
= true;
928 params
->announce_max
= s
->parameters
.announce_max
;
929 params
->has_announce_rounds
= true;
930 params
->announce_rounds
= s
->parameters
.announce_rounds
;
931 params
->has_announce_step
= true;
932 params
->announce_step
= s
->parameters
.announce_step
;
934 if (s
->parameters
.has_block_bitmap_mapping
) {
935 params
->has_block_bitmap_mapping
= true;
936 params
->block_bitmap_mapping
=
937 QAPI_CLONE(BitmapMigrationNodeAliasList
,
938 s
->parameters
.block_bitmap_mapping
);
941 params
->has_x_vcpu_dirty_limit_period
= true;
942 params
->x_vcpu_dirty_limit_period
= s
->parameters
.x_vcpu_dirty_limit_period
;
943 params
->has_vcpu_dirty_limit
= true;
944 params
->vcpu_dirty_limit
= s
->parameters
.vcpu_dirty_limit
;
949 void migrate_params_init(MigrationParameters
*params
)
951 params
->tls_hostname
= g_strdup("");
952 params
->tls_creds
= g_strdup("");
954 /* Set has_* up only for parameter checks */
955 params
->has_compress_level
= true;
956 params
->has_compress_threads
= true;
957 params
->has_compress_wait_thread
= true;
958 params
->has_decompress_threads
= true;
959 params
->has_throttle_trigger_threshold
= true;
960 params
->has_cpu_throttle_initial
= true;
961 params
->has_cpu_throttle_increment
= true;
962 params
->has_cpu_throttle_tailslow
= true;
963 params
->has_max_bandwidth
= true;
964 params
->has_downtime_limit
= true;
965 params
->has_x_checkpoint_delay
= true;
966 params
->has_block_incremental
= true;
967 params
->has_multifd_channels
= true;
968 params
->has_multifd_compression
= true;
969 params
->has_multifd_zlib_level
= true;
970 params
->has_multifd_zstd_level
= true;
971 params
->has_xbzrle_cache_size
= true;
972 params
->has_max_postcopy_bandwidth
= true;
973 params
->has_max_cpu_throttle
= true;
974 params
->has_announce_initial
= true;
975 params
->has_announce_max
= true;
976 params
->has_announce_rounds
= true;
977 params
->has_announce_step
= true;
978 params
->has_x_vcpu_dirty_limit_period
= true;
979 params
->has_vcpu_dirty_limit
= true;
983 * Check whether the parameters are valid. Error will be put into errp
984 * (if provided). Return true if valid, otherwise false.
986 bool migrate_params_check(MigrationParameters
*params
, Error
**errp
)
988 if (params
->has_compress_level
&&
989 (params
->compress_level
> 9)) {
990 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
, "compress_level",
991 "a value between 0 and 9");
995 if (params
->has_compress_threads
&& (params
->compress_threads
< 1)) {
996 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
998 "a value between 1 and 255");
1002 if (params
->has_decompress_threads
&& (params
->decompress_threads
< 1)) {
1003 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1004 "decompress_threads",
1005 "a value between 1 and 255");
1009 if (params
->has_throttle_trigger_threshold
&&
1010 (params
->throttle_trigger_threshold
< 1 ||
1011 params
->throttle_trigger_threshold
> 100)) {
1012 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1013 "throttle_trigger_threshold",
1014 "an integer in the range of 1 to 100");
1018 if (params
->has_cpu_throttle_initial
&&
1019 (params
->cpu_throttle_initial
< 1 ||
1020 params
->cpu_throttle_initial
> 99)) {
1021 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1022 "cpu_throttle_initial",
1023 "an integer in the range of 1 to 99");
1027 if (params
->has_cpu_throttle_increment
&&
1028 (params
->cpu_throttle_increment
< 1 ||
1029 params
->cpu_throttle_increment
> 99)) {
1030 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1031 "cpu_throttle_increment",
1032 "an integer in the range of 1 to 99");
1036 if (params
->has_max_bandwidth
&& (params
->max_bandwidth
> SIZE_MAX
)) {
1037 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1039 "an integer in the range of 0 to "stringify(SIZE_MAX
)
1044 if (params
->has_downtime_limit
&&
1045 (params
->downtime_limit
> MAX_MIGRATE_DOWNTIME
)) {
1046 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1048 "an integer in the range of 0 to "
1049 stringify(MAX_MIGRATE_DOWNTIME
)" ms");
1053 /* x_checkpoint_delay is now always positive */
1055 if (params
->has_multifd_channels
&& (params
->multifd_channels
< 1)) {
1056 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1058 "a value between 1 and 255");
1062 if (params
->has_multifd_zlib_level
&&
1063 (params
->multifd_zlib_level
> 9)) {
1064 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
, "multifd_zlib_level",
1065 "a value between 0 and 9");
1069 if (params
->has_multifd_zstd_level
&&
1070 (params
->multifd_zstd_level
> 20)) {
1071 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
, "multifd_zstd_level",
1072 "a value between 0 and 20");
1076 if (params
->has_xbzrle_cache_size
&&
1077 (params
->xbzrle_cache_size
< qemu_target_page_size() ||
1078 !is_power_of_2(params
->xbzrle_cache_size
))) {
1079 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1080 "xbzrle_cache_size",
1081 "a power of two no less than the target page size");
1085 if (params
->has_max_cpu_throttle
&&
1086 (params
->max_cpu_throttle
< params
->cpu_throttle_initial
||
1087 params
->max_cpu_throttle
> 99)) {
1088 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1090 "an integer in the range of cpu_throttle_initial to 99");
1094 if (params
->has_announce_initial
&&
1095 params
->announce_initial
> 100000) {
1096 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1098 "a value between 0 and 100000");
1101 if (params
->has_announce_max
&&
1102 params
->announce_max
> 100000) {
1103 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1105 "a value between 0 and 100000");
1108 if (params
->has_announce_rounds
&&
1109 params
->announce_rounds
> 1000) {
1110 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1112 "a value between 0 and 1000");
1115 if (params
->has_announce_step
&&
1116 (params
->announce_step
< 1 ||
1117 params
->announce_step
> 10000)) {
1118 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1120 "a value between 0 and 10000");
1124 if (params
->has_block_bitmap_mapping
&&
1125 !check_dirty_bitmap_mig_alias_map(params
->block_bitmap_mapping
, errp
)) {
1126 error_prepend(errp
, "Invalid mapping given for block-bitmap-mapping: ");
1131 if (migrate_zero_copy_send() &&
1132 ((params
->has_multifd_compression
&& params
->multifd_compression
) ||
1133 (params
->tls_creds
&& *params
->tls_creds
))) {
1135 "Zero copy only available for non-compressed non-TLS multifd migration");
1140 if (params
->has_x_vcpu_dirty_limit_period
&&
1141 (params
->x_vcpu_dirty_limit_period
< 1 ||
1142 params
->x_vcpu_dirty_limit_period
> 1000)) {
1143 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1144 "x-vcpu-dirty-limit-period",
1145 "a value between 1 and 1000");
1149 if (params
->has_vcpu_dirty_limit
&&
1150 (params
->vcpu_dirty_limit
< 1)) {
1151 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1153 "is invalid, it must greater then 1 MB/s");
1160 static void migrate_params_test_apply(MigrateSetParameters
*params
,
1161 MigrationParameters
*dest
)
1163 *dest
= migrate_get_current()->parameters
;
1165 /* TODO use QAPI_CLONE() instead of duplicating it inline */
1167 if (params
->has_compress_level
) {
1168 dest
->compress_level
= params
->compress_level
;
1171 if (params
->has_compress_threads
) {
1172 dest
->compress_threads
= params
->compress_threads
;
1175 if (params
->has_compress_wait_thread
) {
1176 dest
->compress_wait_thread
= params
->compress_wait_thread
;
1179 if (params
->has_decompress_threads
) {
1180 dest
->decompress_threads
= params
->decompress_threads
;
1183 if (params
->has_throttle_trigger_threshold
) {
1184 dest
->throttle_trigger_threshold
= params
->throttle_trigger_threshold
;
1187 if (params
->has_cpu_throttle_initial
) {
1188 dest
->cpu_throttle_initial
= params
->cpu_throttle_initial
;
1191 if (params
->has_cpu_throttle_increment
) {
1192 dest
->cpu_throttle_increment
= params
->cpu_throttle_increment
;
1195 if (params
->has_cpu_throttle_tailslow
) {
1196 dest
->cpu_throttle_tailslow
= params
->cpu_throttle_tailslow
;
1199 if (params
->tls_creds
) {
1200 assert(params
->tls_creds
->type
== QTYPE_QSTRING
);
1201 dest
->tls_creds
= params
->tls_creds
->u
.s
;
1204 if (params
->tls_hostname
) {
1205 assert(params
->tls_hostname
->type
== QTYPE_QSTRING
);
1206 dest
->tls_hostname
= params
->tls_hostname
->u
.s
;
1209 if (params
->has_max_bandwidth
) {
1210 dest
->max_bandwidth
= params
->max_bandwidth
;
1213 if (params
->has_downtime_limit
) {
1214 dest
->downtime_limit
= params
->downtime_limit
;
1217 if (params
->has_x_checkpoint_delay
) {
1218 dest
->x_checkpoint_delay
= params
->x_checkpoint_delay
;
1221 if (params
->has_block_incremental
) {
1222 dest
->block_incremental
= params
->block_incremental
;
1224 if (params
->has_multifd_channels
) {
1225 dest
->multifd_channels
= params
->multifd_channels
;
1227 if (params
->has_multifd_compression
) {
1228 dest
->multifd_compression
= params
->multifd_compression
;
1230 if (params
->has_xbzrle_cache_size
) {
1231 dest
->xbzrle_cache_size
= params
->xbzrle_cache_size
;
1233 if (params
->has_max_postcopy_bandwidth
) {
1234 dest
->max_postcopy_bandwidth
= params
->max_postcopy_bandwidth
;
1236 if (params
->has_max_cpu_throttle
) {
1237 dest
->max_cpu_throttle
= params
->max_cpu_throttle
;
1239 if (params
->has_announce_initial
) {
1240 dest
->announce_initial
= params
->announce_initial
;
1242 if (params
->has_announce_max
) {
1243 dest
->announce_max
= params
->announce_max
;
1245 if (params
->has_announce_rounds
) {
1246 dest
->announce_rounds
= params
->announce_rounds
;
1248 if (params
->has_announce_step
) {
1249 dest
->announce_step
= params
->announce_step
;
1252 if (params
->has_block_bitmap_mapping
) {
1253 dest
->has_block_bitmap_mapping
= true;
1254 dest
->block_bitmap_mapping
= params
->block_bitmap_mapping
;
1257 if (params
->has_x_vcpu_dirty_limit_period
) {
1258 dest
->x_vcpu_dirty_limit_period
=
1259 params
->x_vcpu_dirty_limit_period
;
1261 if (params
->has_vcpu_dirty_limit
) {
1262 dest
->vcpu_dirty_limit
= params
->vcpu_dirty_limit
;
1266 static void migrate_params_apply(MigrateSetParameters
*params
, Error
**errp
)
1268 MigrationState
*s
= migrate_get_current();
1270 /* TODO use QAPI_CLONE() instead of duplicating it inline */
1272 if (params
->has_compress_level
) {
1273 s
->parameters
.compress_level
= params
->compress_level
;
1276 if (params
->has_compress_threads
) {
1277 s
->parameters
.compress_threads
= params
->compress_threads
;
1280 if (params
->has_compress_wait_thread
) {
1281 s
->parameters
.compress_wait_thread
= params
->compress_wait_thread
;
1284 if (params
->has_decompress_threads
) {
1285 s
->parameters
.decompress_threads
= params
->decompress_threads
;
1288 if (params
->has_throttle_trigger_threshold
) {
1289 s
->parameters
.throttle_trigger_threshold
= params
->throttle_trigger_threshold
;
1292 if (params
->has_cpu_throttle_initial
) {
1293 s
->parameters
.cpu_throttle_initial
= params
->cpu_throttle_initial
;
1296 if (params
->has_cpu_throttle_increment
) {
1297 s
->parameters
.cpu_throttle_increment
= params
->cpu_throttle_increment
;
1300 if (params
->has_cpu_throttle_tailslow
) {
1301 s
->parameters
.cpu_throttle_tailslow
= params
->cpu_throttle_tailslow
;
1304 if (params
->tls_creds
) {
1305 g_free(s
->parameters
.tls_creds
);
1306 assert(params
->tls_creds
->type
== QTYPE_QSTRING
);
1307 s
->parameters
.tls_creds
= g_strdup(params
->tls_creds
->u
.s
);
1310 if (params
->tls_hostname
) {
1311 g_free(s
->parameters
.tls_hostname
);
1312 assert(params
->tls_hostname
->type
== QTYPE_QSTRING
);
1313 s
->parameters
.tls_hostname
= g_strdup(params
->tls_hostname
->u
.s
);
1316 if (params
->tls_authz
) {
1317 g_free(s
->parameters
.tls_authz
);
1318 assert(params
->tls_authz
->type
== QTYPE_QSTRING
);
1319 s
->parameters
.tls_authz
= g_strdup(params
->tls_authz
->u
.s
);
1322 if (params
->has_max_bandwidth
) {
1323 s
->parameters
.max_bandwidth
= params
->max_bandwidth
;
1324 if (s
->to_dst_file
&& !migration_in_postcopy()) {
1325 migration_rate_set(s
->parameters
.max_bandwidth
);
1329 if (params
->has_downtime_limit
) {
1330 s
->parameters
.downtime_limit
= params
->downtime_limit
;
1333 if (params
->has_x_checkpoint_delay
) {
1334 s
->parameters
.x_checkpoint_delay
= params
->x_checkpoint_delay
;
1335 colo_checkpoint_delay_set();
1338 if (params
->has_block_incremental
) {
1339 s
->parameters
.block_incremental
= params
->block_incremental
;
1341 if (params
->has_multifd_channels
) {
1342 s
->parameters
.multifd_channels
= params
->multifd_channels
;
1344 if (params
->has_multifd_compression
) {
1345 s
->parameters
.multifd_compression
= params
->multifd_compression
;
1347 if (params
->has_xbzrle_cache_size
) {
1348 s
->parameters
.xbzrle_cache_size
= params
->xbzrle_cache_size
;
1349 xbzrle_cache_resize(params
->xbzrle_cache_size
, errp
);
1351 if (params
->has_max_postcopy_bandwidth
) {
1352 s
->parameters
.max_postcopy_bandwidth
= params
->max_postcopy_bandwidth
;
1353 if (s
->to_dst_file
&& migration_in_postcopy()) {
1354 migration_rate_set(s
->parameters
.max_postcopy_bandwidth
);
1357 if (params
->has_max_cpu_throttle
) {
1358 s
->parameters
.max_cpu_throttle
= params
->max_cpu_throttle
;
1360 if (params
->has_announce_initial
) {
1361 s
->parameters
.announce_initial
= params
->announce_initial
;
1363 if (params
->has_announce_max
) {
1364 s
->parameters
.announce_max
= params
->announce_max
;
1366 if (params
->has_announce_rounds
) {
1367 s
->parameters
.announce_rounds
= params
->announce_rounds
;
1369 if (params
->has_announce_step
) {
1370 s
->parameters
.announce_step
= params
->announce_step
;
1373 if (params
->has_block_bitmap_mapping
) {
1374 qapi_free_BitmapMigrationNodeAliasList(
1375 s
->parameters
.block_bitmap_mapping
);
1377 s
->parameters
.has_block_bitmap_mapping
= true;
1378 s
->parameters
.block_bitmap_mapping
=
1379 QAPI_CLONE(BitmapMigrationNodeAliasList
,
1380 params
->block_bitmap_mapping
);
1383 if (params
->has_x_vcpu_dirty_limit_period
) {
1384 s
->parameters
.x_vcpu_dirty_limit_period
=
1385 params
->x_vcpu_dirty_limit_period
;
1387 if (params
->has_vcpu_dirty_limit
) {
1388 s
->parameters
.vcpu_dirty_limit
= params
->vcpu_dirty_limit
;
1392 void qmp_migrate_set_parameters(MigrateSetParameters
*params
, Error
**errp
)
1394 MigrationParameters tmp
;
1396 /* TODO Rewrite "" to null instead */
1397 if (params
->tls_creds
1398 && params
->tls_creds
->type
== QTYPE_QNULL
) {
1399 qobject_unref(params
->tls_creds
->u
.n
);
1400 params
->tls_creds
->type
= QTYPE_QSTRING
;
1401 params
->tls_creds
->u
.s
= strdup("");
1403 /* TODO Rewrite "" to null instead */
1404 if (params
->tls_hostname
1405 && params
->tls_hostname
->type
== QTYPE_QNULL
) {
1406 qobject_unref(params
->tls_hostname
->u
.n
);
1407 params
->tls_hostname
->type
= QTYPE_QSTRING
;
1408 params
->tls_hostname
->u
.s
= strdup("");
1411 migrate_params_test_apply(params
, &tmp
);
1413 if (!migrate_params_check(&tmp
, errp
)) {
1414 /* Invalid parameter */
1418 migrate_params_apply(params
, errp
);