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 "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"
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
,
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
),
182 DEFINE_PROP_MIG_CAP("x-zero-copy-send",
183 MIGRATION_CAPABILITY_ZERO_COPY_SEND
),
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,
377 WT_SUPPORT_AVAILABLE
,
378 WT_SUPPORT_COMPATIBLE
379 } WriteTrackingSupport
;
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 */
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
)
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");
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
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: ");
471 if (new_caps
[MIGRATION_CAPABILITY_X_IGNORE_SHARED
]) {
472 error_setg(errp
, "Postcopy is not compatible with ignore-shared");
476 if (new_caps
[MIGRATION_CAPABILITY_MULTIFD
]) {
477 error_setg(errp
, "Postcopy is not yet compatible with multifd");
482 if (new_caps
[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT
]) {
483 WriteTrackingSupport wt_support
;
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");
494 if (wt_support
< WT_SUPPORT_COMPATIBLE
) {
495 error_setg(errp
, "Background-snapshot is not compatible "
496 "with guest memory configuration");
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
]) {
508 "Background-snapshot is not compatible with %s",
509 MigrationCapability_str(incomp_cap
));
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() ||
522 "Zero copy only available for non-compressed non-TLS multifd migration");
526 if (new_caps
[MIGRATION_CAPABILITY_ZERO_COPY_SEND
]) {
528 "Zero copy currently only available on Linux");
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");
539 if (migrate_incoming_started()) {
541 "Postcopy preempt must be set before incoming starts");
546 if (new_caps
[MIGRATION_CAPABILITY_MULTIFD
]) {
547 if (migrate_incoming_started()) {
548 error_setg(errp
, "Multifd must be set before incoming starts");
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 "
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");
567 if (!kvm_enabled() || !kvm_dirty_ring_enabled()) {
568 error_setg(errp
, "dirty-limit requires KVM with accelerator"
569 " property 'dirty-ring-size' set");
574 if (new_caps
[MIGRATION_CAPABILITY_MULTIFD
]) {
575 if (new_caps
[MIGRATION_CAPABILITY_XBZRLE
]) {
576 error_setg(errp
, "Multifd is not compatible with xbzrle");
581 if (new_caps
[MIGRATION_CAPABILITY_MAPPED_RAM
]) {
582 if (new_caps
[MIGRATION_CAPABILITY_XBZRLE
]) {
584 "Mapped-ram migration is incompatible with xbzrle");
588 if (new_caps
[MIGRATION_CAPABILITY_POSTCOPY_RAM
]) {
590 "Mapped-ram migration is incompatible with postcopy");
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");
608 memcpy(new_caps
, s
->capabilities
, sizeof(new_caps
));
609 new_caps
[cap
] = value
;
611 if (!migrate_caps_check(s
->capabilities
, new_caps
, errp
)) {
614 s
->capabilities
[cap
] = value
;
618 MigrationCapabilityStatusList
*qmp_query_migrate_capabilities(Error
**errp
)
620 MigrationCapabilityStatusList
*head
= NULL
, **tail
= &head
;
621 MigrationCapabilityStatus
*caps
;
622 MigrationState
*s
= migrate_get_current();
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
);
635 void qmp_migrate_set_capabilities(MigrationCapabilityStatusList
*params
,
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");
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
)) {
656 for (cap
= params
; cap
; cap
= cap
->next
) {
657 s
->capabilities
[cap
->value
->capability
] = cap
->value
->state
;
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 uint64_t migrate_downtime_limit(void)
707 MigrationState
*s
= migrate_get_current();
709 return s
->parameters
.downtime_limit
;
712 uint8_t migrate_max_cpu_throttle(void)
714 MigrationState
*s
= migrate_get_current();
716 return s
->parameters
.max_cpu_throttle
;
719 uint64_t migrate_max_bandwidth(void)
721 MigrationState
*s
= migrate_get_current();
723 return s
->parameters
.max_bandwidth
;
726 uint64_t migrate_avail_switchover_bandwidth(void)
728 MigrationState
*s
= migrate_get_current();
730 return s
->parameters
.avail_switchover_bandwidth
;
733 uint64_t migrate_max_postcopy_bandwidth(void)
735 MigrationState
*s
= migrate_get_current();
737 return s
->parameters
.max_postcopy_bandwidth
;
740 MigMode
migrate_mode(void)
742 MigrationState
*s
= migrate_get_current();
743 MigMode mode
= s
->parameters
.mode
;
745 assert(mode
>= 0 && mode
< MIG_MODE__MAX
);
749 int migrate_multifd_channels(void)
751 MigrationState
*s
= migrate_get_current();
753 return s
->parameters
.multifd_channels
;
756 MultiFDCompression
migrate_multifd_compression(void)
758 MigrationState
*s
= migrate_get_current();
760 assert(s
->parameters
.multifd_compression
< MULTIFD_COMPRESSION__MAX
);
761 return s
->parameters
.multifd_compression
;
764 int migrate_multifd_zlib_level(void)
766 MigrationState
*s
= migrate_get_current();
768 return s
->parameters
.multifd_zlib_level
;
771 int migrate_multifd_zstd_level(void)
773 MigrationState
*s
= migrate_get_current();
775 return s
->parameters
.multifd_zstd_level
;
778 uint8_t migrate_throttle_trigger_threshold(void)
780 MigrationState
*s
= migrate_get_current();
782 return s
->parameters
.throttle_trigger_threshold
;
785 const char *migrate_tls_authz(void)
787 MigrationState
*s
= migrate_get_current();
789 return s
->parameters
.tls_authz
;
792 const char *migrate_tls_creds(void)
794 MigrationState
*s
= migrate_get_current();
796 return s
->parameters
.tls_creds
;
799 const char *migrate_tls_hostname(void)
801 MigrationState
*s
= migrate_get_current();
803 return s
->parameters
.tls_hostname
;
806 uint64_t migrate_vcpu_dirty_limit_period(void)
808 MigrationState
*s
= migrate_get_current();
810 return s
->parameters
.x_vcpu_dirty_limit_period
;
813 uint64_t migrate_xbzrle_cache_size(void)
815 MigrationState
*s
= migrate_get_current();
817 return s
->parameters
.xbzrle_cache_size
;
820 ZeroPageDetection
migrate_zero_page_detection(void)
822 MigrationState
*s
= migrate_get_current();
824 return s
->parameters
.zero_page_detection
;
827 /* parameters helpers */
829 AnnounceParameters
*migrate_announce_params(void)
831 static AnnounceParameters ap
;
833 MigrationState
*s
= migrate_get_current();
835 ap
.initial
= s
->parameters
.announce_initial
;
836 ap
.max
= s
->parameters
.announce_max
;
837 ap
.rounds
= s
->parameters
.announce_rounds
;
838 ap
.step
= s
->parameters
.announce_step
;
843 MigrationParameters
*qmp_query_migrate_parameters(Error
**errp
)
845 MigrationParameters
*params
;
846 MigrationState
*s
= migrate_get_current();
848 /* TODO use QAPI_CLONE() instead of duplicating it inline */
849 params
= g_malloc0(sizeof(*params
));
850 params
->has_throttle_trigger_threshold
= true;
851 params
->throttle_trigger_threshold
= s
->parameters
.throttle_trigger_threshold
;
852 params
->has_cpu_throttle_initial
= true;
853 params
->cpu_throttle_initial
= s
->parameters
.cpu_throttle_initial
;
854 params
->has_cpu_throttle_increment
= true;
855 params
->cpu_throttle_increment
= s
->parameters
.cpu_throttle_increment
;
856 params
->has_cpu_throttle_tailslow
= true;
857 params
->cpu_throttle_tailslow
= s
->parameters
.cpu_throttle_tailslow
;
858 params
->tls_creds
= g_strdup(s
->parameters
.tls_creds
);
859 params
->tls_hostname
= g_strdup(s
->parameters
.tls_hostname
);
860 params
->tls_authz
= g_strdup(s
->parameters
.tls_authz
?
861 s
->parameters
.tls_authz
: "");
862 params
->has_max_bandwidth
= true;
863 params
->max_bandwidth
= s
->parameters
.max_bandwidth
;
864 params
->has_avail_switchover_bandwidth
= true;
865 params
->avail_switchover_bandwidth
= s
->parameters
.avail_switchover_bandwidth
;
866 params
->has_downtime_limit
= true;
867 params
->downtime_limit
= s
->parameters
.downtime_limit
;
868 params
->has_x_checkpoint_delay
= true;
869 params
->x_checkpoint_delay
= s
->parameters
.x_checkpoint_delay
;
870 params
->has_multifd_channels
= true;
871 params
->multifd_channels
= s
->parameters
.multifd_channels
;
872 params
->has_multifd_compression
= true;
873 params
->multifd_compression
= s
->parameters
.multifd_compression
;
874 params
->has_multifd_zlib_level
= true;
875 params
->multifd_zlib_level
= s
->parameters
.multifd_zlib_level
;
876 params
->has_multifd_zstd_level
= true;
877 params
->multifd_zstd_level
= s
->parameters
.multifd_zstd_level
;
878 params
->has_xbzrle_cache_size
= true;
879 params
->xbzrle_cache_size
= s
->parameters
.xbzrle_cache_size
;
880 params
->has_max_postcopy_bandwidth
= true;
881 params
->max_postcopy_bandwidth
= s
->parameters
.max_postcopy_bandwidth
;
882 params
->has_max_cpu_throttle
= true;
883 params
->max_cpu_throttle
= s
->parameters
.max_cpu_throttle
;
884 params
->has_announce_initial
= true;
885 params
->announce_initial
= s
->parameters
.announce_initial
;
886 params
->has_announce_max
= true;
887 params
->announce_max
= s
->parameters
.announce_max
;
888 params
->has_announce_rounds
= true;
889 params
->announce_rounds
= s
->parameters
.announce_rounds
;
890 params
->has_announce_step
= true;
891 params
->announce_step
= s
->parameters
.announce_step
;
893 if (s
->parameters
.has_block_bitmap_mapping
) {
894 params
->has_block_bitmap_mapping
= true;
895 params
->block_bitmap_mapping
=
896 QAPI_CLONE(BitmapMigrationNodeAliasList
,
897 s
->parameters
.block_bitmap_mapping
);
900 params
->has_x_vcpu_dirty_limit_period
= true;
901 params
->x_vcpu_dirty_limit_period
= s
->parameters
.x_vcpu_dirty_limit_period
;
902 params
->has_vcpu_dirty_limit
= true;
903 params
->vcpu_dirty_limit
= s
->parameters
.vcpu_dirty_limit
;
904 params
->has_mode
= true;
905 params
->mode
= s
->parameters
.mode
;
906 params
->has_zero_page_detection
= true;
907 params
->zero_page_detection
= s
->parameters
.zero_page_detection
;
912 void migrate_params_init(MigrationParameters
*params
)
914 params
->tls_hostname
= g_strdup("");
915 params
->tls_creds
= g_strdup("");
917 /* Set has_* up only for parameter checks */
918 params
->has_throttle_trigger_threshold
= true;
919 params
->has_cpu_throttle_initial
= true;
920 params
->has_cpu_throttle_increment
= true;
921 params
->has_cpu_throttle_tailslow
= true;
922 params
->has_max_bandwidth
= true;
923 params
->has_downtime_limit
= true;
924 params
->has_x_checkpoint_delay
= true;
925 params
->has_multifd_channels
= true;
926 params
->has_multifd_compression
= true;
927 params
->has_multifd_zlib_level
= true;
928 params
->has_multifd_zstd_level
= true;
929 params
->has_xbzrle_cache_size
= true;
930 params
->has_max_postcopy_bandwidth
= true;
931 params
->has_max_cpu_throttle
= true;
932 params
->has_announce_initial
= true;
933 params
->has_announce_max
= true;
934 params
->has_announce_rounds
= true;
935 params
->has_announce_step
= true;
936 params
->has_x_vcpu_dirty_limit_period
= true;
937 params
->has_vcpu_dirty_limit
= true;
938 params
->has_mode
= true;
939 params
->has_zero_page_detection
= true;
943 * Check whether the parameters are valid. Error will be put into errp
944 * (if provided). Return true if valid, otherwise false.
946 bool migrate_params_check(MigrationParameters
*params
, Error
**errp
)
950 if (params
->has_throttle_trigger_threshold
&&
951 (params
->throttle_trigger_threshold
< 1 ||
952 params
->throttle_trigger_threshold
> 100)) {
953 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
954 "throttle_trigger_threshold",
955 "an integer in the range of 1 to 100");
959 if (params
->has_cpu_throttle_initial
&&
960 (params
->cpu_throttle_initial
< 1 ||
961 params
->cpu_throttle_initial
> 99)) {
962 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
963 "cpu_throttle_initial",
964 "an integer in the range of 1 to 99");
968 if (params
->has_cpu_throttle_increment
&&
969 (params
->cpu_throttle_increment
< 1 ||
970 params
->cpu_throttle_increment
> 99)) {
971 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
972 "cpu_throttle_increment",
973 "an integer in the range of 1 to 99");
977 if (params
->has_max_bandwidth
&& (params
->max_bandwidth
> SIZE_MAX
)) {
978 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
980 "an integer in the range of 0 to "stringify(SIZE_MAX
)
985 if (params
->has_avail_switchover_bandwidth
&&
986 (params
->avail_switchover_bandwidth
> SIZE_MAX
)) {
987 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
988 "avail_switchover_bandwidth",
989 "an integer in the range of 0 to "stringify(SIZE_MAX
)
994 if (params
->has_downtime_limit
&&
995 (params
->downtime_limit
> MAX_MIGRATE_DOWNTIME
)) {
996 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
998 "an integer in the range of 0 to "
999 stringify(MAX_MIGRATE_DOWNTIME
)" ms");
1003 /* x_checkpoint_delay is now always positive */
1005 if (params
->has_multifd_channels
&& (params
->multifd_channels
< 1)) {
1006 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1008 "a value between 1 and 255");
1012 if (params
->has_multifd_zlib_level
&&
1013 (params
->multifd_zlib_level
> 9)) {
1014 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
, "multifd_zlib_level",
1015 "a value between 0 and 9");
1019 if (params
->has_multifd_zstd_level
&&
1020 (params
->multifd_zstd_level
> 20)) {
1021 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
, "multifd_zstd_level",
1022 "a value between 0 and 20");
1026 if (params
->has_xbzrle_cache_size
&&
1027 (params
->xbzrle_cache_size
< qemu_target_page_size() ||
1028 !is_power_of_2(params
->xbzrle_cache_size
))) {
1029 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1030 "xbzrle_cache_size",
1031 "a power of two no less than the target page size");
1035 if (params
->has_max_cpu_throttle
&&
1036 (params
->max_cpu_throttle
< params
->cpu_throttle_initial
||
1037 params
->max_cpu_throttle
> 99)) {
1038 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1040 "an integer in the range of cpu_throttle_initial to 99");
1044 if (params
->has_announce_initial
&&
1045 params
->announce_initial
> 100000) {
1046 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1048 "a value between 0 and 100000");
1051 if (params
->has_announce_max
&&
1052 params
->announce_max
> 100000) {
1053 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1055 "a value between 0 and 100000");
1058 if (params
->has_announce_rounds
&&
1059 params
->announce_rounds
> 1000) {
1060 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1062 "a value between 0 and 1000");
1065 if (params
->has_announce_step
&&
1066 (params
->announce_step
< 1 ||
1067 params
->announce_step
> 10000)) {
1068 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1070 "a value between 0 and 10000");
1074 if (params
->has_block_bitmap_mapping
&&
1075 !check_dirty_bitmap_mig_alias_map(params
->block_bitmap_mapping
, errp
)) {
1076 error_prepend(errp
, "Invalid mapping given for block-bitmap-mapping: ");
1081 if (migrate_zero_copy_send() &&
1082 ((params
->has_multifd_compression
&& params
->multifd_compression
) ||
1083 (params
->tls_creds
&& *params
->tls_creds
))) {
1085 "Zero copy only available for non-compressed non-TLS multifd migration");
1090 if (migrate_mapped_ram() &&
1091 (migrate_multifd_compression() || migrate_tls())) {
1093 "Mapped-ram only available for non-compressed non-TLS multifd migration");
1097 if (params
->has_x_vcpu_dirty_limit_period
&&
1098 (params
->x_vcpu_dirty_limit_period
< 1 ||
1099 params
->x_vcpu_dirty_limit_period
> 1000)) {
1100 error_setg(errp
, QERR_INVALID_PARAMETER_VALUE
,
1101 "x-vcpu-dirty-limit-period",
1102 "a value between 1 and 1000");
1106 if (params
->has_vcpu_dirty_limit
&&
1107 (params
->vcpu_dirty_limit
< 1)) {
1109 "Parameter 'vcpu_dirty_limit' must be greater than 1 MB/s");
1116 static void migrate_params_test_apply(MigrateSetParameters
*params
,
1117 MigrationParameters
*dest
)
1119 *dest
= migrate_get_current()->parameters
;
1121 /* TODO use QAPI_CLONE() instead of duplicating it inline */
1123 if (params
->has_throttle_trigger_threshold
) {
1124 dest
->throttle_trigger_threshold
= params
->throttle_trigger_threshold
;
1127 if (params
->has_cpu_throttle_initial
) {
1128 dest
->cpu_throttle_initial
= params
->cpu_throttle_initial
;
1131 if (params
->has_cpu_throttle_increment
) {
1132 dest
->cpu_throttle_increment
= params
->cpu_throttle_increment
;
1135 if (params
->has_cpu_throttle_tailslow
) {
1136 dest
->cpu_throttle_tailslow
= params
->cpu_throttle_tailslow
;
1139 if (params
->tls_creds
) {
1140 assert(params
->tls_creds
->type
== QTYPE_QSTRING
);
1141 dest
->tls_creds
= params
->tls_creds
->u
.s
;
1144 if (params
->tls_hostname
) {
1145 assert(params
->tls_hostname
->type
== QTYPE_QSTRING
);
1146 dest
->tls_hostname
= params
->tls_hostname
->u
.s
;
1149 if (params
->has_max_bandwidth
) {
1150 dest
->max_bandwidth
= params
->max_bandwidth
;
1153 if (params
->has_avail_switchover_bandwidth
) {
1154 dest
->avail_switchover_bandwidth
= params
->avail_switchover_bandwidth
;
1157 if (params
->has_downtime_limit
) {
1158 dest
->downtime_limit
= params
->downtime_limit
;
1161 if (params
->has_x_checkpoint_delay
) {
1162 dest
->x_checkpoint_delay
= params
->x_checkpoint_delay
;
1165 if (params
->has_multifd_channels
) {
1166 dest
->multifd_channels
= params
->multifd_channels
;
1168 if (params
->has_multifd_compression
) {
1169 dest
->multifd_compression
= params
->multifd_compression
;
1171 if (params
->has_multifd_zlib_level
) {
1172 dest
->multifd_zlib_level
= params
->multifd_zlib_level
;
1174 if (params
->has_multifd_zstd_level
) {
1175 dest
->multifd_zstd_level
= params
->multifd_zstd_level
;
1177 if (params
->has_xbzrle_cache_size
) {
1178 dest
->xbzrle_cache_size
= params
->xbzrle_cache_size
;
1180 if (params
->has_max_postcopy_bandwidth
) {
1181 dest
->max_postcopy_bandwidth
= params
->max_postcopy_bandwidth
;
1183 if (params
->has_max_cpu_throttle
) {
1184 dest
->max_cpu_throttle
= params
->max_cpu_throttle
;
1186 if (params
->has_announce_initial
) {
1187 dest
->announce_initial
= params
->announce_initial
;
1189 if (params
->has_announce_max
) {
1190 dest
->announce_max
= params
->announce_max
;
1192 if (params
->has_announce_rounds
) {
1193 dest
->announce_rounds
= params
->announce_rounds
;
1195 if (params
->has_announce_step
) {
1196 dest
->announce_step
= params
->announce_step
;
1199 if (params
->has_block_bitmap_mapping
) {
1200 dest
->has_block_bitmap_mapping
= true;
1201 dest
->block_bitmap_mapping
= params
->block_bitmap_mapping
;
1204 if (params
->has_x_vcpu_dirty_limit_period
) {
1205 dest
->x_vcpu_dirty_limit_period
=
1206 params
->x_vcpu_dirty_limit_period
;
1208 if (params
->has_vcpu_dirty_limit
) {
1209 dest
->vcpu_dirty_limit
= params
->vcpu_dirty_limit
;
1212 if (params
->has_mode
) {
1213 dest
->mode
= params
->mode
;
1216 if (params
->has_zero_page_detection
) {
1217 dest
->zero_page_detection
= params
->zero_page_detection
;
1221 static void migrate_params_apply(MigrateSetParameters
*params
, Error
**errp
)
1223 MigrationState
*s
= migrate_get_current();
1225 /* TODO use QAPI_CLONE() instead of duplicating it inline */
1227 if (params
->has_throttle_trigger_threshold
) {
1228 s
->parameters
.throttle_trigger_threshold
= params
->throttle_trigger_threshold
;
1231 if (params
->has_cpu_throttle_initial
) {
1232 s
->parameters
.cpu_throttle_initial
= params
->cpu_throttle_initial
;
1235 if (params
->has_cpu_throttle_increment
) {
1236 s
->parameters
.cpu_throttle_increment
= params
->cpu_throttle_increment
;
1239 if (params
->has_cpu_throttle_tailslow
) {
1240 s
->parameters
.cpu_throttle_tailslow
= params
->cpu_throttle_tailslow
;
1243 if (params
->tls_creds
) {
1244 g_free(s
->parameters
.tls_creds
);
1245 assert(params
->tls_creds
->type
== QTYPE_QSTRING
);
1246 s
->parameters
.tls_creds
= g_strdup(params
->tls_creds
->u
.s
);
1249 if (params
->tls_hostname
) {
1250 g_free(s
->parameters
.tls_hostname
);
1251 assert(params
->tls_hostname
->type
== QTYPE_QSTRING
);
1252 s
->parameters
.tls_hostname
= g_strdup(params
->tls_hostname
->u
.s
);
1255 if (params
->tls_authz
) {
1256 g_free(s
->parameters
.tls_authz
);
1257 assert(params
->tls_authz
->type
== QTYPE_QSTRING
);
1258 s
->parameters
.tls_authz
= g_strdup(params
->tls_authz
->u
.s
);
1261 if (params
->has_max_bandwidth
) {
1262 s
->parameters
.max_bandwidth
= params
->max_bandwidth
;
1263 if (s
->to_dst_file
&& !migration_in_postcopy()) {
1264 migration_rate_set(s
->parameters
.max_bandwidth
);
1268 if (params
->has_avail_switchover_bandwidth
) {
1269 s
->parameters
.avail_switchover_bandwidth
= params
->avail_switchover_bandwidth
;
1272 if (params
->has_downtime_limit
) {
1273 s
->parameters
.downtime_limit
= params
->downtime_limit
;
1276 if (params
->has_x_checkpoint_delay
) {
1277 s
->parameters
.x_checkpoint_delay
= params
->x_checkpoint_delay
;
1278 colo_checkpoint_delay_set();
1281 if (params
->has_multifd_channels
) {
1282 s
->parameters
.multifd_channels
= params
->multifd_channels
;
1284 if (params
->has_multifd_compression
) {
1285 s
->parameters
.multifd_compression
= params
->multifd_compression
;
1287 if (params
->has_multifd_zlib_level
) {
1288 s
->parameters
.multifd_zlib_level
= params
->multifd_zlib_level
;
1290 if (params
->has_multifd_zstd_level
) {
1291 s
->parameters
.multifd_zstd_level
= params
->multifd_zstd_level
;
1293 if (params
->has_xbzrle_cache_size
) {
1294 s
->parameters
.xbzrle_cache_size
= params
->xbzrle_cache_size
;
1295 xbzrle_cache_resize(params
->xbzrle_cache_size
, errp
);
1297 if (params
->has_max_postcopy_bandwidth
) {
1298 s
->parameters
.max_postcopy_bandwidth
= params
->max_postcopy_bandwidth
;
1299 if (s
->to_dst_file
&& migration_in_postcopy()) {
1300 migration_rate_set(s
->parameters
.max_postcopy_bandwidth
);
1303 if (params
->has_max_cpu_throttle
) {
1304 s
->parameters
.max_cpu_throttle
= params
->max_cpu_throttle
;
1306 if (params
->has_announce_initial
) {
1307 s
->parameters
.announce_initial
= params
->announce_initial
;
1309 if (params
->has_announce_max
) {
1310 s
->parameters
.announce_max
= params
->announce_max
;
1312 if (params
->has_announce_rounds
) {
1313 s
->parameters
.announce_rounds
= params
->announce_rounds
;
1315 if (params
->has_announce_step
) {
1316 s
->parameters
.announce_step
= params
->announce_step
;
1319 if (params
->has_block_bitmap_mapping
) {
1320 qapi_free_BitmapMigrationNodeAliasList(
1321 s
->parameters
.block_bitmap_mapping
);
1323 s
->parameters
.has_block_bitmap_mapping
= true;
1324 s
->parameters
.block_bitmap_mapping
=
1325 QAPI_CLONE(BitmapMigrationNodeAliasList
,
1326 params
->block_bitmap_mapping
);
1329 if (params
->has_x_vcpu_dirty_limit_period
) {
1330 s
->parameters
.x_vcpu_dirty_limit_period
=
1331 params
->x_vcpu_dirty_limit_period
;
1333 if (params
->has_vcpu_dirty_limit
) {
1334 s
->parameters
.vcpu_dirty_limit
= params
->vcpu_dirty_limit
;
1337 if (params
->has_mode
) {
1338 s
->parameters
.mode
= params
->mode
;
1341 if (params
->has_zero_page_detection
) {
1342 s
->parameters
.zero_page_detection
= params
->zero_page_detection
;
1346 void qmp_migrate_set_parameters(MigrateSetParameters
*params
, Error
**errp
)
1348 MigrationParameters tmp
;
1350 /* TODO Rewrite "" to null instead for all three tls_* parameters */
1351 if (params
->tls_creds
1352 && params
->tls_creds
->type
== QTYPE_QNULL
) {
1353 qobject_unref(params
->tls_creds
->u
.n
);
1354 params
->tls_creds
->type
= QTYPE_QSTRING
;
1355 params
->tls_creds
->u
.s
= strdup("");
1357 if (params
->tls_hostname
1358 && params
->tls_hostname
->type
== QTYPE_QNULL
) {
1359 qobject_unref(params
->tls_hostname
->u
.n
);
1360 params
->tls_hostname
->type
= QTYPE_QSTRING
;
1361 params
->tls_hostname
->u
.s
= strdup("");
1363 if (params
->tls_authz
1364 && params
->tls_authz
->type
== QTYPE_QNULL
) {
1365 qobject_unref(params
->tls_authz
->u
.n
);
1366 params
->tls_authz
->type
= QTYPE_QSTRING
;
1367 params
->tls_authz
->u
.s
= strdup("");
1370 migrate_params_test_apply(params
, &tmp
);
1372 if (!migrate_params_check(&tmp
, errp
)) {
1373 /* Invalid parameter */
1377 migrate_params_apply(params
, errp
);