docs/system/arm: Add a doc for zynq board
[qemu/armbru.git] / migration / options.c
blob645f55003da77c24505e247efb48e130267b009f
1 /*
2 * QEMU migration capabilities
4 * Copyright (c) 2012-2023 Red Hat Inc
6 * Authors:
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 "qemu/error-report.h"
16 #include "exec/target_page.h"
17 #include "qapi/clone-visitor.h"
18 #include "qapi/error.h"
19 #include "qapi/qapi-commands-migration.h"
20 #include "qapi/qapi-visit-migration.h"
21 #include "qapi/qmp/qerror.h"
22 #include "qapi/qmp/qnull.h"
23 #include "sysemu/runstate.h"
24 #include "migration/colo.h"
25 #include "migration/misc.h"
26 #include "migration.h"
27 #include "migration-stats.h"
28 #include "qemu-file.h"
29 #include "ram.h"
30 #include "options.h"
31 #include "sysemu/kvm.h"
33 /* Maximum migrate downtime set to 2000 seconds */
34 #define MAX_MIGRATE_DOWNTIME_SECONDS 2000
35 #define MAX_MIGRATE_DOWNTIME (MAX_MIGRATE_DOWNTIME_SECONDS * 1000)
37 #define MAX_THROTTLE (128 << 20) /* Migration transfer speed throttling */
39 /* Time in milliseconds we are allowed to stop the source,
40 * for sending the last part */
41 #define DEFAULT_MIGRATE_SET_DOWNTIME 300
43 /* Define default autoconverge cpu throttle migration parameters */
44 #define DEFAULT_MIGRATE_THROTTLE_TRIGGER_THRESHOLD 50
45 #define DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL 20
46 #define DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT 10
47 #define DEFAULT_MIGRATE_MAX_CPU_THROTTLE 99
49 /* Migration XBZRLE default cache size */
50 #define DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE (64 * 1024 * 1024)
52 /* The delay time (in ms) between two COLO checkpoints */
53 #define DEFAULT_MIGRATE_X_CHECKPOINT_DELAY (200 * 100)
54 #define DEFAULT_MIGRATE_MULTIFD_CHANNELS 2
55 #define DEFAULT_MIGRATE_MULTIFD_COMPRESSION MULTIFD_COMPRESSION_NONE
56 /* 0: means nocompress, 1: best speed, ... 9: best compress ratio */
57 #define DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL 1
58 /* 0: means nocompress, 1: best speed, ... 20: best compress ratio */
59 #define DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL 1
61 /* Background transfer rate for postcopy, 0 means unlimited, note
62 * that page requests can still exceed this limit.
64 #define DEFAULT_MIGRATE_MAX_POSTCOPY_BANDWIDTH 0
67 * Parameters for self_announce_delay giving a stream of RARP/ARP
68 * packets after migration.
70 #define DEFAULT_MIGRATE_ANNOUNCE_INITIAL 50
71 #define DEFAULT_MIGRATE_ANNOUNCE_MAX 550
72 #define DEFAULT_MIGRATE_ANNOUNCE_ROUNDS 5
73 #define DEFAULT_MIGRATE_ANNOUNCE_STEP 100
75 #define DEFINE_PROP_MIG_CAP(name, x) \
76 DEFINE_PROP_BOOL(name, MigrationState, capabilities[x], false)
78 #define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD 1000 /* milliseconds */
79 #define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT 1 /* MB/s */
81 Property migration_properties[] = {
82 DEFINE_PROP_BOOL("store-global-state", MigrationState,
83 store_global_state, true),
84 DEFINE_PROP_BOOL("send-configuration", MigrationState,
85 send_configuration, true),
86 DEFINE_PROP_BOOL("send-section-footer", MigrationState,
87 send_section_footer, true),
88 DEFINE_PROP_BOOL("multifd-flush-after-each-section", MigrationState,
89 multifd_flush_after_each_section, false),
90 DEFINE_PROP_UINT8("x-clear-bitmap-shift", MigrationState,
91 clear_bitmap_shift, CLEAR_BITMAP_SHIFT_DEFAULT),
92 DEFINE_PROP_BOOL("x-preempt-pre-7-2", MigrationState,
93 preempt_pre_7_2, false),
95 /* Migration parameters */
96 DEFINE_PROP_UINT8("x-throttle-trigger-threshold", MigrationState,
97 parameters.throttle_trigger_threshold,
98 DEFAULT_MIGRATE_THROTTLE_TRIGGER_THRESHOLD),
99 DEFINE_PROP_UINT8("x-cpu-throttle-initial", MigrationState,
100 parameters.cpu_throttle_initial,
101 DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL),
102 DEFINE_PROP_UINT8("x-cpu-throttle-increment", MigrationState,
103 parameters.cpu_throttle_increment,
104 DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT),
105 DEFINE_PROP_BOOL("x-cpu-throttle-tailslow", MigrationState,
106 parameters.cpu_throttle_tailslow, false),
107 DEFINE_PROP_SIZE("x-max-bandwidth", MigrationState,
108 parameters.max_bandwidth, MAX_THROTTLE),
109 DEFINE_PROP_SIZE("avail-switchover-bandwidth", MigrationState,
110 parameters.avail_switchover_bandwidth, 0),
111 DEFINE_PROP_UINT64("x-downtime-limit", MigrationState,
112 parameters.downtime_limit,
113 DEFAULT_MIGRATE_SET_DOWNTIME),
114 DEFINE_PROP_UINT32("x-checkpoint-delay", MigrationState,
115 parameters.x_checkpoint_delay,
116 DEFAULT_MIGRATE_X_CHECKPOINT_DELAY),
117 DEFINE_PROP_UINT8("multifd-channels", MigrationState,
118 parameters.multifd_channels,
119 DEFAULT_MIGRATE_MULTIFD_CHANNELS),
120 DEFINE_PROP_MULTIFD_COMPRESSION("multifd-compression", MigrationState,
121 parameters.multifd_compression,
122 DEFAULT_MIGRATE_MULTIFD_COMPRESSION),
123 DEFINE_PROP_UINT8("multifd-zlib-level", MigrationState,
124 parameters.multifd_zlib_level,
125 DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL),
126 DEFINE_PROP_UINT8("multifd-zstd-level", MigrationState,
127 parameters.multifd_zstd_level,
128 DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL),
129 DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState,
130 parameters.xbzrle_cache_size,
131 DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE),
132 DEFINE_PROP_SIZE("max-postcopy-bandwidth", MigrationState,
133 parameters.max_postcopy_bandwidth,
134 DEFAULT_MIGRATE_MAX_POSTCOPY_BANDWIDTH),
135 DEFINE_PROP_UINT8("max-cpu-throttle", MigrationState,
136 parameters.max_cpu_throttle,
137 DEFAULT_MIGRATE_MAX_CPU_THROTTLE),
138 DEFINE_PROP_SIZE("announce-initial", MigrationState,
139 parameters.announce_initial,
140 DEFAULT_MIGRATE_ANNOUNCE_INITIAL),
141 DEFINE_PROP_SIZE("announce-max", MigrationState,
142 parameters.announce_max,
143 DEFAULT_MIGRATE_ANNOUNCE_MAX),
144 DEFINE_PROP_SIZE("announce-rounds", MigrationState,
145 parameters.announce_rounds,
146 DEFAULT_MIGRATE_ANNOUNCE_ROUNDS),
147 DEFINE_PROP_SIZE("announce-step", MigrationState,
148 parameters.announce_step,
149 DEFAULT_MIGRATE_ANNOUNCE_STEP),
150 DEFINE_PROP_STRING("tls-creds", MigrationState, parameters.tls_creds),
151 DEFINE_PROP_STRING("tls-hostname", MigrationState, parameters.tls_hostname),
152 DEFINE_PROP_STRING("tls-authz", MigrationState, parameters.tls_authz),
153 DEFINE_PROP_UINT64("x-vcpu-dirty-limit-period", MigrationState,
154 parameters.x_vcpu_dirty_limit_period,
155 DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD),
156 DEFINE_PROP_UINT64("vcpu-dirty-limit", MigrationState,
157 parameters.vcpu_dirty_limit,
158 DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT),
159 DEFINE_PROP_MIG_MODE("mode", MigrationState,
160 parameters.mode,
161 MIG_MODE_NORMAL),
162 DEFINE_PROP_ZERO_PAGE_DETECTION("zero-page-detection", MigrationState,
163 parameters.zero_page_detection,
164 ZERO_PAGE_DETECTION_MULTIFD),
166 /* Migration capabilities */
167 DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE),
168 DEFINE_PROP_MIG_CAP("x-rdma-pin-all", MIGRATION_CAPABILITY_RDMA_PIN_ALL),
169 DEFINE_PROP_MIG_CAP("x-auto-converge", MIGRATION_CAPABILITY_AUTO_CONVERGE),
170 DEFINE_PROP_MIG_CAP("x-zero-blocks", MIGRATION_CAPABILITY_ZERO_BLOCKS),
171 DEFINE_PROP_MIG_CAP("x-events", MIGRATION_CAPABILITY_EVENTS),
172 DEFINE_PROP_MIG_CAP("x-postcopy-ram", MIGRATION_CAPABILITY_POSTCOPY_RAM),
173 DEFINE_PROP_MIG_CAP("x-postcopy-preempt",
174 MIGRATION_CAPABILITY_POSTCOPY_PREEMPT),
175 DEFINE_PROP_MIG_CAP("x-colo", MIGRATION_CAPABILITY_X_COLO),
176 DEFINE_PROP_MIG_CAP("x-release-ram", MIGRATION_CAPABILITY_RELEASE_RAM),
177 DEFINE_PROP_MIG_CAP("x-return-path", MIGRATION_CAPABILITY_RETURN_PATH),
178 DEFINE_PROP_MIG_CAP("x-multifd", MIGRATION_CAPABILITY_MULTIFD),
179 DEFINE_PROP_MIG_CAP("x-background-snapshot",
180 MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT),
181 #ifdef CONFIG_LINUX
182 DEFINE_PROP_MIG_CAP("x-zero-copy-send",
183 MIGRATION_CAPABILITY_ZERO_COPY_SEND),
184 #endif
185 DEFINE_PROP_MIG_CAP("x-switchover-ack",
186 MIGRATION_CAPABILITY_SWITCHOVER_ACK),
187 DEFINE_PROP_MIG_CAP("x-dirty-limit", MIGRATION_CAPABILITY_DIRTY_LIMIT),
188 DEFINE_PROP_MIG_CAP("mapped-ram", MIGRATION_CAPABILITY_MAPPED_RAM),
189 DEFINE_PROP_END_OF_LIST(),
192 bool migrate_auto_converge(void)
194 MigrationState *s = migrate_get_current();
196 return s->capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE];
199 bool migrate_background_snapshot(void)
201 MigrationState *s = migrate_get_current();
203 return s->capabilities[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT];
206 bool migrate_colo(void)
208 MigrationState *s = migrate_get_current();
210 return s->capabilities[MIGRATION_CAPABILITY_X_COLO];
213 bool migrate_dirty_bitmaps(void)
215 MigrationState *s = migrate_get_current();
217 return s->capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS];
220 bool migrate_dirty_limit(void)
222 MigrationState *s = migrate_get_current();
224 return s->capabilities[MIGRATION_CAPABILITY_DIRTY_LIMIT];
227 bool migrate_events(void)
229 MigrationState *s = migrate_get_current();
231 return s->capabilities[MIGRATION_CAPABILITY_EVENTS];
234 bool migrate_mapped_ram(void)
236 MigrationState *s = migrate_get_current();
238 return s->capabilities[MIGRATION_CAPABILITY_MAPPED_RAM];
241 bool migrate_ignore_shared(void)
243 MigrationState *s = migrate_get_current();
245 return s->capabilities[MIGRATION_CAPABILITY_X_IGNORE_SHARED];
248 bool migrate_late_block_activate(void)
250 MigrationState *s = migrate_get_current();
252 return s->capabilities[MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE];
255 bool migrate_multifd(void)
257 MigrationState *s = migrate_get_current();
259 return s->capabilities[MIGRATION_CAPABILITY_MULTIFD];
262 bool migrate_pause_before_switchover(void)
264 MigrationState *s = migrate_get_current();
266 return s->capabilities[MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER];
269 bool migrate_postcopy_blocktime(void)
271 MigrationState *s = migrate_get_current();
273 return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME];
276 bool migrate_postcopy_preempt(void)
278 MigrationState *s = migrate_get_current();
280 return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT];
283 bool migrate_postcopy_ram(void)
285 MigrationState *s = migrate_get_current();
287 return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM];
290 bool migrate_rdma_pin_all(void)
292 MigrationState *s = migrate_get_current();
294 return s->capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL];
297 bool migrate_release_ram(void)
299 MigrationState *s = migrate_get_current();
301 return s->capabilities[MIGRATION_CAPABILITY_RELEASE_RAM];
304 bool migrate_return_path(void)
306 MigrationState *s = migrate_get_current();
308 return s->capabilities[MIGRATION_CAPABILITY_RETURN_PATH];
311 bool migrate_switchover_ack(void)
313 MigrationState *s = migrate_get_current();
315 return s->capabilities[MIGRATION_CAPABILITY_SWITCHOVER_ACK];
318 bool migrate_validate_uuid(void)
320 MigrationState *s = migrate_get_current();
322 return s->capabilities[MIGRATION_CAPABILITY_VALIDATE_UUID];
325 bool migrate_xbzrle(void)
327 MigrationState *s = migrate_get_current();
329 return s->capabilities[MIGRATION_CAPABILITY_XBZRLE];
332 bool migrate_zero_blocks(void)
334 MigrationState *s = migrate_get_current();
336 return s->capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS];
339 bool migrate_zero_copy_send(void)
341 MigrationState *s = migrate_get_current();
343 return s->capabilities[MIGRATION_CAPABILITY_ZERO_COPY_SEND];
346 /* pseudo capabilities */
348 bool migrate_multifd_flush_after_each_section(void)
350 MigrationState *s = migrate_get_current();
352 return s->multifd_flush_after_each_section;
355 bool migrate_postcopy(void)
357 return migrate_postcopy_ram() || migrate_dirty_bitmaps();
360 bool migrate_rdma(void)
362 MigrationState *s = migrate_get_current();
364 return s->rdma_migration;
367 bool migrate_tls(void)
369 MigrationState *s = migrate_get_current();
371 return s->parameters.tls_creds && *s->parameters.tls_creds;
374 typedef enum WriteTrackingSupport {
375 WT_SUPPORT_UNKNOWN = 0,
376 WT_SUPPORT_ABSENT,
377 WT_SUPPORT_AVAILABLE,
378 WT_SUPPORT_COMPATIBLE
379 } WriteTrackingSupport;
381 static
382 WriteTrackingSupport migrate_query_write_tracking(void)
384 /* Check if kernel supports required UFFD features */
385 if (!ram_write_tracking_available()) {
386 return WT_SUPPORT_ABSENT;
389 * Check if current memory configuration is
390 * compatible with required UFFD features.
392 if (!ram_write_tracking_compatible()) {
393 return WT_SUPPORT_AVAILABLE;
396 return WT_SUPPORT_COMPATIBLE;
399 /* Migration capabilities set */
400 struct MigrateCapsSet {
401 int size; /* Capability set size */
402 MigrationCapability caps[]; /* Variadic array of capabilities */
404 typedef struct MigrateCapsSet MigrateCapsSet;
406 /* Define and initialize MigrateCapsSet */
407 #define INITIALIZE_MIGRATE_CAPS_SET(_name, ...) \
408 MigrateCapsSet _name = { \
409 .size = sizeof((int []) { __VA_ARGS__ }) / sizeof(int), \
410 .caps = { __VA_ARGS__ } \
413 /* Background-snapshot compatibility check list */
414 static const
415 INITIALIZE_MIGRATE_CAPS_SET(check_caps_background_snapshot,
416 MIGRATION_CAPABILITY_POSTCOPY_RAM,
417 MIGRATION_CAPABILITY_DIRTY_BITMAPS,
418 MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME,
419 MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE,
420 MIGRATION_CAPABILITY_RETURN_PATH,
421 MIGRATION_CAPABILITY_MULTIFD,
422 MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER,
423 MIGRATION_CAPABILITY_AUTO_CONVERGE,
424 MIGRATION_CAPABILITY_RELEASE_RAM,
425 MIGRATION_CAPABILITY_RDMA_PIN_ALL,
426 MIGRATION_CAPABILITY_XBZRLE,
427 MIGRATION_CAPABILITY_X_COLO,
428 MIGRATION_CAPABILITY_VALIDATE_UUID,
429 MIGRATION_CAPABILITY_ZERO_COPY_SEND);
431 static bool migrate_incoming_started(void)
433 return !!migration_incoming_get_current()->transport_data;
437 * @migration_caps_check - check capability compatibility
439 * @old_caps: old capability list
440 * @new_caps: new capability list
441 * @errp: set *errp if the check failed, with reason
443 * Returns true if check passed, otherwise false.
445 bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)
447 ERRP_GUARD();
448 MigrationIncomingState *mis = migration_incoming_get_current();
450 #ifndef CONFIG_REPLICATION
451 if (new_caps[MIGRATION_CAPABILITY_X_COLO]) {
452 error_setg(errp, "QEMU compiled without replication module"
453 " can't enable COLO");
454 error_append_hint(errp, "Please enable replication before COLO.\n");
455 return false;
457 #endif
459 if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) {
460 /* This check is reasonably expensive, so only when it's being
461 * set the first time, also it's only the destination that needs
462 * special support.
464 if (!old_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM] &&
465 runstate_check(RUN_STATE_INMIGRATE) &&
466 !postcopy_ram_supported_by_host(mis, errp)) {
467 error_prepend(errp, "Postcopy is not supported: ");
468 return false;
471 if (new_caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED]) {
472 error_setg(errp, "Postcopy is not compatible with ignore-shared");
473 return false;
476 if (new_caps[MIGRATION_CAPABILITY_MULTIFD]) {
477 error_setg(errp, "Postcopy is not yet compatible with multifd");
478 return false;
482 if (new_caps[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT]) {
483 WriteTrackingSupport wt_support;
484 int idx;
486 * Check if 'background-snapshot' capability is supported by
487 * host kernel and compatible with guest memory configuration.
489 wt_support = migrate_query_write_tracking();
490 if (wt_support < WT_SUPPORT_AVAILABLE) {
491 error_setg(errp, "Background-snapshot is not supported by host kernel");
492 return false;
494 if (wt_support < WT_SUPPORT_COMPATIBLE) {
495 error_setg(errp, "Background-snapshot is not compatible "
496 "with guest memory configuration");
497 return false;
501 * Check if there are any migration capabilities
502 * incompatible with 'background-snapshot'.
504 for (idx = 0; idx < check_caps_background_snapshot.size; idx++) {
505 int incomp_cap = check_caps_background_snapshot.caps[idx];
506 if (new_caps[incomp_cap]) {
507 error_setg(errp,
508 "Background-snapshot is not compatible with %s",
509 MigrationCapability_str(incomp_cap));
510 return false;
515 #ifdef CONFIG_LINUX
516 if (new_caps[MIGRATION_CAPABILITY_ZERO_COPY_SEND] &&
517 (!new_caps[MIGRATION_CAPABILITY_MULTIFD] ||
518 new_caps[MIGRATION_CAPABILITY_XBZRLE] ||
519 migrate_multifd_compression() ||
520 migrate_tls())) {
521 error_setg(errp,
522 "Zero copy only available for non-compressed non-TLS multifd migration");
523 return false;
525 #else
526 if (new_caps[MIGRATION_CAPABILITY_ZERO_COPY_SEND]) {
527 error_setg(errp,
528 "Zero copy currently only available on Linux");
529 return false;
531 #endif
533 if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT]) {
534 if (!new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) {
535 error_setg(errp, "Postcopy preempt requires postcopy-ram");
536 return false;
539 if (migrate_incoming_started()) {
540 error_setg(errp,
541 "Postcopy preempt must be set before incoming starts");
542 return false;
546 if (new_caps[MIGRATION_CAPABILITY_MULTIFD]) {
547 if (migrate_incoming_started()) {
548 error_setg(errp, "Multifd must be set before incoming starts");
549 return false;
553 if (new_caps[MIGRATION_CAPABILITY_SWITCHOVER_ACK]) {
554 if (!new_caps[MIGRATION_CAPABILITY_RETURN_PATH]) {
555 error_setg(errp, "Capability 'switchover-ack' requires capability "
556 "'return-path'");
557 return false;
560 if (new_caps[MIGRATION_CAPABILITY_DIRTY_LIMIT]) {
561 if (new_caps[MIGRATION_CAPABILITY_AUTO_CONVERGE]) {
562 error_setg(errp, "dirty-limit conflicts with auto-converge"
563 " either of then available currently");
564 return false;
567 if (!kvm_enabled() || !kvm_dirty_ring_enabled()) {
568 error_setg(errp, "dirty-limit requires KVM with accelerator"
569 " property 'dirty-ring-size' set");
570 return false;
574 if (new_caps[MIGRATION_CAPABILITY_MULTIFD]) {
575 if (new_caps[MIGRATION_CAPABILITY_XBZRLE]) {
576 error_setg(errp, "Multifd is not compatible with xbzrle");
577 return false;
581 if (new_caps[MIGRATION_CAPABILITY_MAPPED_RAM]) {
582 if (new_caps[MIGRATION_CAPABILITY_XBZRLE]) {
583 error_setg(errp,
584 "Mapped-ram migration is incompatible with xbzrle");
585 return false;
588 if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) {
589 error_setg(errp,
590 "Mapped-ram migration is incompatible with postcopy");
591 return false;
595 return true;
598 bool migrate_cap_set(int cap, bool value, Error **errp)
600 MigrationState *s = migrate_get_current();
601 bool new_caps[MIGRATION_CAPABILITY__MAX];
603 if (migration_is_running()) {
604 error_setg(errp, "There's a migration process in progress");
605 return false;
608 memcpy(new_caps, s->capabilities, sizeof(new_caps));
609 new_caps[cap] = value;
611 if (!migrate_caps_check(s->capabilities, new_caps, errp)) {
612 return false;
614 s->capabilities[cap] = value;
615 return true;
618 MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp)
620 MigrationCapabilityStatusList *head = NULL, **tail = &head;
621 MigrationCapabilityStatus *caps;
622 MigrationState *s = migrate_get_current();
623 int i;
625 for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
626 caps = g_malloc0(sizeof(*caps));
627 caps->capability = i;
628 caps->state = s->capabilities[i];
629 QAPI_LIST_APPEND(tail, caps);
632 return head;
635 void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
636 Error **errp)
638 MigrationState *s = migrate_get_current();
639 MigrationCapabilityStatusList *cap;
640 bool new_caps[MIGRATION_CAPABILITY__MAX];
642 if (migration_is_running() || migration_in_colo_state()) {
643 error_setg(errp, "There's a migration process in progress");
644 return;
647 memcpy(new_caps, s->capabilities, sizeof(new_caps));
648 for (cap = params; cap; cap = cap->next) {
649 new_caps[cap->value->capability] = cap->value->state;
652 if (!migrate_caps_check(s->capabilities, new_caps, errp)) {
653 return;
656 for (cap = params; cap; cap = cap->next) {
657 s->capabilities[cap->value->capability] = cap->value->state;
661 /* parameters */
663 const BitmapMigrationNodeAliasList *migrate_block_bitmap_mapping(void)
665 MigrationState *s = migrate_get_current();
667 return s->parameters.block_bitmap_mapping;
670 bool migrate_has_block_bitmap_mapping(void)
672 MigrationState *s = migrate_get_current();
674 return s->parameters.has_block_bitmap_mapping;
677 uint32_t migrate_checkpoint_delay(void)
679 MigrationState *s = migrate_get_current();
681 return s->parameters.x_checkpoint_delay;
684 uint8_t migrate_cpu_throttle_increment(void)
686 MigrationState *s = migrate_get_current();
688 return s->parameters.cpu_throttle_increment;
691 uint8_t migrate_cpu_throttle_initial(void)
693 MigrationState *s = migrate_get_current();
695 return s->parameters.cpu_throttle_initial;
698 bool migrate_cpu_throttle_tailslow(void)
700 MigrationState *s = migrate_get_current();
702 return s->parameters.cpu_throttle_tailslow;
705 bool migrate_direct_io(void)
707 MigrationState *s = migrate_get_current();
710 * O_DIRECT is only supported with mapped-ram and multifd.
712 * mapped-ram is needed because filesystems impose restrictions on
713 * O_DIRECT IO alignment (see MAPPED_RAM_FILE_OFFSET_ALIGNMENT).
715 * multifd is needed to keep the unaligned portion of the stream
716 * isolated to the main migration thread while multifd channels
717 * process the aligned data with O_DIRECT enabled.
719 return s->parameters.direct_io &&
720 s->capabilities[MIGRATION_CAPABILITY_MAPPED_RAM] &&
721 s->capabilities[MIGRATION_CAPABILITY_MULTIFD];
724 uint64_t migrate_downtime_limit(void)
726 MigrationState *s = migrate_get_current();
728 return s->parameters.downtime_limit;
731 uint8_t migrate_max_cpu_throttle(void)
733 MigrationState *s = migrate_get_current();
735 return s->parameters.max_cpu_throttle;
738 uint64_t migrate_max_bandwidth(void)
740 MigrationState *s = migrate_get_current();
742 return s->parameters.max_bandwidth;
745 uint64_t migrate_avail_switchover_bandwidth(void)
747 MigrationState *s = migrate_get_current();
749 return s->parameters.avail_switchover_bandwidth;
752 uint64_t migrate_max_postcopy_bandwidth(void)
754 MigrationState *s = migrate_get_current();
756 return s->parameters.max_postcopy_bandwidth;
759 MigMode migrate_mode(void)
761 MigrationState *s = migrate_get_current();
762 MigMode mode = s->parameters.mode;
764 assert(mode >= 0 && mode < MIG_MODE__MAX);
765 return mode;
768 int migrate_multifd_channels(void)
770 MigrationState *s = migrate_get_current();
772 return s->parameters.multifd_channels;
775 MultiFDCompression migrate_multifd_compression(void)
777 MigrationState *s = migrate_get_current();
779 assert(s->parameters.multifd_compression < MULTIFD_COMPRESSION__MAX);
780 return s->parameters.multifd_compression;
783 int migrate_multifd_zlib_level(void)
785 MigrationState *s = migrate_get_current();
787 return s->parameters.multifd_zlib_level;
790 int migrate_multifd_zstd_level(void)
792 MigrationState *s = migrate_get_current();
794 return s->parameters.multifd_zstd_level;
797 uint8_t migrate_throttle_trigger_threshold(void)
799 MigrationState *s = migrate_get_current();
801 return s->parameters.throttle_trigger_threshold;
804 const char *migrate_tls_authz(void)
806 MigrationState *s = migrate_get_current();
808 return s->parameters.tls_authz;
811 const char *migrate_tls_creds(void)
813 MigrationState *s = migrate_get_current();
815 return s->parameters.tls_creds;
818 const char *migrate_tls_hostname(void)
820 MigrationState *s = migrate_get_current();
822 return s->parameters.tls_hostname;
825 uint64_t migrate_vcpu_dirty_limit_period(void)
827 MigrationState *s = migrate_get_current();
829 return s->parameters.x_vcpu_dirty_limit_period;
832 uint64_t migrate_xbzrle_cache_size(void)
834 MigrationState *s = migrate_get_current();
836 return s->parameters.xbzrle_cache_size;
839 ZeroPageDetection migrate_zero_page_detection(void)
841 MigrationState *s = migrate_get_current();
843 return s->parameters.zero_page_detection;
846 /* parameters helpers */
848 AnnounceParameters *migrate_announce_params(void)
850 static AnnounceParameters ap;
852 MigrationState *s = migrate_get_current();
854 ap.initial = s->parameters.announce_initial;
855 ap.max = s->parameters.announce_max;
856 ap.rounds = s->parameters.announce_rounds;
857 ap.step = s->parameters.announce_step;
859 return &ap;
862 MigrationParameters *qmp_query_migrate_parameters(Error **errp)
864 MigrationParameters *params;
865 MigrationState *s = migrate_get_current();
867 /* TODO use QAPI_CLONE() instead of duplicating it inline */
868 params = g_malloc0(sizeof(*params));
869 params->has_throttle_trigger_threshold = true;
870 params->throttle_trigger_threshold = s->parameters.throttle_trigger_threshold;
871 params->has_cpu_throttle_initial = true;
872 params->cpu_throttle_initial = s->parameters.cpu_throttle_initial;
873 params->has_cpu_throttle_increment = true;
874 params->cpu_throttle_increment = s->parameters.cpu_throttle_increment;
875 params->has_cpu_throttle_tailslow = true;
876 params->cpu_throttle_tailslow = s->parameters.cpu_throttle_tailslow;
877 params->tls_creds = g_strdup(s->parameters.tls_creds);
878 params->tls_hostname = g_strdup(s->parameters.tls_hostname);
879 params->tls_authz = g_strdup(s->parameters.tls_authz ?
880 s->parameters.tls_authz : "");
881 params->has_max_bandwidth = true;
882 params->max_bandwidth = s->parameters.max_bandwidth;
883 params->has_avail_switchover_bandwidth = true;
884 params->avail_switchover_bandwidth = s->parameters.avail_switchover_bandwidth;
885 params->has_downtime_limit = true;
886 params->downtime_limit = s->parameters.downtime_limit;
887 params->has_x_checkpoint_delay = true;
888 params->x_checkpoint_delay = s->parameters.x_checkpoint_delay;
889 params->has_multifd_channels = true;
890 params->multifd_channels = s->parameters.multifd_channels;
891 params->has_multifd_compression = true;
892 params->multifd_compression = s->parameters.multifd_compression;
893 params->has_multifd_zlib_level = true;
894 params->multifd_zlib_level = s->parameters.multifd_zlib_level;
895 params->has_multifd_zstd_level = true;
896 params->multifd_zstd_level = s->parameters.multifd_zstd_level;
897 params->has_xbzrle_cache_size = true;
898 params->xbzrle_cache_size = s->parameters.xbzrle_cache_size;
899 params->has_max_postcopy_bandwidth = true;
900 params->max_postcopy_bandwidth = s->parameters.max_postcopy_bandwidth;
901 params->has_max_cpu_throttle = true;
902 params->max_cpu_throttle = s->parameters.max_cpu_throttle;
903 params->has_announce_initial = true;
904 params->announce_initial = s->parameters.announce_initial;
905 params->has_announce_max = true;
906 params->announce_max = s->parameters.announce_max;
907 params->has_announce_rounds = true;
908 params->announce_rounds = s->parameters.announce_rounds;
909 params->has_announce_step = true;
910 params->announce_step = s->parameters.announce_step;
912 if (s->parameters.has_block_bitmap_mapping) {
913 params->has_block_bitmap_mapping = true;
914 params->block_bitmap_mapping =
915 QAPI_CLONE(BitmapMigrationNodeAliasList,
916 s->parameters.block_bitmap_mapping);
919 params->has_x_vcpu_dirty_limit_period = true;
920 params->x_vcpu_dirty_limit_period = s->parameters.x_vcpu_dirty_limit_period;
921 params->has_vcpu_dirty_limit = true;
922 params->vcpu_dirty_limit = s->parameters.vcpu_dirty_limit;
923 params->has_mode = true;
924 params->mode = s->parameters.mode;
925 params->has_zero_page_detection = true;
926 params->zero_page_detection = s->parameters.zero_page_detection;
927 params->has_direct_io = true;
928 params->direct_io = s->parameters.direct_io;
930 return params;
933 void migrate_params_init(MigrationParameters *params)
935 params->tls_hostname = g_strdup("");
936 params->tls_creds = g_strdup("");
938 /* Set has_* up only for parameter checks */
939 params->has_throttle_trigger_threshold = true;
940 params->has_cpu_throttle_initial = true;
941 params->has_cpu_throttle_increment = true;
942 params->has_cpu_throttle_tailslow = true;
943 params->has_max_bandwidth = true;
944 params->has_downtime_limit = true;
945 params->has_x_checkpoint_delay = true;
946 params->has_multifd_channels = true;
947 params->has_multifd_compression = true;
948 params->has_multifd_zlib_level = true;
949 params->has_multifd_zstd_level = true;
950 params->has_xbzrle_cache_size = true;
951 params->has_max_postcopy_bandwidth = true;
952 params->has_max_cpu_throttle = true;
953 params->has_announce_initial = true;
954 params->has_announce_max = true;
955 params->has_announce_rounds = true;
956 params->has_announce_step = true;
957 params->has_x_vcpu_dirty_limit_period = true;
958 params->has_vcpu_dirty_limit = true;
959 params->has_mode = true;
960 params->has_zero_page_detection = true;
961 params->has_direct_io = true;
965 * Check whether the parameters are valid. Error will be put into errp
966 * (if provided). Return true if valid, otherwise false.
968 bool migrate_params_check(MigrationParameters *params, Error **errp)
970 ERRP_GUARD();
972 if (params->has_throttle_trigger_threshold &&
973 (params->throttle_trigger_threshold < 1 ||
974 params->throttle_trigger_threshold > 100)) {
975 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
976 "throttle_trigger_threshold",
977 "an integer in the range of 1 to 100");
978 return false;
981 if (params->has_cpu_throttle_initial &&
982 (params->cpu_throttle_initial < 1 ||
983 params->cpu_throttle_initial > 99)) {
984 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
985 "cpu_throttle_initial",
986 "an integer in the range of 1 to 99");
987 return false;
990 if (params->has_cpu_throttle_increment &&
991 (params->cpu_throttle_increment < 1 ||
992 params->cpu_throttle_increment > 99)) {
993 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
994 "cpu_throttle_increment",
995 "an integer in the range of 1 to 99");
996 return false;
999 if (params->has_max_bandwidth && (params->max_bandwidth > SIZE_MAX)) {
1000 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1001 "max_bandwidth",
1002 "an integer in the range of 0 to "stringify(SIZE_MAX)
1003 " bytes/second");
1004 return false;
1007 if (params->has_avail_switchover_bandwidth &&
1008 (params->avail_switchover_bandwidth > SIZE_MAX)) {
1009 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1010 "avail_switchover_bandwidth",
1011 "an integer in the range of 0 to "stringify(SIZE_MAX)
1012 " bytes/second");
1013 return false;
1016 if (params->has_downtime_limit &&
1017 (params->downtime_limit > MAX_MIGRATE_DOWNTIME)) {
1018 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1019 "downtime_limit",
1020 "an integer in the range of 0 to "
1021 stringify(MAX_MIGRATE_DOWNTIME)" ms");
1022 return false;
1025 /* x_checkpoint_delay is now always positive */
1027 if (params->has_multifd_channels && (params->multifd_channels < 1)) {
1028 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1029 "multifd_channels",
1030 "a value between 1 and 255");
1031 return false;
1034 if (params->has_multifd_zlib_level &&
1035 (params->multifd_zlib_level > 9)) {
1036 error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "multifd_zlib_level",
1037 "a value between 0 and 9");
1038 return false;
1041 if (params->has_multifd_zstd_level &&
1042 (params->multifd_zstd_level > 20)) {
1043 error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "multifd_zstd_level",
1044 "a value between 0 and 20");
1045 return false;
1048 if (params->has_xbzrle_cache_size &&
1049 (params->xbzrle_cache_size < qemu_target_page_size() ||
1050 !is_power_of_2(params->xbzrle_cache_size))) {
1051 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1052 "xbzrle_cache_size",
1053 "a power of two no less than the target page size");
1054 return false;
1057 if (params->has_max_cpu_throttle &&
1058 (params->max_cpu_throttle < params->cpu_throttle_initial ||
1059 params->max_cpu_throttle > 99)) {
1060 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1061 "max_cpu_throttle",
1062 "an integer in the range of cpu_throttle_initial to 99");
1063 return false;
1066 if (params->has_announce_initial &&
1067 params->announce_initial > 100000) {
1068 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1069 "announce_initial",
1070 "a value between 0 and 100000");
1071 return false;
1073 if (params->has_announce_max &&
1074 params->announce_max > 100000) {
1075 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1076 "announce_max",
1077 "a value between 0 and 100000");
1078 return false;
1080 if (params->has_announce_rounds &&
1081 params->announce_rounds > 1000) {
1082 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1083 "announce_rounds",
1084 "a value between 0 and 1000");
1085 return false;
1087 if (params->has_announce_step &&
1088 (params->announce_step < 1 ||
1089 params->announce_step > 10000)) {
1090 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1091 "announce_step",
1092 "a value between 0 and 10000");
1093 return false;
1096 if (params->has_block_bitmap_mapping &&
1097 !check_dirty_bitmap_mig_alias_map(params->block_bitmap_mapping, errp)) {
1098 error_prepend(errp, "Invalid mapping given for block-bitmap-mapping: ");
1099 return false;
1102 #ifdef CONFIG_LINUX
1103 if (migrate_zero_copy_send() &&
1104 ((params->has_multifd_compression && params->multifd_compression) ||
1105 (params->tls_creds && *params->tls_creds))) {
1106 error_setg(errp,
1107 "Zero copy only available for non-compressed non-TLS multifd migration");
1108 return false;
1110 #endif
1112 if (migrate_mapped_ram() &&
1113 (migrate_multifd_compression() || migrate_tls())) {
1114 error_setg(errp,
1115 "Mapped-ram only available for non-compressed non-TLS multifd migration");
1116 return false;
1119 if (params->has_x_vcpu_dirty_limit_period &&
1120 (params->x_vcpu_dirty_limit_period < 1 ||
1121 params->x_vcpu_dirty_limit_period > 1000)) {
1122 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1123 "x-vcpu-dirty-limit-period",
1124 "a value between 1 and 1000");
1125 return false;
1128 if (params->has_vcpu_dirty_limit &&
1129 (params->vcpu_dirty_limit < 1)) {
1130 error_setg(errp,
1131 "Parameter 'vcpu_dirty_limit' must be greater than 1 MB/s");
1132 return false;
1135 if (params->has_direct_io && params->direct_io && !qemu_has_direct_io()) {
1136 error_setg(errp, "No build-time support for direct-io");
1137 return false;
1140 return true;
1143 static void migrate_params_test_apply(MigrateSetParameters *params,
1144 MigrationParameters *dest)
1146 *dest = migrate_get_current()->parameters;
1148 /* TODO use QAPI_CLONE() instead of duplicating it inline */
1150 if (params->has_throttle_trigger_threshold) {
1151 dest->throttle_trigger_threshold = params->throttle_trigger_threshold;
1154 if (params->has_cpu_throttle_initial) {
1155 dest->cpu_throttle_initial = params->cpu_throttle_initial;
1158 if (params->has_cpu_throttle_increment) {
1159 dest->cpu_throttle_increment = params->cpu_throttle_increment;
1162 if (params->has_cpu_throttle_tailslow) {
1163 dest->cpu_throttle_tailslow = params->cpu_throttle_tailslow;
1166 if (params->tls_creds) {
1167 assert(params->tls_creds->type == QTYPE_QSTRING);
1168 dest->tls_creds = params->tls_creds->u.s;
1171 if (params->tls_hostname) {
1172 assert(params->tls_hostname->type == QTYPE_QSTRING);
1173 dest->tls_hostname = params->tls_hostname->u.s;
1176 if (params->has_max_bandwidth) {
1177 dest->max_bandwidth = params->max_bandwidth;
1180 if (params->has_avail_switchover_bandwidth) {
1181 dest->avail_switchover_bandwidth = params->avail_switchover_bandwidth;
1184 if (params->has_downtime_limit) {
1185 dest->downtime_limit = params->downtime_limit;
1188 if (params->has_x_checkpoint_delay) {
1189 dest->x_checkpoint_delay = params->x_checkpoint_delay;
1192 if (params->has_multifd_channels) {
1193 dest->multifd_channels = params->multifd_channels;
1195 if (params->has_multifd_compression) {
1196 dest->multifd_compression = params->multifd_compression;
1198 if (params->has_multifd_zlib_level) {
1199 dest->multifd_zlib_level = params->multifd_zlib_level;
1201 if (params->has_multifd_zstd_level) {
1202 dest->multifd_zstd_level = params->multifd_zstd_level;
1204 if (params->has_xbzrle_cache_size) {
1205 dest->xbzrle_cache_size = params->xbzrle_cache_size;
1207 if (params->has_max_postcopy_bandwidth) {
1208 dest->max_postcopy_bandwidth = params->max_postcopy_bandwidth;
1210 if (params->has_max_cpu_throttle) {
1211 dest->max_cpu_throttle = params->max_cpu_throttle;
1213 if (params->has_announce_initial) {
1214 dest->announce_initial = params->announce_initial;
1216 if (params->has_announce_max) {
1217 dest->announce_max = params->announce_max;
1219 if (params->has_announce_rounds) {
1220 dest->announce_rounds = params->announce_rounds;
1222 if (params->has_announce_step) {
1223 dest->announce_step = params->announce_step;
1226 if (params->has_block_bitmap_mapping) {
1227 dest->has_block_bitmap_mapping = true;
1228 dest->block_bitmap_mapping = params->block_bitmap_mapping;
1231 if (params->has_x_vcpu_dirty_limit_period) {
1232 dest->x_vcpu_dirty_limit_period =
1233 params->x_vcpu_dirty_limit_period;
1235 if (params->has_vcpu_dirty_limit) {
1236 dest->vcpu_dirty_limit = params->vcpu_dirty_limit;
1239 if (params->has_mode) {
1240 dest->mode = params->mode;
1243 if (params->has_zero_page_detection) {
1244 dest->zero_page_detection = params->zero_page_detection;
1247 if (params->has_direct_io) {
1248 dest->direct_io = params->direct_io;
1252 static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
1254 MigrationState *s = migrate_get_current();
1256 /* TODO use QAPI_CLONE() instead of duplicating it inline */
1258 if (params->has_throttle_trigger_threshold) {
1259 s->parameters.throttle_trigger_threshold = params->throttle_trigger_threshold;
1262 if (params->has_cpu_throttle_initial) {
1263 s->parameters.cpu_throttle_initial = params->cpu_throttle_initial;
1266 if (params->has_cpu_throttle_increment) {
1267 s->parameters.cpu_throttle_increment = params->cpu_throttle_increment;
1270 if (params->has_cpu_throttle_tailslow) {
1271 s->parameters.cpu_throttle_tailslow = params->cpu_throttle_tailslow;
1274 if (params->tls_creds) {
1275 g_free(s->parameters.tls_creds);
1276 assert(params->tls_creds->type == QTYPE_QSTRING);
1277 s->parameters.tls_creds = g_strdup(params->tls_creds->u.s);
1280 if (params->tls_hostname) {
1281 g_free(s->parameters.tls_hostname);
1282 assert(params->tls_hostname->type == QTYPE_QSTRING);
1283 s->parameters.tls_hostname = g_strdup(params->tls_hostname->u.s);
1286 if (params->tls_authz) {
1287 g_free(s->parameters.tls_authz);
1288 assert(params->tls_authz->type == QTYPE_QSTRING);
1289 s->parameters.tls_authz = g_strdup(params->tls_authz->u.s);
1292 if (params->has_max_bandwidth) {
1293 s->parameters.max_bandwidth = params->max_bandwidth;
1294 if (s->to_dst_file && !migration_in_postcopy()) {
1295 migration_rate_set(s->parameters.max_bandwidth);
1299 if (params->has_avail_switchover_bandwidth) {
1300 s->parameters.avail_switchover_bandwidth = params->avail_switchover_bandwidth;
1303 if (params->has_downtime_limit) {
1304 s->parameters.downtime_limit = params->downtime_limit;
1307 if (params->has_x_checkpoint_delay) {
1308 s->parameters.x_checkpoint_delay = params->x_checkpoint_delay;
1309 colo_checkpoint_delay_set();
1312 if (params->has_multifd_channels) {
1313 s->parameters.multifd_channels = params->multifd_channels;
1315 if (params->has_multifd_compression) {
1316 s->parameters.multifd_compression = params->multifd_compression;
1318 if (params->has_multifd_zlib_level) {
1319 s->parameters.multifd_zlib_level = params->multifd_zlib_level;
1321 if (params->has_multifd_zstd_level) {
1322 s->parameters.multifd_zstd_level = params->multifd_zstd_level;
1324 if (params->has_xbzrle_cache_size) {
1325 s->parameters.xbzrle_cache_size = params->xbzrle_cache_size;
1326 xbzrle_cache_resize(params->xbzrle_cache_size, errp);
1328 if (params->has_max_postcopy_bandwidth) {
1329 s->parameters.max_postcopy_bandwidth = params->max_postcopy_bandwidth;
1330 if (s->to_dst_file && migration_in_postcopy()) {
1331 migration_rate_set(s->parameters.max_postcopy_bandwidth);
1334 if (params->has_max_cpu_throttle) {
1335 s->parameters.max_cpu_throttle = params->max_cpu_throttle;
1337 if (params->has_announce_initial) {
1338 s->parameters.announce_initial = params->announce_initial;
1340 if (params->has_announce_max) {
1341 s->parameters.announce_max = params->announce_max;
1343 if (params->has_announce_rounds) {
1344 s->parameters.announce_rounds = params->announce_rounds;
1346 if (params->has_announce_step) {
1347 s->parameters.announce_step = params->announce_step;
1350 if (params->has_block_bitmap_mapping) {
1351 qapi_free_BitmapMigrationNodeAliasList(
1352 s->parameters.block_bitmap_mapping);
1354 s->parameters.has_block_bitmap_mapping = true;
1355 s->parameters.block_bitmap_mapping =
1356 QAPI_CLONE(BitmapMigrationNodeAliasList,
1357 params->block_bitmap_mapping);
1360 if (params->has_x_vcpu_dirty_limit_period) {
1361 s->parameters.x_vcpu_dirty_limit_period =
1362 params->x_vcpu_dirty_limit_period;
1364 if (params->has_vcpu_dirty_limit) {
1365 s->parameters.vcpu_dirty_limit = params->vcpu_dirty_limit;
1368 if (params->has_mode) {
1369 s->parameters.mode = params->mode;
1372 if (params->has_zero_page_detection) {
1373 s->parameters.zero_page_detection = params->zero_page_detection;
1376 if (params->has_direct_io) {
1377 s->parameters.direct_io = params->direct_io;
1381 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
1383 MigrationParameters tmp;
1385 /* TODO Rewrite "" to null instead for all three tls_* parameters */
1386 if (params->tls_creds
1387 && params->tls_creds->type == QTYPE_QNULL) {
1388 qobject_unref(params->tls_creds->u.n);
1389 params->tls_creds->type = QTYPE_QSTRING;
1390 params->tls_creds->u.s = strdup("");
1392 if (params->tls_hostname
1393 && params->tls_hostname->type == QTYPE_QNULL) {
1394 qobject_unref(params->tls_hostname->u.n);
1395 params->tls_hostname->type = QTYPE_QSTRING;
1396 params->tls_hostname->u.s = strdup("");
1398 if (params->tls_authz
1399 && params->tls_authz->type == QTYPE_QNULL) {
1400 qobject_unref(params->tls_authz->u.n);
1401 params->tls_authz->type = QTYPE_QSTRING;
1402 params->tls_authz->u.s = strdup("");
1405 migrate_params_test_apply(params, &tmp);
1407 if (!migrate_params_check(&tmp, errp)) {
1408 /* Invalid parameter */
1409 return;
1412 migrate_params_apply(params, errp);