qapi/migration: Introduce x-vcpu-dirty-limit-period parameter
[qemu/ar7.git] / migration / options.c
blob1de63ba775818166379c789cb6c1119302ee3d99
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 "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"
28 #include "ram.h"
29 #include "options.h"
31 /* Maximum migrate downtime set to 2000 seconds */
32 #define MAX_MIGRATE_DOWNTIME_SECONDS 2000
33 #define MAX_MIGRATE_DOWNTIME (MAX_MIGRATE_DOWNTIME_SECONDS * 1000)
35 #define MAX_THROTTLE (128 << 20) /* Migration transfer speed throttling */
37 /* Time in milliseconds we are allowed to stop the source,
38 * for sending the last part */
39 #define DEFAULT_MIGRATE_SET_DOWNTIME 300
41 /* Default compression thread count */
42 #define DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT 8
43 /* Default decompression thread count, usually decompression is at
44 * least 4 times as fast as compression.*/
45 #define DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT 2
46 /*0: means nocompress, 1: best speed, ... 9: best compress ratio */
47 #define DEFAULT_MIGRATE_COMPRESS_LEVEL 1
48 /* Define default autoconverge cpu throttle migration parameters */
49 #define DEFAULT_MIGRATE_THROTTLE_TRIGGER_THRESHOLD 50
50 #define DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL 20
51 #define DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT 10
52 #define DEFAULT_MIGRATE_MAX_CPU_THROTTLE 99
54 /* Migration XBZRLE default cache size */
55 #define DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE (64 * 1024 * 1024)
57 /* The delay time (in ms) between two COLO checkpoints */
58 #define DEFAULT_MIGRATE_X_CHECKPOINT_DELAY (200 * 100)
59 #define DEFAULT_MIGRATE_MULTIFD_CHANNELS 2
60 #define DEFAULT_MIGRATE_MULTIFD_COMPRESSION MULTIFD_COMPRESSION_NONE
61 /* 0: means nocompress, 1: best speed, ... 9: best compress ratio */
62 #define DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL 1
63 /* 0: means nocompress, 1: best speed, ... 20: best compress ratio */
64 #define DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL 1
66 /* Background transfer rate for postcopy, 0 means unlimited, note
67 * that page requests can still exceed this limit.
69 #define DEFAULT_MIGRATE_MAX_POSTCOPY_BANDWIDTH 0
72 * Parameters for self_announce_delay giving a stream of RARP/ARP
73 * packets after migration.
75 #define DEFAULT_MIGRATE_ANNOUNCE_INITIAL 50
76 #define DEFAULT_MIGRATE_ANNOUNCE_MAX 550
77 #define DEFAULT_MIGRATE_ANNOUNCE_ROUNDS 5
78 #define DEFAULT_MIGRATE_ANNOUNCE_STEP 100
80 #define DEFINE_PROP_MIG_CAP(name, x) \
81 DEFINE_PROP_BOOL(name, MigrationState, capabilities[x], false)
83 #define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD 1000 /* milliseconds */
85 Property migration_properties[] = {
86 DEFINE_PROP_BOOL("store-global-state", MigrationState,
87 store_global_state, true),
88 DEFINE_PROP_BOOL("send-configuration", MigrationState,
89 send_configuration, true),
90 DEFINE_PROP_BOOL("send-section-footer", MigrationState,
91 send_section_footer, true),
92 DEFINE_PROP_BOOL("decompress-error-check", MigrationState,
93 decompress_error_check, true),
94 DEFINE_PROP_BOOL("multifd-flush-after-each-section", MigrationState,
95 multifd_flush_after_each_section, false),
96 DEFINE_PROP_UINT8("x-clear-bitmap-shift", MigrationState,
97 clear_bitmap_shift, CLEAR_BITMAP_SHIFT_DEFAULT),
98 DEFINE_PROP_BOOL("x-preempt-pre-7-2", MigrationState,
99 preempt_pre_7_2, false),
101 /* Migration parameters */
102 DEFINE_PROP_UINT8("x-compress-level", MigrationState,
103 parameters.compress_level,
104 DEFAULT_MIGRATE_COMPRESS_LEVEL),
105 DEFINE_PROP_UINT8("x-compress-threads", MigrationState,
106 parameters.compress_threads,
107 DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT),
108 DEFINE_PROP_BOOL("x-compress-wait-thread", MigrationState,
109 parameters.compress_wait_thread, true),
110 DEFINE_PROP_UINT8("x-decompress-threads", MigrationState,
111 parameters.decompress_threads,
112 DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT),
113 DEFINE_PROP_UINT8("x-throttle-trigger-threshold", MigrationState,
114 parameters.throttle_trigger_threshold,
115 DEFAULT_MIGRATE_THROTTLE_TRIGGER_THRESHOLD),
116 DEFINE_PROP_UINT8("x-cpu-throttle-initial", MigrationState,
117 parameters.cpu_throttle_initial,
118 DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL),
119 DEFINE_PROP_UINT8("x-cpu-throttle-increment", MigrationState,
120 parameters.cpu_throttle_increment,
121 DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT),
122 DEFINE_PROP_BOOL("x-cpu-throttle-tailslow", MigrationState,
123 parameters.cpu_throttle_tailslow, false),
124 DEFINE_PROP_SIZE("x-max-bandwidth", MigrationState,
125 parameters.max_bandwidth, MAX_THROTTLE),
126 DEFINE_PROP_UINT64("x-downtime-limit", MigrationState,
127 parameters.downtime_limit,
128 DEFAULT_MIGRATE_SET_DOWNTIME),
129 DEFINE_PROP_UINT32("x-checkpoint-delay", MigrationState,
130 parameters.x_checkpoint_delay,
131 DEFAULT_MIGRATE_X_CHECKPOINT_DELAY),
132 DEFINE_PROP_UINT8("multifd-channels", MigrationState,
133 parameters.multifd_channels,
134 DEFAULT_MIGRATE_MULTIFD_CHANNELS),
135 DEFINE_PROP_MULTIFD_COMPRESSION("multifd-compression", MigrationState,
136 parameters.multifd_compression,
137 DEFAULT_MIGRATE_MULTIFD_COMPRESSION),
138 DEFINE_PROP_UINT8("multifd-zlib-level", MigrationState,
139 parameters.multifd_zlib_level,
140 DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL),
141 DEFINE_PROP_UINT8("multifd-zstd-level", MigrationState,
142 parameters.multifd_zstd_level,
143 DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL),
144 DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState,
145 parameters.xbzrle_cache_size,
146 DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE),
147 DEFINE_PROP_SIZE("max-postcopy-bandwidth", MigrationState,
148 parameters.max_postcopy_bandwidth,
149 DEFAULT_MIGRATE_MAX_POSTCOPY_BANDWIDTH),
150 DEFINE_PROP_UINT8("max-cpu-throttle", MigrationState,
151 parameters.max_cpu_throttle,
152 DEFAULT_MIGRATE_MAX_CPU_THROTTLE),
153 DEFINE_PROP_SIZE("announce-initial", MigrationState,
154 parameters.announce_initial,
155 DEFAULT_MIGRATE_ANNOUNCE_INITIAL),
156 DEFINE_PROP_SIZE("announce-max", MigrationState,
157 parameters.announce_max,
158 DEFAULT_MIGRATE_ANNOUNCE_MAX),
159 DEFINE_PROP_SIZE("announce-rounds", MigrationState,
160 parameters.announce_rounds,
161 DEFAULT_MIGRATE_ANNOUNCE_ROUNDS),
162 DEFINE_PROP_SIZE("announce-step", MigrationState,
163 parameters.announce_step,
164 DEFAULT_MIGRATE_ANNOUNCE_STEP),
165 DEFINE_PROP_STRING("tls-creds", MigrationState, parameters.tls_creds),
166 DEFINE_PROP_STRING("tls-hostname", MigrationState, parameters.tls_hostname),
167 DEFINE_PROP_STRING("tls-authz", MigrationState, parameters.tls_authz),
168 DEFINE_PROP_UINT64("x-vcpu-dirty-limit-period", MigrationState,
169 parameters.x_vcpu_dirty_limit_period,
170 DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD),
172 /* Migration capabilities */
173 DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE),
174 DEFINE_PROP_MIG_CAP("x-rdma-pin-all", MIGRATION_CAPABILITY_RDMA_PIN_ALL),
175 DEFINE_PROP_MIG_CAP("x-auto-converge", MIGRATION_CAPABILITY_AUTO_CONVERGE),
176 DEFINE_PROP_MIG_CAP("x-zero-blocks", MIGRATION_CAPABILITY_ZERO_BLOCKS),
177 DEFINE_PROP_MIG_CAP("x-compress", MIGRATION_CAPABILITY_COMPRESS),
178 DEFINE_PROP_MIG_CAP("x-events", MIGRATION_CAPABILITY_EVENTS),
179 DEFINE_PROP_MIG_CAP("x-postcopy-ram", MIGRATION_CAPABILITY_POSTCOPY_RAM),
180 DEFINE_PROP_MIG_CAP("x-postcopy-preempt",
181 MIGRATION_CAPABILITY_POSTCOPY_PREEMPT),
182 DEFINE_PROP_MIG_CAP("x-colo", MIGRATION_CAPABILITY_X_COLO),
183 DEFINE_PROP_MIG_CAP("x-release-ram", MIGRATION_CAPABILITY_RELEASE_RAM),
184 DEFINE_PROP_MIG_CAP("x-block", MIGRATION_CAPABILITY_BLOCK),
185 DEFINE_PROP_MIG_CAP("x-return-path", MIGRATION_CAPABILITY_RETURN_PATH),
186 DEFINE_PROP_MIG_CAP("x-multifd", MIGRATION_CAPABILITY_MULTIFD),
187 DEFINE_PROP_MIG_CAP("x-background-snapshot",
188 MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT),
189 #ifdef CONFIG_LINUX
190 DEFINE_PROP_MIG_CAP("x-zero-copy-send",
191 MIGRATION_CAPABILITY_ZERO_COPY_SEND),
192 #endif
193 DEFINE_PROP_MIG_CAP("x-switchover-ack",
194 MIGRATION_CAPABILITY_SWITCHOVER_ACK),
196 DEFINE_PROP_END_OF_LIST(),
199 bool migrate_auto_converge(void)
201 MigrationState *s = migrate_get_current();
203 return s->capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE];
206 bool migrate_background_snapshot(void)
208 MigrationState *s = migrate_get_current();
210 return s->capabilities[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT];
213 bool migrate_block(void)
215 MigrationState *s = migrate_get_current();
217 return s->capabilities[MIGRATION_CAPABILITY_BLOCK];
220 bool migrate_colo(void)
222 MigrationState *s = migrate_get_current();
224 return s->capabilities[MIGRATION_CAPABILITY_X_COLO];
227 bool migrate_compress(void)
229 MigrationState *s = migrate_get_current();
231 return s->capabilities[MIGRATION_CAPABILITY_COMPRESS];
234 bool migrate_dirty_bitmaps(void)
236 MigrationState *s = migrate_get_current();
238 return s->capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS];
241 bool migrate_events(void)
243 MigrationState *s = migrate_get_current();
245 return s->capabilities[MIGRATION_CAPABILITY_EVENTS];
248 bool migrate_ignore_shared(void)
250 MigrationState *s = migrate_get_current();
252 return s->capabilities[MIGRATION_CAPABILITY_X_IGNORE_SHARED];
255 bool migrate_late_block_activate(void)
257 MigrationState *s = migrate_get_current();
259 return s->capabilities[MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE];
262 bool migrate_multifd(void)
264 MigrationState *s = migrate_get_current();
266 return s->capabilities[MIGRATION_CAPABILITY_MULTIFD];
269 bool migrate_pause_before_switchover(void)
271 MigrationState *s = migrate_get_current();
273 return s->capabilities[MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER];
276 bool migrate_postcopy_blocktime(void)
278 MigrationState *s = migrate_get_current();
280 return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME];
283 bool migrate_postcopy_preempt(void)
285 MigrationState *s = migrate_get_current();
287 return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT];
290 bool migrate_postcopy_ram(void)
292 MigrationState *s = migrate_get_current();
294 return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM];
297 bool migrate_rdma_pin_all(void)
299 MigrationState *s = migrate_get_current();
301 return s->capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL];
304 bool migrate_release_ram(void)
306 MigrationState *s = migrate_get_current();
308 return s->capabilities[MIGRATION_CAPABILITY_RELEASE_RAM];
311 bool migrate_return_path(void)
313 MigrationState *s = migrate_get_current();
315 return s->capabilities[MIGRATION_CAPABILITY_RETURN_PATH];
318 bool migrate_switchover_ack(void)
320 MigrationState *s = migrate_get_current();
322 return s->capabilities[MIGRATION_CAPABILITY_SWITCHOVER_ACK];
325 bool migrate_validate_uuid(void)
327 MigrationState *s = migrate_get_current();
329 return s->capabilities[MIGRATION_CAPABILITY_VALIDATE_UUID];
332 bool migrate_xbzrle(void)
334 MigrationState *s = migrate_get_current();
336 return s->capabilities[MIGRATION_CAPABILITY_XBZRLE];
339 bool migrate_zero_blocks(void)
341 MigrationState *s = migrate_get_current();
343 return s->capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS];
346 bool migrate_zero_copy_send(void)
348 MigrationState *s = migrate_get_current();
350 return s->capabilities[MIGRATION_CAPABILITY_ZERO_COPY_SEND];
353 /* pseudo capabilities */
355 bool migrate_multifd_flush_after_each_section(void)
357 MigrationState *s = migrate_get_current();
359 return s->multifd_flush_after_each_section;
362 bool migrate_postcopy(void)
364 return migrate_postcopy_ram() || migrate_dirty_bitmaps();
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_COMPRESS,
427 MIGRATION_CAPABILITY_XBZRLE,
428 MIGRATION_CAPABILITY_X_COLO,
429 MIGRATION_CAPABILITY_VALIDATE_UUID,
430 MIGRATION_CAPABILITY_ZERO_COPY_SEND);
433 * @migration_caps_check - check capability compatibility
435 * @old_caps: old capability list
436 * @new_caps: new capability list
437 * @errp: set *errp if the check failed, with reason
439 * Returns true if check passed, otherwise false.
441 bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)
443 MigrationIncomingState *mis = migration_incoming_get_current();
445 ERRP_GUARD();
446 #ifndef CONFIG_LIVE_BLOCK_MIGRATION
447 if (new_caps[MIGRATION_CAPABILITY_BLOCK]) {
448 error_setg(errp, "QEMU compiled without old-style (blk/-b, inc/-i) "
449 "block migration");
450 error_append_hint(errp, "Use drive_mirror+NBD instead.\n");
451 return false;
453 #endif
455 #ifndef CONFIG_REPLICATION
456 if (new_caps[MIGRATION_CAPABILITY_X_COLO]) {
457 error_setg(errp, "QEMU compiled without replication module"
458 " can't enable COLO");
459 error_append_hint(errp, "Please enable replication before COLO.\n");
460 return false;
462 #endif
464 if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) {
465 /* This check is reasonably expensive, so only when it's being
466 * set the first time, also it's only the destination that needs
467 * special support.
469 if (!old_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM] &&
470 runstate_check(RUN_STATE_INMIGRATE) &&
471 !postcopy_ram_supported_by_host(mis, errp)) {
472 error_prepend(errp, "Postcopy is not supported: ");
473 return false;
476 if (new_caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED]) {
477 error_setg(errp, "Postcopy is not compatible with ignore-shared");
478 return false;
481 if (new_caps[MIGRATION_CAPABILITY_MULTIFD]) {
482 error_setg(errp, "Postcopy is not yet compatible with multifd");
483 return false;
487 if (new_caps[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT]) {
488 WriteTrackingSupport wt_support;
489 int idx;
491 * Check if 'background-snapshot' capability is supported by
492 * host kernel and compatible with guest memory configuration.
494 wt_support = migrate_query_write_tracking();
495 if (wt_support < WT_SUPPORT_AVAILABLE) {
496 error_setg(errp, "Background-snapshot is not supported by host kernel");
497 return false;
499 if (wt_support < WT_SUPPORT_COMPATIBLE) {
500 error_setg(errp, "Background-snapshot is not compatible "
501 "with guest memory configuration");
502 return false;
506 * Check if there are any migration capabilities
507 * incompatible with 'background-snapshot'.
509 for (idx = 0; idx < check_caps_background_snapshot.size; idx++) {
510 int incomp_cap = check_caps_background_snapshot.caps[idx];
511 if (new_caps[incomp_cap]) {
512 error_setg(errp,
513 "Background-snapshot is not compatible with %s",
514 MigrationCapability_str(incomp_cap));
515 return false;
520 #ifdef CONFIG_LINUX
521 if (new_caps[MIGRATION_CAPABILITY_ZERO_COPY_SEND] &&
522 (!new_caps[MIGRATION_CAPABILITY_MULTIFD] ||
523 new_caps[MIGRATION_CAPABILITY_COMPRESS] ||
524 new_caps[MIGRATION_CAPABILITY_XBZRLE] ||
525 migrate_multifd_compression() ||
526 migrate_tls())) {
527 error_setg(errp,
528 "Zero copy only available for non-compressed non-TLS multifd migration");
529 return false;
531 #else
532 if (new_caps[MIGRATION_CAPABILITY_ZERO_COPY_SEND]) {
533 error_setg(errp,
534 "Zero copy currently only available on Linux");
535 return false;
537 #endif
539 if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT]) {
540 if (!new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) {
541 error_setg(errp, "Postcopy preempt requires postcopy-ram");
542 return false;
546 * Preempt mode requires urgent pages to be sent in separate
547 * channel, OTOH compression logic will disorder all pages into
548 * different compression channels, which is not compatible with the
549 * preempt assumptions on channel assignments.
551 if (new_caps[MIGRATION_CAPABILITY_COMPRESS]) {
552 error_setg(errp, "Postcopy preempt not compatible with compress");
553 return false;
557 if (new_caps[MIGRATION_CAPABILITY_MULTIFD]) {
558 if (new_caps[MIGRATION_CAPABILITY_COMPRESS]) {
559 error_setg(errp, "Multifd is not compatible with compress");
560 return false;
564 if (new_caps[MIGRATION_CAPABILITY_SWITCHOVER_ACK]) {
565 if (!new_caps[MIGRATION_CAPABILITY_RETURN_PATH]) {
566 error_setg(errp, "Capability 'switchover-ack' requires capability "
567 "'return-path'");
568 return false;
572 return true;
575 bool migrate_cap_set(int cap, bool value, Error **errp)
577 MigrationState *s = migrate_get_current();
578 bool new_caps[MIGRATION_CAPABILITY__MAX];
580 if (migration_is_running(s->state)) {
581 error_setg(errp, QERR_MIGRATION_ACTIVE);
582 return false;
585 memcpy(new_caps, s->capabilities, sizeof(new_caps));
586 new_caps[cap] = value;
588 if (!migrate_caps_check(s->capabilities, new_caps, errp)) {
589 return false;
591 s->capabilities[cap] = value;
592 return true;
595 MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp)
597 MigrationCapabilityStatusList *head = NULL, **tail = &head;
598 MigrationCapabilityStatus *caps;
599 MigrationState *s = migrate_get_current();
600 int i;
602 for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
603 #ifndef CONFIG_LIVE_BLOCK_MIGRATION
604 if (i == MIGRATION_CAPABILITY_BLOCK) {
605 continue;
607 #endif
608 caps = g_malloc0(sizeof(*caps));
609 caps->capability = i;
610 caps->state = s->capabilities[i];
611 QAPI_LIST_APPEND(tail, caps);
614 return head;
617 void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
618 Error **errp)
620 MigrationState *s = migrate_get_current();
621 MigrationCapabilityStatusList *cap;
622 bool new_caps[MIGRATION_CAPABILITY__MAX];
624 if (migration_is_running(s->state) || migration_in_colo_state()) {
625 error_setg(errp, QERR_MIGRATION_ACTIVE);
626 return;
629 memcpy(new_caps, s->capabilities, sizeof(new_caps));
630 for (cap = params; cap; cap = cap->next) {
631 new_caps[cap->value->capability] = cap->value->state;
634 if (!migrate_caps_check(s->capabilities, new_caps, errp)) {
635 return;
638 for (cap = params; cap; cap = cap->next) {
639 s->capabilities[cap->value->capability] = cap->value->state;
643 /* parameters */
645 const BitmapMigrationNodeAliasList *migrate_block_bitmap_mapping(void)
647 MigrationState *s = migrate_get_current();
649 return s->parameters.block_bitmap_mapping;
652 bool migrate_has_block_bitmap_mapping(void)
654 MigrationState *s = migrate_get_current();
656 return s->parameters.has_block_bitmap_mapping;
659 bool migrate_block_incremental(void)
661 MigrationState *s = migrate_get_current();
663 return s->parameters.block_incremental;
666 uint32_t migrate_checkpoint_delay(void)
668 MigrationState *s = migrate_get_current();
670 return s->parameters.x_checkpoint_delay;
673 int migrate_compress_level(void)
675 MigrationState *s = migrate_get_current();
677 return s->parameters.compress_level;
680 int migrate_compress_threads(void)
682 MigrationState *s = migrate_get_current();
684 return s->parameters.compress_threads;
687 int migrate_compress_wait_thread(void)
689 MigrationState *s = migrate_get_current();
691 return s->parameters.compress_wait_thread;
694 uint8_t migrate_cpu_throttle_increment(void)
696 MigrationState *s = migrate_get_current();
698 return s->parameters.cpu_throttle_increment;
701 uint8_t migrate_cpu_throttle_initial(void)
703 MigrationState *s = migrate_get_current();
705 return s->parameters.cpu_throttle_initial;
708 bool migrate_cpu_throttle_tailslow(void)
710 MigrationState *s = migrate_get_current();
712 return s->parameters.cpu_throttle_tailslow;
715 int migrate_decompress_threads(void)
717 MigrationState *s = migrate_get_current();
719 return s->parameters.decompress_threads;
722 uint64_t migrate_downtime_limit(void)
724 MigrationState *s = migrate_get_current();
726 return s->parameters.downtime_limit;
729 uint8_t migrate_max_cpu_throttle(void)
731 MigrationState *s = migrate_get_current();
733 return s->parameters.max_cpu_throttle;
736 uint64_t migrate_max_bandwidth(void)
738 MigrationState *s = migrate_get_current();
740 return s->parameters.max_bandwidth;
743 uint64_t migrate_max_postcopy_bandwidth(void)
745 MigrationState *s = migrate_get_current();
747 return s->parameters.max_postcopy_bandwidth;
750 int migrate_multifd_channels(void)
752 MigrationState *s = migrate_get_current();
754 return s->parameters.multifd_channels;
757 MultiFDCompression migrate_multifd_compression(void)
759 MigrationState *s = migrate_get_current();
761 assert(s->parameters.multifd_compression < MULTIFD_COMPRESSION__MAX);
762 return s->parameters.multifd_compression;
765 int migrate_multifd_zlib_level(void)
767 MigrationState *s = migrate_get_current();
769 return s->parameters.multifd_zlib_level;
772 int migrate_multifd_zstd_level(void)
774 MigrationState *s = migrate_get_current();
776 return s->parameters.multifd_zstd_level;
779 uint8_t migrate_throttle_trigger_threshold(void)
781 MigrationState *s = migrate_get_current();
783 return s->parameters.throttle_trigger_threshold;
786 const char *migrate_tls_authz(void)
788 MigrationState *s = migrate_get_current();
790 return s->parameters.tls_authz;
793 const char *migrate_tls_creds(void)
795 MigrationState *s = migrate_get_current();
797 return s->parameters.tls_creds;
800 const char *migrate_tls_hostname(void)
802 MigrationState *s = migrate_get_current();
804 return s->parameters.tls_hostname;
807 uint64_t migrate_xbzrle_cache_size(void)
809 MigrationState *s = migrate_get_current();
811 return s->parameters.xbzrle_cache_size;
814 /* parameter setters */
816 void migrate_set_block_incremental(bool value)
818 MigrationState *s = migrate_get_current();
820 s->parameters.block_incremental = value;
823 /* parameters helpers */
825 void block_cleanup_parameters(void)
827 MigrationState *s = migrate_get_current();
829 if (s->must_remove_block_options) {
830 /* setting to false can never fail */
831 migrate_cap_set(MIGRATION_CAPABILITY_BLOCK, false, &error_abort);
832 migrate_set_block_incremental(false);
833 s->must_remove_block_options = false;
837 AnnounceParameters *migrate_announce_params(void)
839 static AnnounceParameters ap;
841 MigrationState *s = migrate_get_current();
843 ap.initial = s->parameters.announce_initial;
844 ap.max = s->parameters.announce_max;
845 ap.rounds = s->parameters.announce_rounds;
846 ap.step = s->parameters.announce_step;
848 return &ap;
851 MigrationParameters *qmp_query_migrate_parameters(Error **errp)
853 MigrationParameters *params;
854 MigrationState *s = migrate_get_current();
856 /* TODO use QAPI_CLONE() instead of duplicating it inline */
857 params = g_malloc0(sizeof(*params));
858 params->has_compress_level = true;
859 params->compress_level = s->parameters.compress_level;
860 params->has_compress_threads = true;
861 params->compress_threads = s->parameters.compress_threads;
862 params->has_compress_wait_thread = true;
863 params->compress_wait_thread = s->parameters.compress_wait_thread;
864 params->has_decompress_threads = true;
865 params->decompress_threads = s->parameters.decompress_threads;
866 params->has_throttle_trigger_threshold = true;
867 params->throttle_trigger_threshold = s->parameters.throttle_trigger_threshold;
868 params->has_cpu_throttle_initial = true;
869 params->cpu_throttle_initial = s->parameters.cpu_throttle_initial;
870 params->has_cpu_throttle_increment = true;
871 params->cpu_throttle_increment = s->parameters.cpu_throttle_increment;
872 params->has_cpu_throttle_tailslow = true;
873 params->cpu_throttle_tailslow = s->parameters.cpu_throttle_tailslow;
874 params->tls_creds = g_strdup(s->parameters.tls_creds);
875 params->tls_hostname = g_strdup(s->parameters.tls_hostname);
876 params->tls_authz = g_strdup(s->parameters.tls_authz ?
877 s->parameters.tls_authz : "");
878 params->has_max_bandwidth = true;
879 params->max_bandwidth = s->parameters.max_bandwidth;
880 params->has_downtime_limit = true;
881 params->downtime_limit = s->parameters.downtime_limit;
882 params->has_x_checkpoint_delay = true;
883 params->x_checkpoint_delay = s->parameters.x_checkpoint_delay;
884 params->has_block_incremental = true;
885 params->block_incremental = s->parameters.block_incremental;
886 params->has_multifd_channels = true;
887 params->multifd_channels = s->parameters.multifd_channels;
888 params->has_multifd_compression = true;
889 params->multifd_compression = s->parameters.multifd_compression;
890 params->has_multifd_zlib_level = true;
891 params->multifd_zlib_level = s->parameters.multifd_zlib_level;
892 params->has_multifd_zstd_level = true;
893 params->multifd_zstd_level = s->parameters.multifd_zstd_level;
894 params->has_xbzrle_cache_size = true;
895 params->xbzrle_cache_size = s->parameters.xbzrle_cache_size;
896 params->has_max_postcopy_bandwidth = true;
897 params->max_postcopy_bandwidth = s->parameters.max_postcopy_bandwidth;
898 params->has_max_cpu_throttle = true;
899 params->max_cpu_throttle = s->parameters.max_cpu_throttle;
900 params->has_announce_initial = true;
901 params->announce_initial = s->parameters.announce_initial;
902 params->has_announce_max = true;
903 params->announce_max = s->parameters.announce_max;
904 params->has_announce_rounds = true;
905 params->announce_rounds = s->parameters.announce_rounds;
906 params->has_announce_step = true;
907 params->announce_step = s->parameters.announce_step;
909 if (s->parameters.has_block_bitmap_mapping) {
910 params->has_block_bitmap_mapping = true;
911 params->block_bitmap_mapping =
912 QAPI_CLONE(BitmapMigrationNodeAliasList,
913 s->parameters.block_bitmap_mapping);
916 params->has_x_vcpu_dirty_limit_period = true;
917 params->x_vcpu_dirty_limit_period = s->parameters.x_vcpu_dirty_limit_period;
919 return params;
922 void migrate_params_init(MigrationParameters *params)
924 params->tls_hostname = g_strdup("");
925 params->tls_creds = g_strdup("");
927 /* Set has_* up only for parameter checks */
928 params->has_compress_level = true;
929 params->has_compress_threads = true;
930 params->has_compress_wait_thread = true;
931 params->has_decompress_threads = true;
932 params->has_throttle_trigger_threshold = true;
933 params->has_cpu_throttle_initial = true;
934 params->has_cpu_throttle_increment = true;
935 params->has_cpu_throttle_tailslow = true;
936 params->has_max_bandwidth = true;
937 params->has_downtime_limit = true;
938 params->has_x_checkpoint_delay = true;
939 params->has_block_incremental = true;
940 params->has_multifd_channels = true;
941 params->has_multifd_compression = true;
942 params->has_multifd_zlib_level = true;
943 params->has_multifd_zstd_level = true;
944 params->has_xbzrle_cache_size = true;
945 params->has_max_postcopy_bandwidth = true;
946 params->has_max_cpu_throttle = true;
947 params->has_announce_initial = true;
948 params->has_announce_max = true;
949 params->has_announce_rounds = true;
950 params->has_announce_step = true;
951 params->has_x_vcpu_dirty_limit_period = true;
955 * Check whether the parameters are valid. Error will be put into errp
956 * (if provided). Return true if valid, otherwise false.
958 bool migrate_params_check(MigrationParameters *params, Error **errp)
960 if (params->has_compress_level &&
961 (params->compress_level > 9)) {
962 error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
963 "a value between 0 and 9");
964 return false;
967 if (params->has_compress_threads && (params->compress_threads < 1)) {
968 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
969 "compress_threads",
970 "a value between 1 and 255");
971 return false;
974 if (params->has_decompress_threads && (params->decompress_threads < 1)) {
975 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
976 "decompress_threads",
977 "a value between 1 and 255");
978 return false;
981 if (params->has_throttle_trigger_threshold &&
982 (params->throttle_trigger_threshold < 1 ||
983 params->throttle_trigger_threshold > 100)) {
984 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
985 "throttle_trigger_threshold",
986 "an integer in the range of 1 to 100");
987 return false;
990 if (params->has_cpu_throttle_initial &&
991 (params->cpu_throttle_initial < 1 ||
992 params->cpu_throttle_initial > 99)) {
993 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
994 "cpu_throttle_initial",
995 "an integer in the range of 1 to 99");
996 return false;
999 if (params->has_cpu_throttle_increment &&
1000 (params->cpu_throttle_increment < 1 ||
1001 params->cpu_throttle_increment > 99)) {
1002 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1003 "cpu_throttle_increment",
1004 "an integer in the range of 1 to 99");
1005 return false;
1008 if (params->has_max_bandwidth && (params->max_bandwidth > SIZE_MAX)) {
1009 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1010 "max_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 (params->has_x_vcpu_dirty_limit_period &&
1113 (params->x_vcpu_dirty_limit_period < 1 ||
1114 params->x_vcpu_dirty_limit_period > 1000)) {
1115 error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
1116 "x-vcpu-dirty-limit-period",
1117 "a value between 1 and 1000");
1118 return false;
1121 return true;
1124 static void migrate_params_test_apply(MigrateSetParameters *params,
1125 MigrationParameters *dest)
1127 *dest = migrate_get_current()->parameters;
1129 /* TODO use QAPI_CLONE() instead of duplicating it inline */
1131 if (params->has_compress_level) {
1132 dest->compress_level = params->compress_level;
1135 if (params->has_compress_threads) {
1136 dest->compress_threads = params->compress_threads;
1139 if (params->has_compress_wait_thread) {
1140 dest->compress_wait_thread = params->compress_wait_thread;
1143 if (params->has_decompress_threads) {
1144 dest->decompress_threads = params->decompress_threads;
1147 if (params->has_throttle_trigger_threshold) {
1148 dest->throttle_trigger_threshold = params->throttle_trigger_threshold;
1151 if (params->has_cpu_throttle_initial) {
1152 dest->cpu_throttle_initial = params->cpu_throttle_initial;
1155 if (params->has_cpu_throttle_increment) {
1156 dest->cpu_throttle_increment = params->cpu_throttle_increment;
1159 if (params->has_cpu_throttle_tailslow) {
1160 dest->cpu_throttle_tailslow = params->cpu_throttle_tailslow;
1163 if (params->tls_creds) {
1164 assert(params->tls_creds->type == QTYPE_QSTRING);
1165 dest->tls_creds = params->tls_creds->u.s;
1168 if (params->tls_hostname) {
1169 assert(params->tls_hostname->type == QTYPE_QSTRING);
1170 dest->tls_hostname = params->tls_hostname->u.s;
1173 if (params->has_max_bandwidth) {
1174 dest->max_bandwidth = params->max_bandwidth;
1177 if (params->has_downtime_limit) {
1178 dest->downtime_limit = params->downtime_limit;
1181 if (params->has_x_checkpoint_delay) {
1182 dest->x_checkpoint_delay = params->x_checkpoint_delay;
1185 if (params->has_block_incremental) {
1186 dest->block_incremental = params->block_incremental;
1188 if (params->has_multifd_channels) {
1189 dest->multifd_channels = params->multifd_channels;
1191 if (params->has_multifd_compression) {
1192 dest->multifd_compression = params->multifd_compression;
1194 if (params->has_xbzrle_cache_size) {
1195 dest->xbzrle_cache_size = params->xbzrle_cache_size;
1197 if (params->has_max_postcopy_bandwidth) {
1198 dest->max_postcopy_bandwidth = params->max_postcopy_bandwidth;
1200 if (params->has_max_cpu_throttle) {
1201 dest->max_cpu_throttle = params->max_cpu_throttle;
1203 if (params->has_announce_initial) {
1204 dest->announce_initial = params->announce_initial;
1206 if (params->has_announce_max) {
1207 dest->announce_max = params->announce_max;
1209 if (params->has_announce_rounds) {
1210 dest->announce_rounds = params->announce_rounds;
1212 if (params->has_announce_step) {
1213 dest->announce_step = params->announce_step;
1216 if (params->has_block_bitmap_mapping) {
1217 dest->has_block_bitmap_mapping = true;
1218 dest->block_bitmap_mapping = params->block_bitmap_mapping;
1221 if (params->has_x_vcpu_dirty_limit_period) {
1222 dest->x_vcpu_dirty_limit_period =
1223 params->x_vcpu_dirty_limit_period;
1227 static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
1229 MigrationState *s = migrate_get_current();
1231 /* TODO use QAPI_CLONE() instead of duplicating it inline */
1233 if (params->has_compress_level) {
1234 s->parameters.compress_level = params->compress_level;
1237 if (params->has_compress_threads) {
1238 s->parameters.compress_threads = params->compress_threads;
1241 if (params->has_compress_wait_thread) {
1242 s->parameters.compress_wait_thread = params->compress_wait_thread;
1245 if (params->has_decompress_threads) {
1246 s->parameters.decompress_threads = params->decompress_threads;
1249 if (params->has_throttle_trigger_threshold) {
1250 s->parameters.throttle_trigger_threshold = params->throttle_trigger_threshold;
1253 if (params->has_cpu_throttle_initial) {
1254 s->parameters.cpu_throttle_initial = params->cpu_throttle_initial;
1257 if (params->has_cpu_throttle_increment) {
1258 s->parameters.cpu_throttle_increment = params->cpu_throttle_increment;
1261 if (params->has_cpu_throttle_tailslow) {
1262 s->parameters.cpu_throttle_tailslow = params->cpu_throttle_tailslow;
1265 if (params->tls_creds) {
1266 g_free(s->parameters.tls_creds);
1267 assert(params->tls_creds->type == QTYPE_QSTRING);
1268 s->parameters.tls_creds = g_strdup(params->tls_creds->u.s);
1271 if (params->tls_hostname) {
1272 g_free(s->parameters.tls_hostname);
1273 assert(params->tls_hostname->type == QTYPE_QSTRING);
1274 s->parameters.tls_hostname = g_strdup(params->tls_hostname->u.s);
1277 if (params->tls_authz) {
1278 g_free(s->parameters.tls_authz);
1279 assert(params->tls_authz->type == QTYPE_QSTRING);
1280 s->parameters.tls_authz = g_strdup(params->tls_authz->u.s);
1283 if (params->has_max_bandwidth) {
1284 s->parameters.max_bandwidth = params->max_bandwidth;
1285 if (s->to_dst_file && !migration_in_postcopy()) {
1286 migration_rate_set(s->parameters.max_bandwidth);
1290 if (params->has_downtime_limit) {
1291 s->parameters.downtime_limit = params->downtime_limit;
1294 if (params->has_x_checkpoint_delay) {
1295 s->parameters.x_checkpoint_delay = params->x_checkpoint_delay;
1296 colo_checkpoint_delay_set();
1299 if (params->has_block_incremental) {
1300 s->parameters.block_incremental = params->block_incremental;
1302 if (params->has_multifd_channels) {
1303 s->parameters.multifd_channels = params->multifd_channels;
1305 if (params->has_multifd_compression) {
1306 s->parameters.multifd_compression = params->multifd_compression;
1308 if (params->has_xbzrle_cache_size) {
1309 s->parameters.xbzrle_cache_size = params->xbzrle_cache_size;
1310 xbzrle_cache_resize(params->xbzrle_cache_size, errp);
1312 if (params->has_max_postcopy_bandwidth) {
1313 s->parameters.max_postcopy_bandwidth = params->max_postcopy_bandwidth;
1314 if (s->to_dst_file && migration_in_postcopy()) {
1315 migration_rate_set(s->parameters.max_postcopy_bandwidth);
1318 if (params->has_max_cpu_throttle) {
1319 s->parameters.max_cpu_throttle = params->max_cpu_throttle;
1321 if (params->has_announce_initial) {
1322 s->parameters.announce_initial = params->announce_initial;
1324 if (params->has_announce_max) {
1325 s->parameters.announce_max = params->announce_max;
1327 if (params->has_announce_rounds) {
1328 s->parameters.announce_rounds = params->announce_rounds;
1330 if (params->has_announce_step) {
1331 s->parameters.announce_step = params->announce_step;
1334 if (params->has_block_bitmap_mapping) {
1335 qapi_free_BitmapMigrationNodeAliasList(
1336 s->parameters.block_bitmap_mapping);
1338 s->parameters.has_block_bitmap_mapping = true;
1339 s->parameters.block_bitmap_mapping =
1340 QAPI_CLONE(BitmapMigrationNodeAliasList,
1341 params->block_bitmap_mapping);
1344 if (params->has_x_vcpu_dirty_limit_period) {
1345 s->parameters.x_vcpu_dirty_limit_period =
1346 params->x_vcpu_dirty_limit_period;
1350 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
1352 MigrationParameters tmp;
1354 /* TODO Rewrite "" to null instead */
1355 if (params->tls_creds
1356 && params->tls_creds->type == QTYPE_QNULL) {
1357 qobject_unref(params->tls_creds->u.n);
1358 params->tls_creds->type = QTYPE_QSTRING;
1359 params->tls_creds->u.s = strdup("");
1361 /* TODO Rewrite "" to null instead */
1362 if (params->tls_hostname
1363 && params->tls_hostname->type == QTYPE_QNULL) {
1364 qobject_unref(params->tls_hostname->u.n);
1365 params->tls_hostname->type = QTYPE_QSTRING;
1366 params->tls_hostname->u.s = strdup("");
1369 migrate_params_test_apply(params, &tmp);
1371 if (!migrate_params_check(&tmp, errp)) {
1372 /* Invalid parameter */
1373 return;
1376 migrate_params_apply(params, errp);