Lines Matching +full:- +full:- +full:disable +full:- +full:spice

10  * the COPYING file in the top-level directory.
12 * Contributions after 2012-01-13 are licensed under the terms of the
18 #include "qemu/error-report.h"
19 #include "qemu/main-loop.h"
27 #include "sysemu/cpu-throttle.h"
33 #include "migration-stats.h"
35 #include "qemu-file.h"
40 #include "qapi/clone-visitor.h"
41 #include "qapi/qapi-visit-migration.h"
42 #include "qapi/qapi-visit-sockets.h"
43 #include "qapi/qapi-commands-migration.h"
44 #include "qapi/qapi-events-migration.h"
48 #include "postcopy-ram.h"
52 #include "io/channel-buffer.h"
53 #include "io/channel-tls.h"
114 trace_vmstate_downtime_checkpoint("src-downtime-start"); in migration_downtime_start()
115 s->downtime_start = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); in migration_downtime_start()
126 if (!s->downtime) { in migration_downtime_end()
127 s->downtime = now - s->downtime_start; in migration_downtime_end()
130 trace_vmstate_downtime_checkpoint("src-downtime-end"); in migration_downtime_end()
140 if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) { in transport_supports_multi_channels()
141 SocketAddress *saddr = &addr->u.socket; in transport_supports_multi_channels()
143 return (saddr->type == SOCKET_ADDRESS_TYPE_INET || in transport_supports_multi_channels()
144 saddr->type == SOCKET_ADDRESS_TYPE_UNIX || in transport_supports_multi_channels()
145 saddr->type == SOCKET_ADDRESS_TYPE_VSOCK); in transport_supports_multi_channels()
146 } else if (addr->transport == MIGRATION_ADDRESS_TYPE_FILE) { in transport_supports_multi_channels()
161 * When doing direct-io, multifd requires two different, in migration_needs_extra_fds()
162 * non-duplicated file descriptors so we can use one of them for in migration_needs_extra_fds()
170 if (addr->transport == MIGRATION_ADDRESS_TYPE_FILE) { in transport_supports_seeking()
180 return addr->transport == MIGRATION_ADDRESS_TYPE_FILE; in transport_supports_extra_fds()
195 error_setg(errp, "Migration requires multi-channel URIs (e.g. tcp)"); in migration_channels_and_transport_compatible()
213 return (a > b) - (a < b); in page_request_addr_cmp()
222 s->vm_old_state = runstate_get(); in migration_stop_vm()
227 trace_vmstate_downtime_checkpoint("src-vm-stopped"); in migration_stop_vm()
245 current_incoming->state = MIGRATION_STATUS_NONE; in migration_object_init()
246 current_incoming->postcopy_remote_fds = in migration_object_init()
248 qemu_mutex_init(&current_incoming->rp_mutex); in migration_object_init()
249 qemu_mutex_init(&current_incoming->postcopy_prio_thread_mutex); in migration_object_init()
250 qemu_event_init(&current_incoming->main_thread_load_event, false); in migration_object_init()
251 qemu_sem_init(&current_incoming->postcopy_pause_sem_dst, 0); in migration_object_init()
252 qemu_sem_init(&current_incoming->postcopy_pause_sem_fault, 0); in migration_object_init()
253 qemu_sem_init(&current_incoming->postcopy_pause_sem_fast_load, 0); in migration_object_init()
254 qemu_sem_init(&current_incoming->postcopy_qemufile_dst_done, 0); in migration_object_init()
256 qemu_mutex_init(&current_incoming->page_request_mutex); in migration_object_init()
257 qemu_cond_init(&current_incoming->page_request_cond); in migration_object_init()
258 current_incoming->page_requested = g_tree_new(page_request_addr_cmp); in migration_object_init()
260 current_incoming->exit_on_error = INMIGRATE_DEFAULT_EXIT_ON_ERROR; in migration_object_init()
283 qemu_bh_delete(migbh->bh); in migration_bh_dispatch_bh()
284 migbh->bh = NULL; in migration_bh_dispatch_bh()
287 migbh->cb(migbh->opaque); in migration_bh_dispatch_bh()
300 migbh->bh = bh; in migration_bh_schedule()
301 migbh->cb = cb; in migration_bh_schedule()
302 migbh->opaque = opaque; in migration_bh_schedule()
318 qmp_cancel_vcpu_dirty_limit(false, -1, NULL); in migration_cancel()
332 * Cancel the current migration - that will (eventually) in migration_shutdown()
346 * are non-critical data, and their loss never considered as in migration_shutdown()
368 if (mis->socket_address_list) { in migration_incoming_transport_cleanup()
369 qapi_free_SocketAddressList(mis->socket_address_list); in migration_incoming_transport_cleanup()
370 mis->socket_address_list = NULL; in migration_incoming_transport_cleanup()
373 if (mis->transport_cleanup) { in migration_incoming_transport_cleanup()
374 mis->transport_cleanup(mis->transport_data); in migration_incoming_transport_cleanup()
375 mis->transport_data = mis->transport_cleanup = NULL; in migration_incoming_transport_cleanup()
390 if (mis->to_src_file) { in migration_incoming_state_destroy()
392 migrate_send_rp_shut(mis, qemu_file_get_error(mis->from_src_file) != 0); in migration_incoming_state_destroy()
393 qemu_fclose(mis->to_src_file); in migration_incoming_state_destroy()
394 mis->to_src_file = NULL; in migration_incoming_state_destroy()
397 if (mis->from_src_file) { in migration_incoming_state_destroy()
398 migration_ioc_unregister_yank_from_file(mis->from_src_file); in migration_incoming_state_destroy()
399 qemu_fclose(mis->from_src_file); in migration_incoming_state_destroy()
400 mis->from_src_file = NULL; in migration_incoming_state_destroy()
402 if (mis->postcopy_remote_fds) { in migration_incoming_state_destroy()
403 g_array_free(mis->postcopy_remote_fds, TRUE); in migration_incoming_state_destroy()
404 mis->postcopy_remote_fds = NULL; in migration_incoming_state_destroy()
408 qemu_event_reset(&mis->main_thread_load_event); in migration_incoming_state_destroy()
410 if (mis->page_requested) { in migration_incoming_state_destroy()
411 g_tree_destroy(mis->page_requested); in migration_incoming_state_destroy()
412 mis->page_requested = NULL; in migration_incoming_state_destroy()
415 if (mis->postcopy_qemufile_dst) { in migration_incoming_state_destroy()
416 migration_ioc_unregister_yank_from_file(mis->postcopy_qemufile_dst); in migration_incoming_state_destroy()
417 qemu_fclose(mis->postcopy_qemufile_dst); in migration_incoming_state_destroy()
418 mis->postcopy_qemufile_dst = NULL; in migration_incoming_state_destroy()
442 QEMU_LOCK_GUARD(&mis->rp_mutex); in migrate_send_rp_message()
448 if (!mis->to_src_file) { in migrate_send_rp_message()
449 ret = -EIO; in migrate_send_rp_message()
453 qemu_put_be16(mis->to_src_file, (unsigned int)message_type); in migrate_send_rp_message()
454 qemu_put_be16(mis->to_src_file, len); in migrate_send_rp_message()
455 qemu_put_buffer(mis->to_src_file, data, len); in migrate_send_rp_message()
456 return qemu_fflush(mis->to_src_file); in migrate_send_rp_message()
462 * Len: Length in bytes required - must be a multiple of pagesize
482 if (rb != mis->last_rb) { in migrate_send_rp_message_req_pages()
483 mis->last_rb = rb; in migrate_send_rp_message_req_pages()
507 WITH_QEMU_LOCK_GUARD(&mis->page_request_mutex) { in migrate_send_rp_req_pages()
509 if (!received && !g_tree_lookup(mis->page_requested, aligned)) { in migrate_send_rp_req_pages()
515 g_tree_insert(mis->page_requested, aligned, (gpointer)1); in migrate_send_rp_req_pages()
516 qatomic_inc(&mis->page_requested_count); in migrate_send_rp_req_pages()
517 trace_postcopy_page_req_add(aligned, mis->page_requested_count); in migrate_send_rp_req_pages()
549 return -ENOTSUP; in migration_incoming_enable_colo()
553 error_report("ENABLE_COLO command come in migration stream, but x-colo " in migration_incoming_enable_colo()
555 return -EINVAL; in migration_incoming_enable_colo()
559 error_report("COLO: cannot disable RAM discard"); in migration_incoming_enable_colo()
560 return -EBUSY; in migration_incoming_enable_colo()
570 QAPI_LIST_PREPEND(mis->socket_address_list, in migrate_add_address()
579 InetSocketAddress *isock = &addr->u.rdma; in migrate_uri_parse()
580 strList **tail = &addr->u.exec.args; in migrate_uri_parse()
583 addr->transport = MIGRATION_ADDRESS_TYPE_EXEC; in migrate_uri_parse()
589 QAPI_LIST_APPEND(tail, g_strdup("-c")); in migrate_uri_parse()
597 addr->transport = MIGRATION_ADDRESS_TYPE_RDMA; in migrate_uri_parse()
602 addr->transport = MIGRATION_ADDRESS_TYPE_SOCKET; in migrate_uri_parse()
607 addr->u.socket.type = saddr->type; in migrate_uri_parse()
608 addr->u.socket.u = saddr->u; in migrate_uri_parse()
612 addr->transport = MIGRATION_ADDRESS_TYPE_FILE; in migrate_uri_parse()
613 addr->u.file.filename = g_strdup(uri + strlen("file:")); in migrate_uri_parse()
614 if (file_parse_offset(addr->u.file.filename, &addr->u.file.offset, in migrate_uri_parse()
623 val->channel_type = MIGRATION_CHANNEL_TYPE_MAIN; in migrate_uri_parse()
624 val->addr = g_steal_pointer(&addr); in migrate_uri_parse()
632 MigrationStatus current = mis->state; in migration_incoming_state_setup()
648 migrate_set_state(&mis->state, current, MIGRATION_STATUS_SETUP); in migration_incoming_state_setup()
670 if (channels->next) { in qemu_start_incoming_migration()
674 addr = channels->value->addr; in qemu_start_incoming_migration()
682 addr = channel->addr; in qemu_start_incoming_migration()
694 if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) { in qemu_start_incoming_migration()
695 SocketAddress *saddr = &addr->u.socket; in qemu_start_incoming_migration()
696 if (saddr->type == SOCKET_ADDRESS_TYPE_INET || in qemu_start_incoming_migration()
697 saddr->type == SOCKET_ADDRESS_TYPE_UNIX || in qemu_start_incoming_migration()
698 saddr->type == SOCKET_ADDRESS_TYPE_VSOCK) { in qemu_start_incoming_migration()
700 } else if (saddr->type == SOCKET_ADDRESS_TYPE_FD) { in qemu_start_incoming_migration()
701 fd_start_incoming_migration(saddr->u.fd.str, errp); in qemu_start_incoming_migration()
704 } else if (addr->transport == MIGRATION_ADDRESS_TYPE_RDMA) { in qemu_start_incoming_migration()
713 rdma_start_incoming_migration(&addr->u.rdma, errp); in qemu_start_incoming_migration()
715 } else if (addr->transport == MIGRATION_ADDRESS_TYPE_EXEC) { in qemu_start_incoming_migration()
716 exec_start_incoming_migration(addr->u.exec.args, errp); in qemu_start_incoming_migration()
717 } else if (addr->transport == MIGRATION_ADDRESS_TYPE_FILE) { in qemu_start_incoming_migration()
718 file_start_incoming_migration(&addr->u.file, errp); in qemu_start_incoming_migration()
729 trace_vmstate_downtime_checkpoint("dst-precopy-bh-enter"); in process_incoming_migration_bh()
754 qemu_announce_self(&mis->announce_timer, migrate_announce_params()); in process_incoming_migration_bh()
756 trace_vmstate_downtime_checkpoint("dst-precopy-bh-announced"); in process_incoming_migration_bh()
775 trace_vmstate_downtime_checkpoint("dst-precopy-bh-vm-started"); in process_incoming_migration_bh()
781 migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, in process_incoming_migration_bh()
795 assert(mis->from_src_file); in process_incoming_migration_co()
797 mis->largest_page_size = qemu_ram_pagesize_largest(); in process_incoming_migration_co()
799 migrate_set_state(&mis->state, MIGRATION_STATUS_SETUP, in process_incoming_migration_co()
802 mis->loadvm_co = qemu_coroutine_self(); in process_incoming_migration_co()
803 ret = qemu_loadvm_state(mis->from_src_file); in process_incoming_migration_co()
804 mis->loadvm_co = NULL; in process_incoming_migration_co()
806 trace_vmstate_downtime_checkpoint("dst-precopy-loadvm-completed"); in process_incoming_migration_co()
830 error_setg(&local_err, "load of migration failed: %s", strerror(-ret)); in process_incoming_migration_co()
842 migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, in process_incoming_migration_co()
849 if (mis->exit_on_error) { in process_incoming_migration_co()
850 WITH_QEMU_LOCK_GUARD(&s->error_mutex) { in process_incoming_migration_co()
851 error_report_err(s->error); in process_incoming_migration_co()
852 s->error = NULL; in process_incoming_migration_co()
867 if (!mis->from_src_file) { in migration_incoming_setup()
868 mis->from_src_file = f; in migration_incoming_setup()
884 if (mis->state == MIGRATION_STATUS_POSTCOPY_PAUSED) { in postcopy_try_recover()
888 assert(mis->from_src_file); in postcopy_try_recover()
890 qemu_file_set_blocking(mis->from_src_file, true); in postcopy_try_recover()
892 /* Re-configure the return path */ in postcopy_try_recover()
893 mis->to_src_file = qemu_file_get_return_path(mis->from_src_file); in postcopy_try_recover()
895 migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_PAUSED, in postcopy_try_recover()
905 qemu_sem_post(&mis->postcopy_pause_sem_dst); in postcopy_try_recover()
977 default_channel = !mis->from_src_file; in migration_ioc_process_incoming()
1022 if (!mis->from_src_file) { in migration_has_all_channels()
1031 return mis->postcopy_qemufile_dst != NULL; in migration_has_all_channels()
1044 * to indicate that we've finished with the RP. Non-0 value indicates
1084 if (mis->state != MIGRATION_STATUS_POSTCOPY_RECOVER) { in migrate_send_rp_recv_bitmap()
1101 qemu_mutex_lock(&mis->rp_mutex); in migrate_send_rp_recv_bitmap()
1102 res = ramblock_recv_bitmap_send(mis->to_src_file, block_name); in migrate_send_rp_recv_bitmap()
1103 qemu_mutex_unlock(&mis->rp_mutex); in migrate_send_rp_recv_bitmap()
1124 switch (s->state) { in migration_is_running()
1144 return (s->state == MIGRATION_STATUS_COMPLETED) || migration_in_postcopy(); in migrate_show_downtime()
1149 info->has_status = true; in populate_time_info()
1150 info->has_setup_time = true; in populate_time_info()
1151 info->setup_time = s->setup_time; in populate_time_info()
1153 if (s->state == MIGRATION_STATUS_COMPLETED) { in populate_time_info()
1154 info->has_total_time = true; in populate_time_info()
1155 info->total_time = s->total_time; in populate_time_info()
1157 info->has_total_time = true; in populate_time_info()
1158 info->total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - in populate_time_info()
1159 s->start_time; in populate_time_info()
1163 info->has_downtime = true; in populate_time_info()
1164 info->downtime = s->downtime; in populate_time_info()
1166 info->has_expected_downtime = true; in populate_time_info()
1167 info->expected_downtime = s->expected_downtime; in populate_time_info()
1175 info->ram = g_malloc0(sizeof(*info->ram)); in populate_ram_info()
1176 info->ram->transferred = migration_transferred_bytes(); in populate_ram_info()
1177 info->ram->total = ram_bytes_total(); in populate_ram_info()
1178 info->ram->duplicate = stat64_get(&mig_stats.zero_pages); in populate_ram_info()
1179 info->ram->normal = stat64_get(&mig_stats.normal_pages); in populate_ram_info()
1180 info->ram->normal_bytes = info->ram->normal * page_size; in populate_ram_info()
1181 info->ram->mbps = s->mbps; in populate_ram_info()
1182 info->ram->dirty_sync_count = in populate_ram_info()
1184 info->ram->dirty_sync_missed_zero_copy = in populate_ram_info()
1186 info->ram->postcopy_requests = in populate_ram_info()
1188 info->ram->page_size = page_size; in populate_ram_info()
1189 info->ram->multifd_bytes = stat64_get(&mig_stats.multifd_bytes); in populate_ram_info()
1190 info->ram->pages_per_second = s->pages_per_second; in populate_ram_info()
1191 info->ram->precopy_bytes = stat64_get(&mig_stats.precopy_bytes); in populate_ram_info()
1192 info->ram->downtime_bytes = stat64_get(&mig_stats.downtime_bytes); in populate_ram_info()
1193 info->ram->postcopy_bytes = stat64_get(&mig_stats.postcopy_bytes); in populate_ram_info()
1196 info->xbzrle_cache = g_malloc0(sizeof(*info->xbzrle_cache)); in populate_ram_info()
1197 info->xbzrle_cache->cache_size = migrate_xbzrle_cache_size(); in populate_ram_info()
1198 info->xbzrle_cache->bytes = xbzrle_counters.bytes; in populate_ram_info()
1199 info->xbzrle_cache->pages = xbzrle_counters.pages; in populate_ram_info()
1200 info->xbzrle_cache->cache_miss = xbzrle_counters.cache_miss; in populate_ram_info()
1201 info->xbzrle_cache->cache_miss_rate = xbzrle_counters.cache_miss_rate; in populate_ram_info()
1202 info->xbzrle_cache->encoding_rate = xbzrle_counters.encoding_rate; in populate_ram_info()
1203 info->xbzrle_cache->overflow = xbzrle_counters.overflow; in populate_ram_info()
1207 info->has_cpu_throttle_percentage = true; in populate_ram_info()
1208 info->cpu_throttle_percentage = cpu_throttle_get_percentage(); in populate_ram_info()
1211 if (s->state != MIGRATION_STATUS_COMPLETED) { in populate_ram_info()
1212 info->ram->remaining = ram_bytes_remaining(); in populate_ram_info()
1213 info->ram->dirty_pages_rate = in populate_ram_info()
1218 info->has_dirty_limit_throttle_time_per_round = true; in populate_ram_info()
1219 info->dirty_limit_throttle_time_per_round = in populate_ram_info()
1222 info->has_dirty_limit_ring_full_time = true; in populate_ram_info()
1223 info->dirty_limit_ring_full_time = dirtylimit_ring_full_time(); in populate_ram_info()
1230 int state = qatomic_read(&s->state); in fill_source_migration_info()
1233 info->blocked_reasons = NULL; in fill_source_migration_info()
1237 * a) devices marked in VMState as non-migratable, and in fill_source_migration_info()
1241 qemu_savevm_non_migratable_list(&info->blocked_reasons); in fill_source_migration_info()
1244 QAPI_LIST_PREPEND(info->blocked_reasons, in fill_source_migration_info()
1245 g_strdup(error_get_pretty(cur_blocker->data))); in fill_source_migration_info()
1248 info->has_blocked_reasons = info->blocked_reasons != NULL; in fill_source_migration_info()
1256 info->has_status = true; in fill_source_migration_info()
1257 info->has_total_time = false; in fill_source_migration_info()
1273 info->has_status = true; in fill_source_migration_info()
1282 info->has_status = true; in fill_source_migration_info()
1285 info->has_status = true; in fill_source_migration_info()
1288 info->has_status = true; in fill_source_migration_info()
1291 info->status = state; in fill_source_migration_info()
1293 QEMU_LOCK_GUARD(&s->error_mutex); in fill_source_migration_info()
1294 if (s->error) { in fill_source_migration_info()
1295 info->error_desc = g_strdup(error_get_pretty(s->error)); in fill_source_migration_info()
1303 if (mis->socket_address_list) { in fill_destination_migration_info()
1304 info->has_socket_address = true; in fill_destination_migration_info()
1305 info->socket_address = in fill_destination_migration_info()
1306 QAPI_CLONE(SocketAddressList, mis->socket_address_list); in fill_destination_migration_info()
1309 switch (mis->state) { in fill_destination_migration_info()
1319 info->has_status = true; in fill_destination_migration_info()
1322 info->has_status = true; in fill_destination_migration_info()
1328 info->status = mis->state; in fill_destination_migration_info()
1330 if (!info->error_desc) { in fill_destination_migration_info()
1332 QEMU_LOCK_GUARD(&s->error_mutex); in fill_destination_migration_info()
1334 if (s->error) { in fill_destination_migration_info()
1335 info->error_desc = g_strdup(error_get_pretty(s->error)); in fill_destination_migration_info()
1360 if (s->state == MIGRATION_STATUS_NONE) { in qmp_migrate_start_postcopy()
1369 qatomic_set(&s->start_postcopy, true); in qmp_migrate_start_postcopy()
1391 g_free(s->hostname); in migrate_fd_cleanup()
1392 s->hostname = NULL; in migrate_fd_cleanup()
1393 json_writer_free(s->vmdesc); in migrate_fd_cleanup()
1394 s->vmdesc = NULL; in migrate_fd_cleanup()
1400 if (s->migration_thread_running) { in migrate_fd_cleanup()
1402 qemu_thread_join(&s->thread); in migrate_fd_cleanup()
1403 s->migration_thread_running = false; in migrate_fd_cleanup()
1407 WITH_QEMU_LOCK_GUARD(&s->qemu_file_lock) { in migrate_fd_cleanup()
1412 tmp = s->to_dst_file; in migrate_fd_cleanup()
1413 s->to_dst_file = NULL; in migrate_fd_cleanup()
1429 if (s->state == MIGRATION_STATUS_CANCELLING) { in migrate_fd_cleanup()
1430 migrate_set_state(&s->state, MIGRATION_STATUS_CANCELLING, in migrate_fd_cleanup()
1434 if (s->error) { in migrate_fd_cleanup()
1436 error_report_err(error_copy(s->error)); in migrate_fd_cleanup()
1451 QEMU_LOCK_GUARD(&s->error_mutex); in migrate_set_error()
1455 if (!s->error) { in migrate_set_error()
1456 s->error = error_copy(error); in migrate_set_error()
1463 QEMU_LOCK_GUARD(&s->error_mutex); in migrate_has_error()
1464 return qatomic_read(&s->error); in migrate_has_error()
1469 QEMU_LOCK_GUARD(&s->error_mutex); in migrate_error_free()
1470 if (s->error) { in migrate_error_free()
1471 error_free(s->error); in migrate_error_free()
1472 s->error = NULL; in migrate_error_free()
1478 MigrationStatus current = s->state; in migrate_fd_error()
1481 assert(s->to_dst_file == NULL); in migrate_fd_error()
1501 migrate_set_state(&s->state, current, next); in migrate_fd_error()
1511 WITH_QEMU_LOCK_GUARD(&s->qemu_file_lock) { in migrate_fd_cancel()
1512 if (s->rp_state.from_dst_file) { in migrate_fd_cancel()
1514 qemu_file_shutdown(s->rp_state.from_dst_file); in migrate_fd_cancel()
1519 old_state = s->state; in migrate_fd_cancel()
1525 qemu_sem_post(&s->pause_sem); in migrate_fd_cancel()
1527 migrate_set_state(&s->state, old_state, MIGRATION_STATUS_CANCELLING); in migrate_fd_cancel()
1528 } while (s->state != MIGRATION_STATUS_CANCELLING); in migrate_fd_cancel()
1535 if (s->state == MIGRATION_STATUS_CANCELLING) { in migrate_fd_cancel()
1536 WITH_QEMU_LOCK_GUARD(&s->qemu_file_lock) { in migrate_fd_cancel()
1537 if (s->to_dst_file) { in migrate_fd_cancel()
1538 qemu_file_shutdown(s->to_dst_file); in migrate_fd_cancel()
1542 if (s->state == MIGRATION_STATUS_CANCELLING && s->block_inactive) { in migrate_fd_cancel()
1549 s->block_inactive = false; in migrate_fd_cancel()
1557 notify->notify = (NotifierWithReturnFunc)func; in migration_add_notifier_mode()
1569 if (notify->notify) { in migration_remove_notifier()
1571 notify->notify = NULL; in migration_remove_notifier()
1578 MigMode mode = s->parameters.mode; in migration_call_notifiers()
1591 return (s->state == MIGRATION_STATUS_CANCELLED || in migration_has_failed()
1592 s->state == MIGRATION_STATUS_FAILED); in migration_has_failed()
1599 switch (s->state) { in migration_in_postcopy()
1644 return (s->state == MIGRATION_STATUS_ACTIVE || in migration_is_active()
1645 s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE); in migration_is_active()
1652 return s->state == MIGRATION_STATUS_DEVICE; in migration_is_device()
1659 return qemu_thread_is_self(&s->thread); in migration_thread_is_self()
1664 return s->parameters.mode == MIG_MODE_CPR_REBOOT; in migrate_mode_is_cpr()
1681 s->to_dst_file = NULL; in migrate_init()
1682 s->state = MIGRATION_STATUS_NONE; in migrate_init()
1683 s->rp_state.from_dst_file = NULL; in migrate_init()
1684 s->mbps = 0.0; in migrate_init()
1685 s->pages_per_second = 0.0; in migrate_init()
1686 s->downtime = 0; in migrate_init()
1687 s->expected_downtime = 0; in migrate_init()
1688 s->setup_time = 0; in migrate_init()
1689 s->start_postcopy = false; in migrate_init()
1690 s->migration_thread_running = false; in migrate_init()
1691 error_free(s->error); in migrate_init()
1692 s->error = NULL; in migrate_init()
1693 s->vmdesc = NULL; in migrate_init()
1695 migrate_set_state(&s->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP); in migrate_init()
1697 s->start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); in migrate_init()
1698 s->total_time = 0; in migrate_init()
1699 s->vm_old_state = -1; in migrate_init()
1700 s->iteration_initial_bytes = 0; in migrate_init()
1701 s->threshold_size = 0; in migrate_init()
1702 s->switchover_acked = false; in migrate_init()
1703 s->rdma_migration = false; in migrate_init()
1735 "(--only-migratable) for: "); in is_only_migratable()
1746 while (mode != -1 && mode != MIG_MODE_ALL) { in get_modes()
1752 modes = BIT(MIG_MODE__MAX) - 1; in get_modes()
1775 return migrate_add_blocker_modes(reasonp, errp, MIG_MODE_NORMAL, -1); in migrate_add_blocker_normal()
1788 return -EACCES; in migrate_add_blocker_modes()
1790 return -EBUSY; in migrate_add_blocker_modes()
1797 int modes = BIT(MIG_MODE__MAX) - 1; in migrate_add_blocker_internal()
1800 return -EBUSY; in migrate_add_blocker_internal()
1831 error_setg(errp, "'-incoming' was not specified on the command line"); in qmp_migrate_incoming()
1839 mis->exit_on_error = in qmp_migrate_incoming()
1864 if (mis->state != MIGRATION_STATUS_POSTCOPY_PAUSED) { in qmp_migrate_recover()
1875 * only re-setup the migration stream and poke existing migration in qmp_migrate_recover()
1887 if (migration_postcopy_is_alive(ms->state)) { in qmp_migrate_pause()
1896 qemu_mutex_lock(&ms->qemu_file_lock); in qmp_migrate_pause()
1897 if (ms->to_dst_file) { in qmp_migrate_pause()
1898 ret = qemu_file_shutdown(ms->to_dst_file); in qmp_migrate_pause()
1900 qemu_mutex_unlock(&ms->qemu_file_lock); in qmp_migrate_pause()
1914 if (migration_postcopy_is_alive(mis->state)) { in qmp_migrate_pause()
1915 ret = qemu_file_shutdown(mis->from_src_file); in qmp_migrate_pause()
1922 error_setg(errp, "migrate-pause is currently only supported " in qmp_migrate_pause()
1923 "during postcopy-active or postcopy-recover state"); in qmp_migrate_pause()
1935 error_propagate(errp, error_copy(blockers->data)); in migration_is_blocked()
1946 if (s->state != MIGRATION_STATUS_POSTCOPY_PAUSED) { in migrate_prepare()
1953 * Postcopy recovery won't work well with release-ram in migrate_prepare()
1954 * capability since release-ram will drop the page buffer as in migrate_prepare()
1960 * Luckily release-ram was designed to only be used when src in migrate_prepare()
1966 "when release-ram capability is set"); in migrate_prepare()
1970 migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_PAUSED, in migrate_prepare()
2005 error_setg(errp, "Cannot use TLS with mapped-ram"); in migrate_prepare()
2010 error_setg(errp, "Cannot use compression with mapped-ram"); in migrate_prepare()
2059 if (channels->next) { in qmp_migrate()
2063 addr = channels->value->addr; in qmp_migrate()
2071 addr = channel->addr; in qmp_migrate()
2091 if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) { in qmp_migrate()
2092 SocketAddress *saddr = &addr->u.socket; in qmp_migrate()
2093 if (saddr->type == SOCKET_ADDRESS_TYPE_INET || in qmp_migrate()
2094 saddr->type == SOCKET_ADDRESS_TYPE_UNIX || in qmp_migrate()
2095 saddr->type == SOCKET_ADDRESS_TYPE_VSOCK) { in qmp_migrate()
2097 } else if (saddr->type == SOCKET_ADDRESS_TYPE_FD) { in qmp_migrate()
2098 fd_start_outgoing_migration(s, saddr->u.fd.str, &local_err); in qmp_migrate()
2101 } else if (addr->transport == MIGRATION_ADDRESS_TYPE_RDMA) { in qmp_migrate()
2102 rdma_start_outgoing_migration(s, &addr->u.rdma, &local_err); in qmp_migrate()
2104 } else if (addr->transport == MIGRATION_ADDRESS_TYPE_EXEC) { in qmp_migrate()
2105 exec_start_outgoing_migration(s, addr->u.exec.args, &local_err); in qmp_migrate()
2106 } else if (addr->transport == MIGRATION_ADDRESS_TYPE_FILE) { in qmp_migrate()
2107 file_start_outgoing_migration(s, &addr->u.file, &local_err); in qmp_migrate()
2111 migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, in qmp_migrate()
2133 if (s->state != state) { in qmp_migrate_continue()
2135 MigrationStatus_str(s->state)); in qmp_migrate_continue()
2138 qemu_sem_post(&s->pause_sem); in qmp_migrate_continue()
2145 return -1; in migration_rp_wait()
2148 qemu_sem_wait(&s->rp_state.rp_sem); in migration_rp_wait()
2152 return -1; in migration_rp_wait()
2160 qemu_sem_post(&s->rp_state.rp_sem); in migration_rp_kick()
2164 ssize_t len; /* -1 = variable */
2167 [MIG_RP_MSG_INVALID] = { .len = -1, .name = "INVALID" },
2171 [MIG_RP_MSG_REQ_PAGES_ID] = { .len = -1, .name = "REQ_PAGES_ID" },
2172 [MIG_RP_MSG_RECV_BITMAP] = { .len = -1, .name = "RECV_BITMAP" },
2175 [MIG_RP_MSG_MAX] = { .len = -1, .name = "MAX" },
2231 migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_RECOVER, in migrate_handle_rp_resume_ack()
2241 * Release ms->rp_state.from_dst_file (and postcopy_qemufile_src if
2248 WITH_QEMU_LOCK_GUARD(&ms->qemu_file_lock) { in migration_release_dst_files()
2253 file = ms->rp_state.from_dst_file; in migration_release_dst_files()
2254 ms->rp_state.from_dst_file = NULL; in migration_release_dst_files()
2262 if (ms->postcopy_qemufile_src) { in migration_release_dst_files()
2263 migration_ioc_unregister_yank_from_file(ms->postcopy_qemufile_src); in migration_release_dst_files()
2264 qemu_file_shutdown(ms->postcopy_qemufile_src); in migration_release_dst_files()
2265 qemu_fclose(ms->postcopy_qemufile_src); in migration_release_dst_files()
2266 ms->postcopy_qemufile_src = NULL; in migration_release_dst_files()
2279 QEMUFile *rp = ms->rp_state.from_dst_file; in source_return_path_thread()
2309 if ((rp_cmd_args[header_type].len != -1 && in source_return_path_thread()
2346 qemu_sem_post(&ms->rp_state.rp_pong_acks); in source_return_path_thread()
2401 ms->switchover_acked = true; in source_return_path_thread()
2417 if (ms->state == MIGRATION_STATUS_POSTCOPY_RECOVER) { in source_return_path_thread()
2439 ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->to_dst_file); in open_return_path_on_source()
2440 if (!ms->rp_state.from_dst_file) { in open_return_path_on_source()
2441 return -1; in open_return_path_on_source()
2446 qemu_thread_create(&ms->rp_state.rp_thread, MIGRATION_THREAD_SRC_RETURN, in open_return_path_on_source()
2448 ms->rp_state.rp_thread_created = true; in open_return_path_on_source()
2458 if (!ms->rp_state.rp_thread_created) { in close_return_path_on_source()
2470 WITH_QEMU_LOCK_GUARD(&ms->qemu_file_lock) { in close_return_path_on_source()
2471 if (migrate_has_error(ms) && ms->rp_state.from_dst_file) { in close_return_path_on_source()
2472 qemu_file_shutdown(ms->rp_state.from_dst_file); in close_return_path_on_source()
2476 qemu_thread_join(&ms->rp_state.rp_thread); in close_return_path_on_source()
2477 ms->rp_state.rp_thread_created = false; in close_return_path_on_source()
2489 qemu_sem_wait(&ms->rp_state.rp_pong_acks); in migration_wait_main_channel()
2494 * Returns non-0 on error
2508 migrate_set_state(&ms->state, ms->state, MIGRATION_STATUS_FAILED); in postcopy_start()
2511 return -1; in postcopy_start()
2516 migrate_set_state(&ms->state, MIGRATION_STATUS_ACTIVE, in postcopy_start()
2526 error_setg_errno(errp, -ret, "%s: Failed to stop the VM", __func__); in postcopy_start()
2533 error_setg_errno(errp, -ret, "%s: Failed in migration_maybe_pause()", in postcopy_start()
2540 error_setg_errno(errp, -ret, "%s: Failed in bdrv_inactivate_all()", in postcopy_start()
2547 * Cause any non-postcopiable, but iterative devices to in postcopy_start()
2550 qemu_savevm_state_complete_precopy(ms->to_dst_file, true, false); in postcopy_start()
2553 * in Finish migrate and with the io-lock held everything should in postcopy_start()
2563 * send rest of state - note things that are doing postcopy in postcopy_start()
2570 qemu_savevm_send_ping(ms->to_dst_file, 2); in postcopy_start()
2577 * it starts processing it. Unfortunately the ad-hoc migration format in postcopy_start()
2579 * parsing it through each devices load-state code (especially the open in postcopy_start()
2585 qio_channel_set_name(QIO_CHANNEL(bioc), "migration-postcopy-buffer"); in postcopy_start()
2608 ret = qemu_file_get_error(ms->to_dst_file); in postcopy_start()
2617 if (qemu_savevm_send_packaged(ms->to_dst_file, bioc->data, bioc->usage)) { in postcopy_start()
2625 * spice needs to trigger a transition now in postcopy_start()
2638 qemu_savevm_send_ping(ms->to_dst_file, 4); in postcopy_start()
2645 ret = qemu_file_get_error(ms->to_dst_file); in postcopy_start()
2647 error_setg_errno(errp, -ret, "postcopy_start: Migration stream error"); in postcopy_start()
2658 migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, in postcopy_start()
2673 return -1; in postcopy_start()
2695 while (qemu_sem_timedwait(&s->pause_sem, 1) == 0) { in migration_maybe_pause()
2705 if (s->state != MIGRATION_STATUS_CANCELLING) { in migration_maybe_pause()
2707 migrate_set_state(&s->state, *current_active_state, in migration_maybe_pause()
2709 qemu_sem_wait(&s->pause_sem); in migration_maybe_pause()
2710 migrate_set_state(&s->state, MIGRATION_STATUS_PRE_SWITCHOVER, in migration_maybe_pause()
2716 return s->state == new_state ? 0 : -EINVAL; in migration_maybe_pause()
2743 s->block_inactive = !migrate_colo(); in migration_completion_precopy()
2745 ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false, in migration_completion_precopy()
2746 s->block_inactive); in migration_completion_precopy()
2757 qemu_savevm_state_complete_postcopy(s->to_dst_file); in migration_completion_postcopy()
2764 if (migrate_postcopy_preempt() && s->preempt_pre_7_2) { in migration_completion_postcopy()
2774 if (s->block_inactive && (s->state == MIGRATION_STATUS_ACTIVE || in migration_completion_failed()
2775 s->state == MIGRATION_STATUS_DEVICE)) { in migration_completion_failed()
2787 s->block_inactive = false; in migration_completion_failed()
2792 migrate_set_state(&s->state, current_active_state, in migration_completion_failed()
2805 int current_active_state = s->state; in migration_completion()
2808 if (s->state == MIGRATION_STATUS_ACTIVE) { in migration_completion()
2810 } else if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) { in migration_completion()
2813 ret = -1; in migration_completion()
2824 if (qemu_file_get_error(s->to_dst_file)) { in migration_completion()
2829 if (migrate_colo() && s->state == MIGRATION_STATUS_ACTIVE) { in migration_completion()
2831 migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, in migration_completion()
2840 if (qemu_file_get_error_obj(s->to_dst_file, &local_err)) { in migration_completion()
2844 error_setg_errno(&local_err, -ret, "Error in migration completion"); in migration_completion()
2860 int current_active_state = s->state; in bg_migration_completion()
2862 if (s->state == MIGRATION_STATUS_ACTIVE) { in bg_migration_completion()
2865 * The next step is to flush the non-RAM content (device state) in bg_migration_completion()
2869 qemu_put_buffer(s->to_dst_file, s->bioc->data, s->bioc->usage); in bg_migration_completion()
2870 qemu_fflush(s->to_dst_file); in bg_migration_completion()
2871 } else if (s->state == MIGRATION_STATUS_CANCELLING) { in bg_migration_completion()
2875 if (qemu_file_get_error(s->to_dst_file)) { in bg_migration_completion()
2884 migrate_set_state(&s->state, current_active_state, in bg_migration_completion()
2899 qemu_savevm_send_postcopy_resume(s->to_dst_file); in postcopy_resume_handshake()
2901 while (s->state == MIGRATION_STATUS_POSTCOPY_RECOVER) { in postcopy_resume_handshake()
2903 return -1; in postcopy_resume_handshake()
2907 if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) { in postcopy_resume_handshake()
2911 return -1; in postcopy_resume_handshake()
2931 * If preempt is enabled, re-establish the preempt channel. Note that in postcopy_do_resume()
2946 * switch to postcopy-active afterwards) in postcopy_do_resume()
2964 assert(s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE); in postcopy_pause()
2972 * re-created when we resume. in postcopy_pause()
2985 assert(s->to_dst_file); in postcopy_pause()
2986 migration_ioc_unregister_yank_from_file(s->to_dst_file); in postcopy_pause()
2987 qemu_mutex_lock(&s->qemu_file_lock); in postcopy_pause()
2988 file = s->to_dst_file; in postcopy_pause()
2989 s->to_dst_file = NULL; in postcopy_pause()
2990 qemu_mutex_unlock(&s->qemu_file_lock); in postcopy_pause()
2995 migrate_set_state(&s->state, s->state, in postcopy_pause()
3006 qemu_sem_wait(&s->postcopy_pause_sem); in postcopy_pause()
3007 } while (postcopy_is_paused(s->state)); in postcopy_pause()
3009 if (s->state == MIGRATION_STATUS_POSTCOPY_RECOVER) { in postcopy_pause()
3036 WITH_QEMU_LOCK_GUARD(&s->qemu_file_lock) { in migration_file_set_error()
3037 if (s->to_dst_file) { in migration_file_set_error()
3038 qemu_file_set_error_obj(s->to_dst_file, ret, err); in migration_file_set_error()
3048 int state = s->state; in migration_detect_error()
3061 ret = qemu_file_get_error_obj_any(s->to_dst_file, in migration_detect_error()
3062 s->postcopy_qemufile_src, in migration_detect_error()
3087 migrate_set_state(&s->state, state, MIGRATION_STATUS_FAILED); in migration_detect_error()
3102 * Take the BQL here so that query-migrate on the QMP thread sees: in migration_completion_end()
3103 * - atomic update of s->total_time and s->mbps; in migration_completion_end()
3104 * - correct ordering of s->mbps update vs. s->state; in migration_completion_end()
3108 s->total_time = end_time - s->start_time; in migration_completion_end()
3109 transfer_time = s->total_time - s->setup_time; in migration_completion_end()
3111 s->mbps = ((double) bytes * 8.0) / transfer_time / 1000; in migration_completion_end()
3114 migrate_set_state(&s->state, s->state, in migration_completion_end()
3125 s->iteration_start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); in update_iteration_initial_status()
3126 s->iteration_initial_bytes = migration_transferred_bytes(); in update_iteration_initial_status()
3127 s->iteration_initial_pages = ram_get_total_transferred_pages(); in update_iteration_initial_status()
3140 if (current_time < s->iteration_start_time + BUFFER_DELAY) { in migration_update_counters()
3146 transferred = current_bytes - s->iteration_initial_bytes; in migration_update_counters()
3147 time_spent = current_time - s->iteration_start_time; in migration_update_counters()
3161 s->threshold_size = expected_bw_per_ms * migrate_downtime_limit(); in migration_update_counters()
3163 s->mbps = (((double) transferred * 8.0) / in migration_update_counters()
3166 transferred_pages = ram_get_total_transferred_pages() - in migration_update_counters()
3167 s->iteration_initial_pages; in migration_update_counters()
3168 s->pages_per_second = (double) transferred_pages / in migration_update_counters()
3177 s->expected_downtime = in migration_update_counters()
3188 s->threshold_size); in migration_update_counters()
3202 return s->switchover_acked; in migration_can_switchover()
3220 bool in_postcopy = s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE; in migration_iteration_run()
3227 if (pending_size < s->threshold_size) { in migration_iteration_run()
3233 if ((!pending_size || pending_size < s->threshold_size) && can_switchover) { in migration_iteration_run()
3240 if (!in_postcopy && must_precopy <= s->threshold_size && can_switchover && in migration_iteration_run()
3241 qatomic_read(&s->start_postcopy)) { in migration_iteration_run()
3250 qemu_savevm_state_iterate(s->to_dst_file, in_postcopy); in migration_iteration_run()
3259 * If we enabled cpu throttling for auto-converge, turn it off. in migration_iteration_finish()
3267 switch (s->state) { in migration_iteration_finish()
3274 s->vm_old_state = RUN_STATE_RUNNING; in migration_iteration_finish()
3279 if (runstate_is_live(s->vm_old_state)) { in migration_iteration_finish()
3285 runstate_set(s->vm_old_state); in migration_iteration_finish()
3292 error_report("%s: Unknown ending state %d", __func__, s->state); in migration_iteration_finish()
3303 * Stop tracking RAM writes - un-protect memory, un-register UFFD in bg_migration_iteration_finish()
3310 switch (s->state) { in bg_migration_iteration_finish()
3320 error_report("%s: Unknown ending state %d", __func__, s->state); in bg_migration_iteration_finish()
3336 res = qemu_savevm_state_iterate(s->to_dst_file, false); in bg_migration_iteration_run()
3347 qemu_sem_post(&migrate_get_current()->rate_limit_sem); in migration_make_urgent_request()
3352 qemu_sem_wait(&migrate_get_current()->rate_limit_sem); in migration_consume_urgent_request()
3363 if (migration_rate_exceeded(s->to_dst_file)) { in migration_rate_limit()
3365 if (qemu_file_get_error(s->to_dst_file)) { in migration_rate_limit()
3372 int ms = s->iteration_start_time + BUFFER_DELAY - now; in migration_rate_limit()
3374 if (qemu_sem_timedwait(&s->rate_limit_sem, ms) == 0) { in migration_rate_limit()
3382 qemu_sem_post(&s->rate_limit_sem); in migration_rate_limit()
3399 migrate_set_state(&s->state, old_state, MIGRATION_STATUS_WAIT_UNPLUG); in qemu_savevm_wait_unplug()
3401 while (s->state == MIGRATION_STATUS_WAIT_UNPLUG && in qemu_savevm_wait_unplug()
3403 qemu_sem_timedwait(&s->wait_unplug_sem, 250); in qemu_savevm_wait_unplug()
3405 if (s->state != MIGRATION_STATUS_WAIT_UNPLUG) { in qemu_savevm_wait_unplug()
3412 while (timeout-- && qemu_savevm_state_guest_unplug_pending()) { in qemu_savevm_wait_unplug()
3413 qemu_sem_timedwait(&s->wait_unplug_sem, 250); in qemu_savevm_wait_unplug()
3422 migrate_set_state(&s->state, MIGRATION_STATUS_WAIT_UNPLUG, new_state); in qemu_savevm_wait_unplug()
3424 migrate_set_state(&s->state, old_state, new_state); in qemu_savevm_wait_unplug()
3454 qemu_savevm_state_header(s->to_dst_file); in migration_thread()
3461 if (s->rp_state.rp_thread_created) { in migration_thread()
3463 qemu_savevm_send_open_return_path(s->to_dst_file); in migration_thread()
3466 qemu_savevm_send_ping(s->to_dst_file, 1); in migration_thread()
3475 qemu_savevm_send_postcopy_advise(s->to_dst_file); in migration_thread()
3480 qemu_savevm_send_colo_enable(s->to_dst_file); in migration_thread()
3489 ret = qemu_savevm_state_setup(s->to_dst_file, &local_err); in migration_thread()
3496 * Handle SETUP failures after waiting for virtio-net-failover in migration_thread()
3502 migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, in migration_thread()
3507 s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; in migration_thread()
3512 if (urgent || !migration_rate_exceeded(s->to_dst_file)) { in migration_thread()
3554 vm_resume(s->vm_old_state); in bg_migration_vm_start_bh()
3592 * stash the non-RAM part of the vmstate to the temporary buffer, in bg_migration_thread()
3594 * with vCPUs running and, finally, write stashed non-RAM part of in bg_migration_thread()
3597 s->bioc = qio_channel_buffer_new(512 * 1024); in bg_migration_thread()
3598 qio_channel_set_name(QIO_CHANNEL(s->bioc), "vmstate-buffer"); in bg_migration_thread()
3599 fb = qemu_file_new_output(QIO_CHANNEL(s->bioc)); in bg_migration_thread()
3600 object_unref(OBJECT(s->bioc)); in bg_migration_thread()
3605 * Prepare for tracking memory writes with UFFD-WP - populate in bg_migration_thread()
3613 qemu_savevm_state_header(s->to_dst_file); in bg_migration_thread()
3614 ret = qemu_savevm_state_setup(s->to_dst_file, &local_err); in bg_migration_thread()
3621 * Handle SETUP failures after waiting for virtio-net-failover in bg_migration_thread()
3627 migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, in bg_migration_thread()
3632 s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; in bg_migration_thread()
3643 * save their state to channel-buffer along with devices. in bg_migration_thread()
3650 * Since we are going to get non-iterable state data directly in bg_migration_thread()
3651 * from s->bioc->data, explicit flush is needed here. in bg_migration_thread()
3662 * Start VM from BH handler to avoid write-fault lock here. in bg_migration_thread()
3663 * UFFD-WP protection for the whole RAM is already enabled so in bg_migration_thread()
3665 * writes to virtio VQs memory which is in write-protected region. in bg_migration_thread()
3695 migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, in bg_migration_thread()
3714 bool resume = (s->state == MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP); in migrate_fd_connect()
3724 s->expected_downtime = migrate_downtime_limit(); in migrate_fd_connect()
3735 error_report_err(error_copy(s->error)); in migrate_fd_connect()
3756 qemu_file_set_blocking(s->to_dst_file, true); in migrate_fd_connect()
3760 * precopy, only if user specified "return-path" capability would in migrate_fd_connect()
3765 error_setg(&local_err, "Unable to open return-path for postcopy"); in migrate_fd_connect()
3775 if (migrate_postcopy_preempt() && s->preempt_pre_7_2) { in migrate_fd_connect()
3781 migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP, in migrate_fd_connect()
3783 qemu_sem_post(&s->postcopy_pause_sem); in migrate_fd_connect()
3790 error_setg(&local_err, "migration_stop_vm failed, error %d", -ret); in migrate_fd_connect()
3804 qemu_thread_create(&s->thread, MIGRATION_THREAD_SNAPSHOT, in migrate_fd_connect()
3807 qemu_thread_create(&s->thread, MIGRATION_THREAD_SRC_MAIN, in migrate_fd_connect()
3810 s->migration_thread_running = true; in migrate_fd_connect()
3815 migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED); in migrate_fd_connect()
3824 dc->user_creatable = false; in migration_class_init()
3832 qemu_mutex_destroy(&ms->error_mutex); in migration_instance_finalize()
3833 qemu_mutex_destroy(&ms->qemu_file_lock); in migration_instance_finalize()
3834 qemu_sem_destroy(&ms->wait_unplug_sem); in migration_instance_finalize()
3835 qemu_sem_destroy(&ms->rate_limit_sem); in migration_instance_finalize()
3836 qemu_sem_destroy(&ms->pause_sem); in migration_instance_finalize()
3837 qemu_sem_destroy(&ms->postcopy_pause_sem); in migration_instance_finalize()
3838 qemu_sem_destroy(&ms->rp_state.rp_sem); in migration_instance_finalize()
3839 qemu_sem_destroy(&ms->rp_state.rp_pong_acks); in migration_instance_finalize()
3840 qemu_sem_destroy(&ms->postcopy_qemufile_src_sem); in migration_instance_finalize()
3841 error_free(ms->error); in migration_instance_finalize()
3848 ms->state = MIGRATION_STATUS_NONE; in migration_instance_init()
3849 ms->mbps = -1; in migration_instance_init()
3850 ms->pages_per_second = -1; in migration_instance_init()
3851 qemu_sem_init(&ms->pause_sem, 0); in migration_instance_init()
3852 qemu_mutex_init(&ms->error_mutex); in migration_instance_init()
3854 migrate_params_init(&ms->parameters); in migration_instance_init()
3856 qemu_sem_init(&ms->postcopy_pause_sem, 0); in migration_instance_init()
3857 qemu_sem_init(&ms->rp_state.rp_sem, 0); in migration_instance_init()
3858 qemu_sem_init(&ms->rp_state.rp_pong_acks, 0); in migration_instance_init()
3859 qemu_sem_init(&ms->rate_limit_sem, 0); in migration_instance_init()
3860 qemu_sem_init(&ms->wait_unplug_sem, 0); in migration_instance_init()
3861 qemu_sem_init(&ms->postcopy_qemufile_src_sem, 0); in migration_instance_init()
3862 qemu_mutex_init(&ms->qemu_file_lock); in migration_instance_init()
3874 if (!migrate_params_check(&ms->parameters, errp)) { in migration_object_check()
3878 return migrate_caps_check(old_caps, ms->capabilities, errp); in migration_object_check()
3889 * TYPE_DEVICE's "-global" properties.