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
);
98 /* Notify all filters of all NIC to do checkpoint */
99 colo_notify_filters_event(COLO_EVENT_FAILOVER
, &local_err
);
101 error_report_err(local_err
);
105 error_report("\"-S\" qemu option will be ignored in secondary side");
106 /* recover runstate to normal migration finish state */
110 * Make sure COLO incoming thread not block in recv or send,
111 * If mis->from_src_file and mis->to_src_file use the same fd,
112 * The second shutdown() will return -1, we ignore this value,
115 if (mis
->from_src_file
) {
116 qemu_file_shutdown(mis
->from_src_file
);
118 if (mis
->to_src_file
) {
119 qemu_file_shutdown(mis
->to_src_file
);
122 old_state
= failover_set_state(FAILOVER_STATUS_ACTIVE
,
123 FAILOVER_STATUS_COMPLETED
);
124 if (old_state
!= FAILOVER_STATUS_ACTIVE
) {
125 error_report("Incorrect state (%s) while doing failover for "
126 "secondary VM", FailoverStatus_str(old_state
));
129 /* Notify COLO incoming thread that failover work is finished */
130 qemu_sem_post(&mis
->colo_incoming_sem
);
132 /* For Secondary VM, jump to incoming co */
133 if (mis
->migration_incoming_co
) {
134 qemu_coroutine_enter(mis
->migration_incoming_co
);
141 static void primary_vm_do_failover(void)
143 #ifdef CONFIG_REPLICATION
144 MigrationState
*s
= migrate_get_current();
146 Error
*local_err
= NULL
;
148 migrate_set_state(&s
->state
, MIGRATION_STATUS_COLO
,
149 MIGRATION_STATUS_COMPLETED
);
151 * kick COLO thread which might wait at
152 * qemu_sem_wait(&s->colo_checkpoint_sem).
154 colo_checkpoint_notify(migrate_get_current());
157 * Wake up COLO thread which may blocked in recv() or send(),
158 * The s->rp_state.from_dst_file and s->to_dst_file may use the
159 * same fd, but we still shutdown the fd for twice, it is harmless.
161 if (s
->to_dst_file
) {
162 qemu_file_shutdown(s
->to_dst_file
);
164 if (s
->rp_state
.from_dst_file
) {
165 qemu_file_shutdown(s
->rp_state
.from_dst_file
);
168 old_state
= failover_set_state(FAILOVER_STATUS_ACTIVE
,
169 FAILOVER_STATUS_COMPLETED
);
170 if (old_state
!= FAILOVER_STATUS_ACTIVE
) {
171 error_report("Incorrect state (%s) while doing failover for Primary VM",
172 FailoverStatus_str(old_state
));
176 replication_stop_all(true, &local_err
);
178 error_report_err(local_err
);
182 /* Notify COLO thread that failover work is finished */
183 qemu_sem_post(&s
->colo_exit_sem
);
189 COLOMode
get_colo_mode(void)
191 if (migration_in_colo_state()) {
192 return COLO_MODE_PRIMARY
;
193 } else if (migration_incoming_in_colo_state()) {
194 return COLO_MODE_SECONDARY
;
196 return COLO_MODE_NONE
;
200 void colo_do_failover(void)
202 /* Make sure VM stopped while failover happened. */
203 if (!colo_runstate_is_stopped()) {
204 vm_stop_force_state(RUN_STATE_COLO
);
207 switch (get_colo_mode()) {
208 case COLO_MODE_PRIMARY
:
209 primary_vm_do_failover();
211 case COLO_MODE_SECONDARY
:
212 secondary_vm_do_failover();
215 error_report("colo_do_failover failed because the colo mode"
216 " could not be obtained");
220 #ifdef CONFIG_REPLICATION
221 void qmp_xen_set_replication(bool enable
, bool primary
,
222 bool has_failover
, bool failover
,
225 ReplicationMode mode
= primary
?
226 REPLICATION_MODE_PRIMARY
:
227 REPLICATION_MODE_SECONDARY
;
229 if (has_failover
&& enable
) {
230 error_setg(errp
, "Parameter 'failover' is only for"
231 " stopping replication");
236 replication_start_all(mode
, errp
);
241 replication_stop_all(failover
, failover
? NULL
: errp
);
245 ReplicationStatus
*qmp_query_xen_replication_status(Error
**errp
)
248 ReplicationStatus
*s
= g_new0(ReplicationStatus
, 1);
250 replication_get_error_all(&err
);
254 s
->desc
= g_strdup(error_get_pretty(err
));
263 void qmp_xen_colo_do_checkpoint(Error
**errp
)
265 replication_do_checkpoint_all(errp
);
266 /* Notify all filters of all NIC to do checkpoint */
267 colo_notify_filters_event(COLO_EVENT_CHECKPOINT
, errp
);
271 COLOStatus
*qmp_query_colo_status(Error
**errp
)
273 COLOStatus
*s
= g_new0(COLOStatus
, 1);
275 s
->mode
= get_colo_mode();
276 s
->last_mode
= last_colo_mode
;
278 switch (failover_get_state()) {
279 case FAILOVER_STATUS_NONE
:
280 s
->reason
= COLO_EXIT_REASON_NONE
;
282 case FAILOVER_STATUS_COMPLETED
:
283 s
->reason
= COLO_EXIT_REASON_REQUEST
;
286 if (migration_in_colo_state()) {
287 s
->reason
= COLO_EXIT_REASON_PROCESSING
;
289 s
->reason
= COLO_EXIT_REASON_ERROR
;
296 static void colo_send_message(QEMUFile
*f
, COLOMessage msg
,
301 if (msg
>= COLO_MESSAGE__MAX
) {
302 error_setg(errp
, "%s: Invalid message", __func__
);
305 qemu_put_be32(f
, msg
);
308 ret
= qemu_file_get_error(f
);
310 error_setg_errno(errp
, -ret
, "Can't send COLO message");
312 trace_colo_send_message(COLOMessage_str(msg
));
315 static void colo_send_message_value(QEMUFile
*f
, COLOMessage msg
,
316 uint64_t value
, Error
**errp
)
318 Error
*local_err
= NULL
;
321 colo_send_message(f
, msg
, &local_err
);
323 error_propagate(errp
, local_err
);
326 qemu_put_be64(f
, value
);
329 ret
= qemu_file_get_error(f
);
331 error_setg_errno(errp
, -ret
, "Failed to send value for message:%s",
332 COLOMessage_str(msg
));
336 static COLOMessage
colo_receive_message(QEMUFile
*f
, Error
**errp
)
341 msg
= qemu_get_be32(f
);
342 ret
= qemu_file_get_error(f
);
344 error_setg_errno(errp
, -ret
, "Can't receive COLO message");
347 if (msg
>= COLO_MESSAGE__MAX
) {
348 error_setg(errp
, "%s: Invalid message", __func__
);
351 trace_colo_receive_message(COLOMessage_str(msg
));
355 static void colo_receive_check_message(QEMUFile
*f
, COLOMessage expect_msg
,
359 Error
*local_err
= NULL
;
361 msg
= colo_receive_message(f
, &local_err
);
363 error_propagate(errp
, local_err
);
366 if (msg
!= expect_msg
) {
367 error_setg(errp
, "Unexpected COLO message %d, expected %d",
372 static uint64_t colo_receive_message_value(QEMUFile
*f
, uint32_t expect_msg
,
375 Error
*local_err
= NULL
;
379 colo_receive_check_message(f
, expect_msg
, &local_err
);
381 error_propagate(errp
, local_err
);
385 value
= qemu_get_be64(f
);
386 ret
= qemu_file_get_error(f
);
388 error_setg_errno(errp
, -ret
, "Failed to get value for COLO message: %s",
389 COLOMessage_str(expect_msg
));
394 static int colo_do_checkpoint_transaction(MigrationState
*s
,
395 QIOChannelBuffer
*bioc
,
398 Error
*local_err
= NULL
;
401 colo_send_message(s
->to_dst_file
, COLO_MESSAGE_CHECKPOINT_REQUEST
,
407 colo_receive_check_message(s
->rp_state
.from_dst_file
,
408 COLO_MESSAGE_CHECKPOINT_REPLY
, &local_err
);
412 /* Reset channel-buffer directly */
413 qio_channel_io_seek(QIO_CHANNEL(bioc
), 0, 0, NULL
);
416 qemu_mutex_lock_iothread();
417 if (failover_get_state() != FAILOVER_STATUS_NONE
) {
418 qemu_mutex_unlock_iothread();
421 vm_stop_force_state(RUN_STATE_COLO
);
422 qemu_mutex_unlock_iothread();
423 trace_colo_vm_state_change("run", "stop");
425 * Failover request bh could be called after vm_stop_force_state(),
426 * So we need check failover_request_is_active() again.
428 if (failover_get_state() != FAILOVER_STATUS_NONE
) {
432 colo_notify_compares_event(NULL
, COLO_EVENT_CHECKPOINT
, &local_err
);
437 /* Disable block migration */
438 migrate_set_block_enabled(false, &local_err
);
439 qemu_mutex_lock_iothread();
441 #ifdef CONFIG_REPLICATION
442 replication_do_checkpoint_all(&local_err
);
444 qemu_mutex_unlock_iothread();
451 colo_send_message(s
->to_dst_file
, COLO_MESSAGE_VMSTATE_SEND
, &local_err
);
453 qemu_mutex_unlock_iothread();
456 /* Note: device state is saved into buffer */
457 ret
= qemu_save_device_state(fb
);
459 qemu_mutex_unlock_iothread();
464 * Only save VM's live state, which not including device state.
465 * TODO: We may need a timeout mechanism to prevent COLO process
466 * to be blocked here.
468 qemu_savevm_live_state(s
->to_dst_file
);
473 * We need the size of the VMstate data in Secondary side,
474 * With which we can decide how much data should be read.
476 colo_send_message_value(s
->to_dst_file
, COLO_MESSAGE_VMSTATE_SIZE
,
477 bioc
->usage
, &local_err
);
482 qemu_put_buffer(s
->to_dst_file
, bioc
->data
, bioc
->usage
);
483 qemu_fflush(s
->to_dst_file
);
484 ret
= qemu_file_get_error(s
->to_dst_file
);
489 colo_receive_check_message(s
->rp_state
.from_dst_file
,
490 COLO_MESSAGE_VMSTATE_RECEIVED
, &local_err
);
495 colo_receive_check_message(s
->rp_state
.from_dst_file
,
496 COLO_MESSAGE_VMSTATE_LOADED
, &local_err
);
503 qemu_mutex_lock_iothread();
505 qemu_mutex_unlock_iothread();
506 trace_colo_vm_state_change("stop", "run");
510 error_report_err(local_err
);
515 static void colo_compare_notify_checkpoint(Notifier
*notifier
, void *data
)
517 colo_checkpoint_notify(data
);
520 static void colo_process_checkpoint(MigrationState
*s
)
522 QIOChannelBuffer
*bioc
;
524 int64_t current_time
= qemu_clock_get_ms(QEMU_CLOCK_HOST
);
525 Error
*local_err
= NULL
;
528 last_colo_mode
= get_colo_mode();
529 if (last_colo_mode
!= COLO_MODE_PRIMARY
) {
530 error_report("COLO mode must be COLO_MODE_PRIMARY");
534 failover_init_state();
536 s
->rp_state
.from_dst_file
= qemu_file_get_return_path(s
->to_dst_file
);
537 if (!s
->rp_state
.from_dst_file
) {
538 error_report("Open QEMUFile from_dst_file failed");
542 packets_compare_notifier
.notify
= colo_compare_notify_checkpoint
;
543 colo_compare_register_notifier(&packets_compare_notifier
);
546 * Wait for Secondary finish loading VM states and enter COLO
549 colo_receive_check_message(s
->rp_state
.from_dst_file
,
550 COLO_MESSAGE_CHECKPOINT_READY
, &local_err
);
554 bioc
= qio_channel_buffer_new(COLO_BUFFER_BASE_SIZE
);
555 fb
= qemu_fopen_channel_output(QIO_CHANNEL(bioc
));
556 object_unref(OBJECT(bioc
));
558 qemu_mutex_lock_iothread();
559 #ifdef CONFIG_REPLICATION
560 replication_start_all(REPLICATION_MODE_PRIMARY
, &local_err
);
562 qemu_mutex_unlock_iothread();
570 qemu_mutex_unlock_iothread();
571 trace_colo_vm_state_change("stop", "run");
573 timer_mod(s
->colo_delay_timer
,
574 current_time
+ s
->parameters
.x_checkpoint_delay
);
576 while (s
->state
== MIGRATION_STATUS_COLO
) {
577 if (failover_get_state() != FAILOVER_STATUS_NONE
) {
578 error_report("failover request");
582 qemu_sem_wait(&s
->colo_checkpoint_sem
);
584 if (s
->state
!= MIGRATION_STATUS_COLO
) {
587 ret
= colo_do_checkpoint_transaction(s
, bioc
, fb
);
594 /* Throw the unreported error message after exited from loop */
596 error_report_err(local_err
);
604 * There are only two reasons we can get here, some error happened
605 * or the user triggered failover.
607 switch (failover_get_state()) {
608 case FAILOVER_STATUS_COMPLETED
:
609 qapi_event_send_colo_exit(COLO_MODE_PRIMARY
,
610 COLO_EXIT_REASON_REQUEST
);
613 qapi_event_send_colo_exit(COLO_MODE_PRIMARY
,
614 COLO_EXIT_REASON_ERROR
);
617 /* Hope this not to be too long to wait here */
618 qemu_sem_wait(&s
->colo_exit_sem
);
619 qemu_sem_destroy(&s
->colo_exit_sem
);
622 * It is safe to unregister notifier after failover finished.
623 * Besides, colo_delay_timer and colo_checkpoint_sem can't be
624 * released befor unregister notifier, or there will be use-after-free
627 colo_compare_unregister_notifier(&packets_compare_notifier
);
628 timer_del(s
->colo_delay_timer
);
629 timer_free(s
->colo_delay_timer
);
630 qemu_sem_destroy(&s
->colo_checkpoint_sem
);
633 * Must be called after failover BH is completed,
634 * Or the failover BH may shutdown the wrong fd that
635 * re-used by other threads after we release here.
637 if (s
->rp_state
.from_dst_file
) {
638 qemu_fclose(s
->rp_state
.from_dst_file
);
642 void colo_checkpoint_notify(void *opaque
)
644 MigrationState
*s
= opaque
;
645 int64_t next_notify_time
;
647 qemu_sem_post(&s
->colo_checkpoint_sem
);
648 s
->colo_checkpoint_time
= qemu_clock_get_ms(QEMU_CLOCK_HOST
);
649 next_notify_time
= s
->colo_checkpoint_time
+
650 s
->parameters
.x_checkpoint_delay
;
651 timer_mod(s
->colo_delay_timer
, next_notify_time
);
654 void migrate_start_colo_process(MigrationState
*s
)
656 qemu_mutex_unlock_iothread();
657 qemu_sem_init(&s
->colo_checkpoint_sem
, 0);
658 s
->colo_delay_timer
= timer_new_ms(QEMU_CLOCK_HOST
,
659 colo_checkpoint_notify
, s
);
661 qemu_sem_init(&s
->colo_exit_sem
, 0);
662 migrate_set_state(&s
->state
, MIGRATION_STATUS_ACTIVE
,
663 MIGRATION_STATUS_COLO
);
664 colo_process_checkpoint(s
);
665 qemu_mutex_lock_iothread();
668 static void colo_incoming_process_checkpoint(MigrationIncomingState
*mis
,
669 QEMUFile
*fb
, QIOChannelBuffer
*bioc
, Error
**errp
)
673 Error
*local_err
= NULL
;
676 qemu_mutex_lock_iothread();
677 vm_stop_force_state(RUN_STATE_COLO
);
678 trace_colo_vm_state_change("run", "stop");
679 qemu_mutex_unlock_iothread();
681 /* FIXME: This is unnecessary for periodic checkpoint mode */
682 colo_send_message(mis
->to_src_file
, COLO_MESSAGE_CHECKPOINT_REPLY
,
685 error_propagate(errp
, local_err
);
689 colo_receive_check_message(mis
->from_src_file
,
690 COLO_MESSAGE_VMSTATE_SEND
, &local_err
);
692 error_propagate(errp
, local_err
);
696 qemu_mutex_lock_iothread();
697 cpu_synchronize_all_pre_loadvm();
698 ret
= qemu_loadvm_state_main(mis
->from_src_file
, mis
);
699 qemu_mutex_unlock_iothread();
702 error_setg(errp
, "Load VM's live state (ram) error");
706 value
= colo_receive_message_value(mis
->from_src_file
,
707 COLO_MESSAGE_VMSTATE_SIZE
, &local_err
);
709 error_propagate(errp
, local_err
);
714 * Read VM device state data into channel buffer,
715 * It's better to re-use the memory allocated.
716 * Here we need to handle the channel buffer directly.
718 if (value
> bioc
->capacity
) {
719 bioc
->capacity
= value
;
720 bioc
->data
= g_realloc(bioc
->data
, bioc
->capacity
);
722 total_size
= qemu_get_buffer(mis
->from_src_file
, bioc
->data
, value
);
723 if (total_size
!= value
) {
724 error_setg(errp
, "Got %" PRIu64
" VMState data, less than expected"
725 " %" PRIu64
, total_size
, value
);
728 bioc
->usage
= total_size
;
729 qio_channel_io_seek(QIO_CHANNEL(bioc
), 0, 0, NULL
);
731 colo_send_message(mis
->to_src_file
, COLO_MESSAGE_VMSTATE_RECEIVED
,
734 error_propagate(errp
, local_err
);
738 qemu_mutex_lock_iothread();
739 vmstate_loading
= true;
740 ret
= qemu_load_device_state(fb
);
742 error_setg(errp
, "COLO: load device state failed");
743 qemu_mutex_unlock_iothread();
747 #ifdef CONFIG_REPLICATION
748 replication_get_error_all(&local_err
);
750 error_propagate(errp
, local_err
);
751 qemu_mutex_unlock_iothread();
755 /* discard colo disk buffer */
756 replication_do_checkpoint_all(&local_err
);
758 error_propagate(errp
, local_err
);
759 qemu_mutex_unlock_iothread();
765 /* Notify all filters of all NIC to do checkpoint */
766 colo_notify_filters_event(COLO_EVENT_CHECKPOINT
, &local_err
);
769 error_propagate(errp
, local_err
);
770 qemu_mutex_unlock_iothread();
774 vmstate_loading
= false;
776 trace_colo_vm_state_change("stop", "run");
777 qemu_mutex_unlock_iothread();
779 if (failover_get_state() == FAILOVER_STATUS_RELAUNCH
) {
780 failover_set_state(FAILOVER_STATUS_RELAUNCH
,
781 FAILOVER_STATUS_NONE
);
782 failover_request_active(NULL
);
786 colo_send_message(mis
->to_src_file
, COLO_MESSAGE_VMSTATE_LOADED
,
789 error_propagate(errp
, local_err
);
793 static void colo_wait_handle_message(MigrationIncomingState
*mis
,
794 QEMUFile
*fb
, QIOChannelBuffer
*bioc
, Error
**errp
)
797 Error
*local_err
= NULL
;
799 msg
= colo_receive_message(mis
->from_src_file
, &local_err
);
801 error_propagate(errp
, local_err
);
806 case COLO_MESSAGE_CHECKPOINT_REQUEST
:
807 colo_incoming_process_checkpoint(mis
, fb
, bioc
, errp
);
810 error_setg(errp
, "Got unknown COLO message: %d", msg
);
815 void *colo_process_incoming_thread(void *opaque
)
817 MigrationIncomingState
*mis
= opaque
;
819 QIOChannelBuffer
*bioc
= NULL
; /* Cache incoming device state */
820 Error
*local_err
= NULL
;
822 rcu_register_thread();
823 qemu_sem_init(&mis
->colo_incoming_sem
, 0);
825 migrate_set_state(&mis
->state
, MIGRATION_STATUS_ACTIVE
,
826 MIGRATION_STATUS_COLO
);
828 last_colo_mode
= get_colo_mode();
829 if (last_colo_mode
!= COLO_MODE_SECONDARY
) {
830 error_report("COLO mode must be COLO_MODE_SECONDARY");
834 failover_init_state();
836 mis
->to_src_file
= qemu_file_get_return_path(mis
->from_src_file
);
837 if (!mis
->to_src_file
) {
838 error_report("COLO incoming thread: Open QEMUFile to_src_file failed");
842 * Note: the communication between Primary side and Secondary side
843 * should be sequential, we set the fd to unblocked in migration incoming
844 * coroutine, and here we are in the COLO incoming thread, so it is ok to
845 * set the fd back to blocked.
847 qemu_file_set_blocking(mis
->from_src_file
, true);
849 colo_incoming_start_dirty_log();
851 bioc
= qio_channel_buffer_new(COLO_BUFFER_BASE_SIZE
);
852 fb
= qemu_fopen_channel_input(QIO_CHANNEL(bioc
));
853 object_unref(OBJECT(bioc
));
855 qemu_mutex_lock_iothread();
856 #ifdef CONFIG_REPLICATION
857 replication_start_all(REPLICATION_MODE_SECONDARY
, &local_err
);
859 qemu_mutex_unlock_iothread();
866 trace_colo_vm_state_change("stop", "run");
867 qemu_mutex_unlock_iothread();
869 colo_send_message(mis
->to_src_file
, COLO_MESSAGE_CHECKPOINT_READY
,
875 while (mis
->state
== MIGRATION_STATUS_COLO
) {
876 colo_wait_handle_message(mis
, fb
, bioc
, &local_err
);
878 error_report_err(local_err
);
881 if (failover_get_state() != FAILOVER_STATUS_NONE
) {
882 error_report("failover request");
888 vmstate_loading
= false;
891 * There are only two reasons we can get here, some error happened
892 * or the user triggered failover.
894 switch (failover_get_state()) {
895 case FAILOVER_STATUS_COMPLETED
:
896 qapi_event_send_colo_exit(COLO_MODE_SECONDARY
,
897 COLO_EXIT_REASON_REQUEST
);
900 qapi_event_send_colo_exit(COLO_MODE_SECONDARY
,
901 COLO_EXIT_REASON_ERROR
);
908 /* Hope this not to be too long to loop here */
909 qemu_sem_wait(&mis
->colo_incoming_sem
);
910 qemu_sem_destroy(&mis
->colo_incoming_sem
);
911 /* Must be called after failover BH is completed */
912 if (mis
->to_src_file
) {
913 qemu_fclose(mis
->to_src_file
);
914 mis
->to_src_file
= NULL
;
917 rcu_unregister_thread();