2 * COarse-grain LOck-stepping Virtual Machines for Non-stop Service (COLO)
3 * (a.k.a. Fault Tolerance or Continuous Replication)
5 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
6 * Copyright (c) 2016 FUJITSU LIMITED
7 * Copyright (c) 2016 Intel Corporation
9 * This work is licensed under the terms of the GNU GPL, version 2 or
10 * later. See the COPYING file in the top-level directory.
13 #include "qemu/osdep.h"
14 #include "sysemu/sysemu.h"
15 #include "qapi/error.h"
16 #include "qapi/qapi-commands-migration.h"
17 #include "qemu-file-channel.h"
18 #include "migration.h"
19 #include "qemu-file.h"
21 #include "migration/colo.h"
23 #include "io/channel-buffer.h"
25 #include "qemu/error-report.h"
26 #include "qemu/main-loop.h"
28 #include "migration/failover.h"
29 #include "migration/ram.h"
30 #ifdef CONFIG_REPLICATION
31 #include "replication.h"
33 #include "net/colo-compare.h"
35 #include "block/block.h"
36 #include "qapi/qapi-events-migration.h"
37 #include "qapi/qmp/qerror.h"
38 #include "sysemu/cpus.h"
39 #include "sysemu/runstate.h"
40 #include "net/filter.h"
42 static bool vmstate_loading
;
43 static Notifier packets_compare_notifier
;
45 /* User need to know colo mode after COLO failover */
46 static COLOMode last_colo_mode
;
48 #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024)
50 bool migration_in_colo_state(void)
52 MigrationState
*s
= migrate_get_current();
54 return (s
->state
== MIGRATION_STATUS_COLO
);
57 bool migration_incoming_in_colo_state(void)
59 MigrationIncomingState
*mis
= migration_incoming_get_current();
61 return mis
&& (mis
->state
== MIGRATION_STATUS_COLO
);
64 static bool colo_runstate_is_stopped(void)
66 return runstate_check(RUN_STATE_COLO
) || !runstate_is_running();
69 static void secondary_vm_do_failover(void)
71 /* COLO needs enable block-replication */
72 #ifdef CONFIG_REPLICATION
74 MigrationIncomingState
*mis
= migration_incoming_get_current();
75 Error
*local_err
= NULL
;
77 /* Can not do failover during the process of VM's loading VMstate, Or
78 * it will break the secondary VM.
80 if (vmstate_loading
) {
81 old_state
= failover_set_state(FAILOVER_STATUS_ACTIVE
,
82 FAILOVER_STATUS_RELAUNCH
);
83 if (old_state
!= FAILOVER_STATUS_ACTIVE
) {
84 error_report("Unknown error while do failover for secondary VM,"
85 "old_state: %s", FailoverStatus_str(old_state
));
90 migrate_set_state(&mis
->state
, MIGRATION_STATUS_COLO
,
91 MIGRATION_STATUS_COMPLETED
);
93 replication_stop_all(true, &local_err
);
95 error_report_err(local_err
);
99 /* Notify all filters of all NIC to do checkpoint */
100 colo_notify_filters_event(COLO_EVENT_FAILOVER
, &local_err
);
102 error_report_err(local_err
);
106 error_report("\"-S\" qemu option will be ignored in secondary side");
107 /* recover runstate to normal migration finish state */
111 * Make sure COLO incoming thread not block in recv or send,
112 * If mis->from_src_file and mis->to_src_file use the same fd,
113 * The second shutdown() will return -1, we ignore this value,
116 if (mis
->from_src_file
) {
117 qemu_file_shutdown(mis
->from_src_file
);
119 if (mis
->to_src_file
) {
120 qemu_file_shutdown(mis
->to_src_file
);
123 old_state
= failover_set_state(FAILOVER_STATUS_ACTIVE
,
124 FAILOVER_STATUS_COMPLETED
);
125 if (old_state
!= FAILOVER_STATUS_ACTIVE
) {
126 error_report("Incorrect state (%s) while doing failover for "
127 "secondary VM", FailoverStatus_str(old_state
));
130 /* Notify COLO incoming thread that failover work is finished */
131 qemu_sem_post(&mis
->colo_incoming_sem
);
133 /* For Secondary VM, jump to incoming co */
134 if (mis
->migration_incoming_co
) {
135 qemu_coroutine_enter(mis
->migration_incoming_co
);
142 static void primary_vm_do_failover(void)
144 #ifdef CONFIG_REPLICATION
145 MigrationState
*s
= migrate_get_current();
147 Error
*local_err
= NULL
;
149 migrate_set_state(&s
->state
, MIGRATION_STATUS_COLO
,
150 MIGRATION_STATUS_COMPLETED
);
152 * kick COLO thread which might wait at
153 * qemu_sem_wait(&s->colo_checkpoint_sem).
155 colo_checkpoint_notify(migrate_get_current());
158 * Wake up COLO thread which may blocked in recv() or send(),
159 * The s->rp_state.from_dst_file and s->to_dst_file may use the
160 * same fd, but we still shutdown the fd for twice, it is harmless.
162 if (s
->to_dst_file
) {
163 qemu_file_shutdown(s
->to_dst_file
);
165 if (s
->rp_state
.from_dst_file
) {
166 qemu_file_shutdown(s
->rp_state
.from_dst_file
);
169 old_state
= failover_set_state(FAILOVER_STATUS_ACTIVE
,
170 FAILOVER_STATUS_COMPLETED
);
171 if (old_state
!= FAILOVER_STATUS_ACTIVE
) {
172 error_report("Incorrect state (%s) while doing failover for Primary VM",
173 FailoverStatus_str(old_state
));
177 replication_stop_all(true, &local_err
);
179 error_report_err(local_err
);
183 /* Notify COLO thread that failover work is finished */
184 qemu_sem_post(&s
->colo_exit_sem
);
190 COLOMode
get_colo_mode(void)
192 if (migration_in_colo_state()) {
193 return COLO_MODE_PRIMARY
;
194 } else if (migration_incoming_in_colo_state()) {
195 return COLO_MODE_SECONDARY
;
197 return COLO_MODE_NONE
;
201 void colo_do_failover(void)
203 /* Make sure VM stopped while failover happened. */
204 if (!colo_runstate_is_stopped()) {
205 vm_stop_force_state(RUN_STATE_COLO
);
208 switch (get_colo_mode()) {
209 case COLO_MODE_PRIMARY
:
210 primary_vm_do_failover();
212 case COLO_MODE_SECONDARY
:
213 secondary_vm_do_failover();
216 error_report("colo_do_failover failed because the colo mode"
217 " could not be obtained");
221 #ifdef CONFIG_REPLICATION
222 void qmp_xen_set_replication(bool enable
, bool primary
,
223 bool has_failover
, bool failover
,
226 ReplicationMode mode
= primary
?
227 REPLICATION_MODE_PRIMARY
:
228 REPLICATION_MODE_SECONDARY
;
230 if (has_failover
&& enable
) {
231 error_setg(errp
, "Parameter 'failover' is only for"
232 " stopping replication");
237 replication_start_all(mode
, errp
);
242 replication_stop_all(failover
, failover
? NULL
: errp
);
246 ReplicationStatus
*qmp_query_xen_replication_status(Error
**errp
)
249 ReplicationStatus
*s
= g_new0(ReplicationStatus
, 1);
251 replication_get_error_all(&err
);
255 s
->desc
= g_strdup(error_get_pretty(err
));
264 void qmp_xen_colo_do_checkpoint(Error
**errp
)
268 replication_do_checkpoint_all(&err
);
270 error_propagate(errp
, err
);
273 /* Notify all filters of all NIC to do checkpoint */
274 colo_notify_filters_event(COLO_EVENT_CHECKPOINT
, errp
);
278 COLOStatus
*qmp_query_colo_status(Error
**errp
)
280 COLOStatus
*s
= g_new0(COLOStatus
, 1);
282 s
->mode
= get_colo_mode();
283 s
->last_mode
= last_colo_mode
;
285 switch (failover_get_state()) {
286 case FAILOVER_STATUS_NONE
:
287 s
->reason
= COLO_EXIT_REASON_NONE
;
289 case FAILOVER_STATUS_COMPLETED
:
290 s
->reason
= COLO_EXIT_REASON_REQUEST
;
293 if (migration_in_colo_state()) {
294 s
->reason
= COLO_EXIT_REASON_PROCESSING
;
296 s
->reason
= COLO_EXIT_REASON_ERROR
;
303 static void colo_send_message(QEMUFile
*f
, COLOMessage msg
,
308 if (msg
>= COLO_MESSAGE__MAX
) {
309 error_setg(errp
, "%s: Invalid message", __func__
);
312 qemu_put_be32(f
, msg
);
315 ret
= qemu_file_get_error(f
);
317 error_setg_errno(errp
, -ret
, "Can't send COLO message");
319 trace_colo_send_message(COLOMessage_str(msg
));
322 static void colo_send_message_value(QEMUFile
*f
, COLOMessage msg
,
323 uint64_t value
, Error
**errp
)
325 Error
*local_err
= NULL
;
328 colo_send_message(f
, msg
, &local_err
);
330 error_propagate(errp
, local_err
);
333 qemu_put_be64(f
, value
);
336 ret
= qemu_file_get_error(f
);
338 error_setg_errno(errp
, -ret
, "Failed to send value for message:%s",
339 COLOMessage_str(msg
));
343 static COLOMessage
colo_receive_message(QEMUFile
*f
, Error
**errp
)
348 msg
= qemu_get_be32(f
);
349 ret
= qemu_file_get_error(f
);
351 error_setg_errno(errp
, -ret
, "Can't receive COLO message");
354 if (msg
>= COLO_MESSAGE__MAX
) {
355 error_setg(errp
, "%s: Invalid message", __func__
);
358 trace_colo_receive_message(COLOMessage_str(msg
));
362 static void colo_receive_check_message(QEMUFile
*f
, COLOMessage expect_msg
,
366 Error
*local_err
= NULL
;
368 msg
= colo_receive_message(f
, &local_err
);
370 error_propagate(errp
, local_err
);
373 if (msg
!= expect_msg
) {
374 error_setg(errp
, "Unexpected COLO message %d, expected %d",
379 static uint64_t colo_receive_message_value(QEMUFile
*f
, uint32_t expect_msg
,
382 Error
*local_err
= NULL
;
386 colo_receive_check_message(f
, expect_msg
, &local_err
);
388 error_propagate(errp
, local_err
);
392 value
= qemu_get_be64(f
);
393 ret
= qemu_file_get_error(f
);
395 error_setg_errno(errp
, -ret
, "Failed to get value for COLO message: %s",
396 COLOMessage_str(expect_msg
));
401 static int colo_do_checkpoint_transaction(MigrationState
*s
,
402 QIOChannelBuffer
*bioc
,
405 Error
*local_err
= NULL
;
408 colo_send_message(s
->to_dst_file
, COLO_MESSAGE_CHECKPOINT_REQUEST
,
414 colo_receive_check_message(s
->rp_state
.from_dst_file
,
415 COLO_MESSAGE_CHECKPOINT_REPLY
, &local_err
);
419 /* Reset channel-buffer directly */
420 qio_channel_io_seek(QIO_CHANNEL(bioc
), 0, 0, NULL
);
423 qemu_mutex_lock_iothread();
424 if (failover_get_state() != FAILOVER_STATUS_NONE
) {
425 qemu_mutex_unlock_iothread();
428 vm_stop_force_state(RUN_STATE_COLO
);
429 qemu_mutex_unlock_iothread();
430 trace_colo_vm_state_change("run", "stop");
432 * Failover request bh could be called after vm_stop_force_state(),
433 * So we need check failover_request_is_active() again.
435 if (failover_get_state() != FAILOVER_STATUS_NONE
) {
439 colo_notify_compares_event(NULL
, COLO_EVENT_CHECKPOINT
, &local_err
);
444 /* Disable block migration */
445 migrate_set_block_enabled(false, &local_err
);
449 qemu_mutex_lock_iothread();
451 #ifdef CONFIG_REPLICATION
452 replication_do_checkpoint_all(&local_err
);
454 qemu_mutex_unlock_iothread();
461 colo_send_message(s
->to_dst_file
, COLO_MESSAGE_VMSTATE_SEND
, &local_err
);
463 qemu_mutex_unlock_iothread();
466 /* Note: device state is saved into buffer */
467 ret
= qemu_save_device_state(fb
);
469 qemu_mutex_unlock_iothread();
474 * Only save VM's live state, which not including device state.
475 * TODO: We may need a timeout mechanism to prevent COLO process
476 * to be blocked here.
478 qemu_savevm_live_state(s
->to_dst_file
);
483 * We need the size of the VMstate data in Secondary side,
484 * With which we can decide how much data should be read.
486 colo_send_message_value(s
->to_dst_file
, COLO_MESSAGE_VMSTATE_SIZE
,
487 bioc
->usage
, &local_err
);
492 qemu_put_buffer(s
->to_dst_file
, bioc
->data
, bioc
->usage
);
493 qemu_fflush(s
->to_dst_file
);
494 ret
= qemu_file_get_error(s
->to_dst_file
);
499 colo_receive_check_message(s
->rp_state
.from_dst_file
,
500 COLO_MESSAGE_VMSTATE_RECEIVED
, &local_err
);
505 colo_receive_check_message(s
->rp_state
.from_dst_file
,
506 COLO_MESSAGE_VMSTATE_LOADED
, &local_err
);
513 qemu_mutex_lock_iothread();
515 qemu_mutex_unlock_iothread();
516 trace_colo_vm_state_change("stop", "run");
520 error_report_err(local_err
);
525 static void colo_compare_notify_checkpoint(Notifier
*notifier
, void *data
)
527 colo_checkpoint_notify(data
);
530 static void colo_process_checkpoint(MigrationState
*s
)
532 QIOChannelBuffer
*bioc
;
534 int64_t current_time
= qemu_clock_get_ms(QEMU_CLOCK_HOST
);
535 Error
*local_err
= NULL
;
538 last_colo_mode
= get_colo_mode();
539 if (last_colo_mode
!= COLO_MODE_PRIMARY
) {
540 error_report("COLO mode must be COLO_MODE_PRIMARY");
544 failover_init_state();
546 s
->rp_state
.from_dst_file
= qemu_file_get_return_path(s
->to_dst_file
);
547 if (!s
->rp_state
.from_dst_file
) {
548 error_report("Open QEMUFile from_dst_file failed");
552 packets_compare_notifier
.notify
= colo_compare_notify_checkpoint
;
553 colo_compare_register_notifier(&packets_compare_notifier
);
556 * Wait for Secondary finish loading VM states and enter COLO
559 colo_receive_check_message(s
->rp_state
.from_dst_file
,
560 COLO_MESSAGE_CHECKPOINT_READY
, &local_err
);
564 bioc
= qio_channel_buffer_new(COLO_BUFFER_BASE_SIZE
);
565 fb
= qemu_fopen_channel_output(QIO_CHANNEL(bioc
));
566 object_unref(OBJECT(bioc
));
568 qemu_mutex_lock_iothread();
569 #ifdef CONFIG_REPLICATION
570 replication_start_all(REPLICATION_MODE_PRIMARY
, &local_err
);
572 qemu_mutex_unlock_iothread();
580 qemu_mutex_unlock_iothread();
581 trace_colo_vm_state_change("stop", "run");
583 timer_mod(s
->colo_delay_timer
,
584 current_time
+ s
->parameters
.x_checkpoint_delay
);
586 while (s
->state
== MIGRATION_STATUS_COLO
) {
587 if (failover_get_state() != FAILOVER_STATUS_NONE
) {
588 error_report("failover request");
592 qemu_sem_wait(&s
->colo_checkpoint_sem
);
594 if (s
->state
!= MIGRATION_STATUS_COLO
) {
597 ret
= colo_do_checkpoint_transaction(s
, bioc
, fb
);
604 /* Throw the unreported error message after exited from loop */
606 error_report_err(local_err
);
614 * There are only two reasons we can get here, some error happened
615 * or the user triggered failover.
617 switch (failover_get_state()) {
618 case FAILOVER_STATUS_COMPLETED
:
619 qapi_event_send_colo_exit(COLO_MODE_PRIMARY
,
620 COLO_EXIT_REASON_REQUEST
);
623 qapi_event_send_colo_exit(COLO_MODE_PRIMARY
,
624 COLO_EXIT_REASON_ERROR
);
627 /* Hope this not to be too long to wait here */
628 qemu_sem_wait(&s
->colo_exit_sem
);
629 qemu_sem_destroy(&s
->colo_exit_sem
);
632 * It is safe to unregister notifier after failover finished.
633 * Besides, colo_delay_timer and colo_checkpoint_sem can't be
634 * released befor unregister notifier, or there will be use-after-free
637 colo_compare_unregister_notifier(&packets_compare_notifier
);
638 timer_del(s
->colo_delay_timer
);
639 timer_free(s
->colo_delay_timer
);
640 qemu_sem_destroy(&s
->colo_checkpoint_sem
);
643 * Must be called after failover BH is completed,
644 * Or the failover BH may shutdown the wrong fd that
645 * re-used by other threads after we release here.
647 if (s
->rp_state
.from_dst_file
) {
648 qemu_fclose(s
->rp_state
.from_dst_file
);
652 void colo_checkpoint_notify(void *opaque
)
654 MigrationState
*s
= opaque
;
655 int64_t next_notify_time
;
657 qemu_sem_post(&s
->colo_checkpoint_sem
);
658 s
->colo_checkpoint_time
= qemu_clock_get_ms(QEMU_CLOCK_HOST
);
659 next_notify_time
= s
->colo_checkpoint_time
+
660 s
->parameters
.x_checkpoint_delay
;
661 timer_mod(s
->colo_delay_timer
, next_notify_time
);
664 void migrate_start_colo_process(MigrationState
*s
)
666 qemu_mutex_unlock_iothread();
667 qemu_sem_init(&s
->colo_checkpoint_sem
, 0);
668 s
->colo_delay_timer
= timer_new_ms(QEMU_CLOCK_HOST
,
669 colo_checkpoint_notify
, s
);
671 qemu_sem_init(&s
->colo_exit_sem
, 0);
672 migrate_set_state(&s
->state
, MIGRATION_STATUS_ACTIVE
,
673 MIGRATION_STATUS_COLO
);
674 colo_process_checkpoint(s
);
675 qemu_mutex_lock_iothread();
678 static void colo_incoming_process_checkpoint(MigrationIncomingState
*mis
,
679 QEMUFile
*fb
, QIOChannelBuffer
*bioc
, Error
**errp
)
683 Error
*local_err
= NULL
;
686 qemu_mutex_lock_iothread();
687 vm_stop_force_state(RUN_STATE_COLO
);
688 trace_colo_vm_state_change("run", "stop");
689 qemu_mutex_unlock_iothread();
691 /* FIXME: This is unnecessary for periodic checkpoint mode */
692 colo_send_message(mis
->to_src_file
, COLO_MESSAGE_CHECKPOINT_REPLY
,
695 error_propagate(errp
, local_err
);
699 colo_receive_check_message(mis
->from_src_file
,
700 COLO_MESSAGE_VMSTATE_SEND
, &local_err
);
702 error_propagate(errp
, local_err
);
706 qemu_mutex_lock_iothread();
707 cpu_synchronize_all_pre_loadvm();
708 ret
= qemu_loadvm_state_main(mis
->from_src_file
, mis
);
709 qemu_mutex_unlock_iothread();
712 error_setg(errp
, "Load VM's live state (ram) error");
716 value
= colo_receive_message_value(mis
->from_src_file
,
717 COLO_MESSAGE_VMSTATE_SIZE
, &local_err
);
719 error_propagate(errp
, local_err
);
724 * Read VM device state data into channel buffer,
725 * It's better to re-use the memory allocated.
726 * Here we need to handle the channel buffer directly.
728 if (value
> bioc
->capacity
) {
729 bioc
->capacity
= value
;
730 bioc
->data
= g_realloc(bioc
->data
, bioc
->capacity
);
732 total_size
= qemu_get_buffer(mis
->from_src_file
, bioc
->data
, value
);
733 if (total_size
!= value
) {
734 error_setg(errp
, "Got %" PRIu64
" VMState data, less than expected"
735 " %" PRIu64
, total_size
, value
);
738 bioc
->usage
= total_size
;
739 qio_channel_io_seek(QIO_CHANNEL(bioc
), 0, 0, NULL
);
741 colo_send_message(mis
->to_src_file
, COLO_MESSAGE_VMSTATE_RECEIVED
,
744 error_propagate(errp
, local_err
);
748 qemu_mutex_lock_iothread();
749 vmstate_loading
= true;
750 ret
= qemu_load_device_state(fb
);
752 error_setg(errp
, "COLO: load device state failed");
753 qemu_mutex_unlock_iothread();
757 #ifdef CONFIG_REPLICATION
758 replication_get_error_all(&local_err
);
760 error_propagate(errp
, local_err
);
761 qemu_mutex_unlock_iothread();
765 /* discard colo disk buffer */
766 replication_do_checkpoint_all(&local_err
);
768 error_propagate(errp
, local_err
);
769 qemu_mutex_unlock_iothread();
775 /* Notify all filters of all NIC to do checkpoint */
776 colo_notify_filters_event(COLO_EVENT_CHECKPOINT
, &local_err
);
779 error_propagate(errp
, local_err
);
780 qemu_mutex_unlock_iothread();
784 vmstate_loading
= false;
786 trace_colo_vm_state_change("stop", "run");
787 qemu_mutex_unlock_iothread();
789 if (failover_get_state() == FAILOVER_STATUS_RELAUNCH
) {
790 failover_set_state(FAILOVER_STATUS_RELAUNCH
,
791 FAILOVER_STATUS_NONE
);
792 failover_request_active(NULL
);
796 colo_send_message(mis
->to_src_file
, COLO_MESSAGE_VMSTATE_LOADED
,
799 error_propagate(errp
, local_err
);
803 static void colo_wait_handle_message(MigrationIncomingState
*mis
,
804 QEMUFile
*fb
, QIOChannelBuffer
*bioc
, Error
**errp
)
807 Error
*local_err
= NULL
;
809 msg
= colo_receive_message(mis
->from_src_file
, &local_err
);
811 error_propagate(errp
, local_err
);
816 case COLO_MESSAGE_CHECKPOINT_REQUEST
:
817 colo_incoming_process_checkpoint(mis
, fb
, bioc
, errp
);
820 error_setg(errp
, "Got unknown COLO message: %d", msg
);
825 void *colo_process_incoming_thread(void *opaque
)
827 MigrationIncomingState
*mis
= opaque
;
829 QIOChannelBuffer
*bioc
= NULL
; /* Cache incoming device state */
830 Error
*local_err
= NULL
;
832 rcu_register_thread();
833 qemu_sem_init(&mis
->colo_incoming_sem
, 0);
835 migrate_set_state(&mis
->state
, MIGRATION_STATUS_ACTIVE
,
836 MIGRATION_STATUS_COLO
);
838 last_colo_mode
= get_colo_mode();
839 if (last_colo_mode
!= COLO_MODE_SECONDARY
) {
840 error_report("COLO mode must be COLO_MODE_SECONDARY");
844 failover_init_state();
846 mis
->to_src_file
= qemu_file_get_return_path(mis
->from_src_file
);
847 if (!mis
->to_src_file
) {
848 error_report("COLO incoming thread: Open QEMUFile to_src_file failed");
852 * Note: the communication between Primary side and Secondary side
853 * should be sequential, we set the fd to unblocked in migration incoming
854 * coroutine, and here we are in the COLO incoming thread, so it is ok to
855 * set the fd back to blocked.
857 qemu_file_set_blocking(mis
->from_src_file
, true);
859 colo_incoming_start_dirty_log();
861 bioc
= qio_channel_buffer_new(COLO_BUFFER_BASE_SIZE
);
862 fb
= qemu_fopen_channel_input(QIO_CHANNEL(bioc
));
863 object_unref(OBJECT(bioc
));
865 qemu_mutex_lock_iothread();
866 #ifdef CONFIG_REPLICATION
867 replication_start_all(REPLICATION_MODE_SECONDARY
, &local_err
);
869 qemu_mutex_unlock_iothread();
876 trace_colo_vm_state_change("stop", "run");
877 qemu_mutex_unlock_iothread();
879 colo_send_message(mis
->to_src_file
, COLO_MESSAGE_CHECKPOINT_READY
,
885 while (mis
->state
== MIGRATION_STATUS_COLO
) {
886 colo_wait_handle_message(mis
, fb
, bioc
, &local_err
);
888 error_report_err(local_err
);
891 if (failover_get_state() != FAILOVER_STATUS_NONE
) {
892 error_report("failover request");
898 vmstate_loading
= false;
901 * There are only two reasons we can get here, some error happened
902 * or the user triggered failover.
904 switch (failover_get_state()) {
905 case FAILOVER_STATUS_COMPLETED
:
906 qapi_event_send_colo_exit(COLO_MODE_SECONDARY
,
907 COLO_EXIT_REASON_REQUEST
);
910 qapi_event_send_colo_exit(COLO_MODE_SECONDARY
,
911 COLO_EXIT_REASON_ERROR
);
918 /* Hope this not to be too long to loop here */
919 qemu_sem_wait(&mis
->colo_incoming_sem
);
920 qemu_sem_destroy(&mis
->colo_incoming_sem
);
921 /* Must be called after failover BH is completed */
922 if (mis
->to_src_file
) {
923 qemu_fclose(mis
->to_src_file
);
924 mis
->to_src_file
= NULL
;
927 rcu_unregister_thread();