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 "migration.h"
18 #include "qemu-file.h"
20 #include "migration/colo.h"
22 #include "io/channel-buffer.h"
24 #include "qemu/error-report.h"
25 #include "qemu/main-loop.h"
27 #include "migration/failover.h"
28 #include "migration/ram.h"
29 #ifdef CONFIG_REPLICATION
30 #include "block/replication.h"
32 #include "net/colo-compare.h"
34 #include "block/block.h"
35 #include "qapi/qapi-events-migration.h"
36 #include "sysemu/cpus.h"
37 #include "sysemu/runstate.h"
38 #include "net/filter.h"
41 static bool vmstate_loading
;
42 static Notifier packets_compare_notifier
;
44 /* User need to know colo mode after COLO failover */
45 static COLOMode last_colo_mode
;
47 #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024)
49 bool migration_in_colo_state(void)
51 MigrationState
*s
= migrate_get_current();
53 return (s
->state
== MIGRATION_STATUS_COLO
);
56 bool migration_incoming_in_colo_state(void)
58 MigrationIncomingState
*mis
= migration_incoming_get_current();
60 return mis
&& (mis
->state
== MIGRATION_STATUS_COLO
);
63 static bool colo_runstate_is_stopped(void)
65 return runstate_check(RUN_STATE_COLO
) || !runstate_is_running();
68 static void colo_checkpoint_notify(void *opaque
)
70 MigrationState
*s
= opaque
;
71 int64_t next_notify_time
;
73 qemu_event_set(&s
->colo_checkpoint_event
);
74 s
->colo_checkpoint_time
= qemu_clock_get_ms(QEMU_CLOCK_HOST
);
75 next_notify_time
= s
->colo_checkpoint_time
+ migrate_checkpoint_delay();
76 timer_mod(s
->colo_delay_timer
, next_notify_time
);
79 void colo_checkpoint_delay_set(void)
81 if (migration_in_colo_state()) {
82 colo_checkpoint_notify(migrate_get_current());
86 static void secondary_vm_do_failover(void)
88 /* COLO needs enable block-replication */
89 #ifdef CONFIG_REPLICATION
91 MigrationIncomingState
*mis
= migration_incoming_get_current();
92 Error
*local_err
= NULL
;
94 /* Can not do failover during the process of VM's loading VMstate, Or
95 * it will break the secondary VM.
97 if (vmstate_loading
) {
98 old_state
= failover_set_state(FAILOVER_STATUS_ACTIVE
,
99 FAILOVER_STATUS_RELAUNCH
);
100 if (old_state
!= FAILOVER_STATUS_ACTIVE
) {
101 error_report("Unknown error while do failover for secondary VM,"
102 "old_state: %s", FailoverStatus_str(old_state
));
107 migrate_set_state(&mis
->state
, MIGRATION_STATUS_COLO
,
108 MIGRATION_STATUS_COMPLETED
);
110 replication_stop_all(true, &local_err
);
112 error_report_err(local_err
);
116 /* Notify all filters of all NIC to do checkpoint */
117 colo_notify_filters_event(COLO_EVENT_FAILOVER
, &local_err
);
119 error_report_err(local_err
);
123 error_report("\"-S\" qemu option will be ignored in secondary side");
124 /* recover runstate to normal migration finish state */
128 * Make sure COLO incoming thread not block in recv or send,
129 * If mis->from_src_file and mis->to_src_file use the same fd,
130 * The second shutdown() will return -1, we ignore this value,
133 if (mis
->from_src_file
) {
134 qemu_file_shutdown(mis
->from_src_file
);
136 if (mis
->to_src_file
) {
137 qemu_file_shutdown(mis
->to_src_file
);
140 old_state
= failover_set_state(FAILOVER_STATUS_ACTIVE
,
141 FAILOVER_STATUS_COMPLETED
);
142 if (old_state
!= FAILOVER_STATUS_ACTIVE
) {
143 error_report("Incorrect state (%s) while doing failover for "
144 "secondary VM", FailoverStatus_str(old_state
));
147 /* Notify COLO incoming thread that failover work is finished */
148 qemu_sem_post(&mis
->colo_incoming_sem
);
150 /* For Secondary VM, jump to incoming co */
151 if (mis
->migration_incoming_co
) {
152 qemu_coroutine_enter(mis
->migration_incoming_co
);
159 static void primary_vm_do_failover(void)
161 #ifdef CONFIG_REPLICATION
162 MigrationState
*s
= migrate_get_current();
164 Error
*local_err
= NULL
;
166 migrate_set_state(&s
->state
, MIGRATION_STATUS_COLO
,
167 MIGRATION_STATUS_COMPLETED
);
169 * kick COLO thread which might wait at
170 * qemu_sem_wait(&s->colo_checkpoint_sem).
172 colo_checkpoint_notify(s
);
175 * Wake up COLO thread which may blocked in recv() or send(),
176 * The s->rp_state.from_dst_file and s->to_dst_file may use the
177 * same fd, but we still shutdown the fd for twice, it is harmless.
179 if (s
->to_dst_file
) {
180 qemu_file_shutdown(s
->to_dst_file
);
182 if (s
->rp_state
.from_dst_file
) {
183 qemu_file_shutdown(s
->rp_state
.from_dst_file
);
186 old_state
= failover_set_state(FAILOVER_STATUS_ACTIVE
,
187 FAILOVER_STATUS_COMPLETED
);
188 if (old_state
!= FAILOVER_STATUS_ACTIVE
) {
189 error_report("Incorrect state (%s) while doing failover for Primary VM",
190 FailoverStatus_str(old_state
));
194 replication_stop_all(true, &local_err
);
196 error_report_err(local_err
);
200 /* Notify COLO thread that failover work is finished */
201 qemu_sem_post(&s
->colo_exit_sem
);
207 COLOMode
get_colo_mode(void)
209 if (migration_in_colo_state()) {
210 return COLO_MODE_PRIMARY
;
211 } else if (migration_incoming_in_colo_state()) {
212 return COLO_MODE_SECONDARY
;
214 return COLO_MODE_NONE
;
218 void colo_do_failover(void)
220 /* Make sure VM stopped while failover happened. */
221 if (!colo_runstate_is_stopped()) {
222 vm_stop_force_state(RUN_STATE_COLO
);
225 switch (last_colo_mode
= get_colo_mode()) {
226 case COLO_MODE_PRIMARY
:
227 primary_vm_do_failover();
229 case COLO_MODE_SECONDARY
:
230 secondary_vm_do_failover();
233 error_report("colo_do_failover failed because the colo mode"
234 " could not be obtained");
238 #ifdef CONFIG_REPLICATION
239 void qmp_xen_set_replication(bool enable
, bool primary
,
240 bool has_failover
, bool failover
,
243 ReplicationMode mode
= primary
?
244 REPLICATION_MODE_PRIMARY
:
245 REPLICATION_MODE_SECONDARY
;
247 if (has_failover
&& enable
) {
248 error_setg(errp
, "Parameter 'failover' is only for"
249 " stopping replication");
254 replication_start_all(mode
, errp
);
259 replication_stop_all(failover
, failover
? NULL
: errp
);
263 ReplicationStatus
*qmp_query_xen_replication_status(Error
**errp
)
266 ReplicationStatus
*s
= g_new0(ReplicationStatus
, 1);
268 replication_get_error_all(&err
);
271 s
->desc
= g_strdup(error_get_pretty(err
));
280 void qmp_xen_colo_do_checkpoint(Error
**errp
)
284 replication_do_checkpoint_all(&err
);
286 error_propagate(errp
, err
);
289 /* Notify all filters of all NIC to do checkpoint */
290 colo_notify_filters_event(COLO_EVENT_CHECKPOINT
, errp
);
294 COLOStatus
*qmp_query_colo_status(Error
**errp
)
296 COLOStatus
*s
= g_new0(COLOStatus
, 1);
298 s
->mode
= get_colo_mode();
299 s
->last_mode
= last_colo_mode
;
301 switch (failover_get_state()) {
302 case FAILOVER_STATUS_NONE
:
303 s
->reason
= COLO_EXIT_REASON_NONE
;
305 case FAILOVER_STATUS_COMPLETED
:
306 s
->reason
= COLO_EXIT_REASON_REQUEST
;
309 if (migration_in_colo_state()) {
310 s
->reason
= COLO_EXIT_REASON_PROCESSING
;
312 s
->reason
= COLO_EXIT_REASON_ERROR
;
319 static void colo_send_message(QEMUFile
*f
, COLOMessage msg
,
324 if (msg
>= COLO_MESSAGE__MAX
) {
325 error_setg(errp
, "%s: Invalid message", __func__
);
328 qemu_put_be32(f
, msg
);
331 ret
= qemu_file_get_error(f
);
333 error_setg_errno(errp
, -ret
, "Can't send COLO message");
335 trace_colo_send_message(COLOMessage_str(msg
));
338 static void colo_send_message_value(QEMUFile
*f
, COLOMessage msg
,
339 uint64_t value
, Error
**errp
)
341 Error
*local_err
= NULL
;
344 colo_send_message(f
, msg
, &local_err
);
346 error_propagate(errp
, local_err
);
349 qemu_put_be64(f
, value
);
352 ret
= qemu_file_get_error(f
);
354 error_setg_errno(errp
, -ret
, "Failed to send value for message:%s",
355 COLOMessage_str(msg
));
359 static COLOMessage
colo_receive_message(QEMUFile
*f
, Error
**errp
)
364 msg
= qemu_get_be32(f
);
365 ret
= qemu_file_get_error(f
);
367 error_setg_errno(errp
, -ret
, "Can't receive COLO message");
370 if (msg
>= COLO_MESSAGE__MAX
) {
371 error_setg(errp
, "%s: Invalid message", __func__
);
374 trace_colo_receive_message(COLOMessage_str(msg
));
378 static void colo_receive_check_message(QEMUFile
*f
, COLOMessage expect_msg
,
382 Error
*local_err
= NULL
;
384 msg
= colo_receive_message(f
, &local_err
);
386 error_propagate(errp
, local_err
);
389 if (msg
!= expect_msg
) {
390 error_setg(errp
, "Unexpected COLO message %d, expected %d",
395 static uint64_t colo_receive_message_value(QEMUFile
*f
, uint32_t expect_msg
,
398 Error
*local_err
= NULL
;
402 colo_receive_check_message(f
, expect_msg
, &local_err
);
404 error_propagate(errp
, local_err
);
408 value
= qemu_get_be64(f
);
409 ret
= qemu_file_get_error(f
);
411 error_setg_errno(errp
, -ret
, "Failed to get value for COLO message: %s",
412 COLOMessage_str(expect_msg
));
417 static int colo_do_checkpoint_transaction(MigrationState
*s
,
418 QIOChannelBuffer
*bioc
,
421 Error
*local_err
= NULL
;
424 colo_send_message(s
->to_dst_file
, COLO_MESSAGE_CHECKPOINT_REQUEST
,
430 colo_receive_check_message(s
->rp_state
.from_dst_file
,
431 COLO_MESSAGE_CHECKPOINT_REPLY
, &local_err
);
435 /* Reset channel-buffer directly */
436 qio_channel_io_seek(QIO_CHANNEL(bioc
), 0, 0, NULL
);
439 qemu_mutex_lock_iothread();
440 if (failover_get_state() != FAILOVER_STATUS_NONE
) {
441 qemu_mutex_unlock_iothread();
444 vm_stop_force_state(RUN_STATE_COLO
);
445 qemu_mutex_unlock_iothread();
446 trace_colo_vm_state_change("run", "stop");
448 * Failover request bh could be called after vm_stop_force_state(),
449 * So we need check failover_request_is_active() again.
451 if (failover_get_state() != FAILOVER_STATUS_NONE
) {
454 qemu_mutex_lock_iothread();
456 #ifdef CONFIG_REPLICATION
457 replication_do_checkpoint_all(&local_err
);
459 qemu_mutex_unlock_iothread();
466 colo_send_message(s
->to_dst_file
, COLO_MESSAGE_VMSTATE_SEND
, &local_err
);
468 qemu_mutex_unlock_iothread();
471 /* Note: device state is saved into buffer */
472 ret
= qemu_save_device_state(fb
);
474 qemu_mutex_unlock_iothread();
479 if (migrate_auto_converge()) {
480 mig_throttle_counter_reset();
483 * Only save VM's live state, which not including device state.
484 * TODO: We may need a timeout mechanism to prevent COLO process
485 * to be blocked here.
487 qemu_savevm_live_state(s
->to_dst_file
);
492 * We need the size of the VMstate data in Secondary side,
493 * With which we can decide how much data should be read.
495 colo_send_message_value(s
->to_dst_file
, COLO_MESSAGE_VMSTATE_SIZE
,
496 bioc
->usage
, &local_err
);
501 qemu_put_buffer(s
->to_dst_file
, bioc
->data
, bioc
->usage
);
502 qemu_fflush(s
->to_dst_file
);
503 ret
= qemu_file_get_error(s
->to_dst_file
);
508 colo_receive_check_message(s
->rp_state
.from_dst_file
,
509 COLO_MESSAGE_VMSTATE_RECEIVED
, &local_err
);
514 qemu_event_reset(&s
->colo_checkpoint_event
);
515 colo_notify_compares_event(NULL
, COLO_EVENT_CHECKPOINT
, &local_err
);
520 colo_receive_check_message(s
->rp_state
.from_dst_file
,
521 COLO_MESSAGE_VMSTATE_LOADED
, &local_err
);
528 qemu_mutex_lock_iothread();
530 qemu_mutex_unlock_iothread();
531 trace_colo_vm_state_change("stop", "run");
535 error_report_err(local_err
);
540 static void colo_compare_notify_checkpoint(Notifier
*notifier
, void *data
)
542 colo_checkpoint_notify(data
);
545 static void colo_process_checkpoint(MigrationState
*s
)
547 QIOChannelBuffer
*bioc
;
549 Error
*local_err
= NULL
;
552 if (get_colo_mode() != COLO_MODE_PRIMARY
) {
553 error_report("COLO mode must be COLO_MODE_PRIMARY");
557 failover_init_state();
559 s
->rp_state
.from_dst_file
= qemu_file_get_return_path(s
->to_dst_file
);
560 if (!s
->rp_state
.from_dst_file
) {
561 error_report("Open QEMUFile from_dst_file failed");
565 packets_compare_notifier
.notify
= colo_compare_notify_checkpoint
;
566 colo_compare_register_notifier(&packets_compare_notifier
);
569 * Wait for Secondary finish loading VM states and enter COLO
572 colo_receive_check_message(s
->rp_state
.from_dst_file
,
573 COLO_MESSAGE_CHECKPOINT_READY
, &local_err
);
577 bioc
= qio_channel_buffer_new(COLO_BUFFER_BASE_SIZE
);
578 fb
= qemu_file_new_output(QIO_CHANNEL(bioc
));
579 object_unref(OBJECT(bioc
));
581 qemu_mutex_lock_iothread();
582 #ifdef CONFIG_REPLICATION
583 replication_start_all(REPLICATION_MODE_PRIMARY
, &local_err
);
585 qemu_mutex_unlock_iothread();
593 qemu_mutex_unlock_iothread();
594 trace_colo_vm_state_change("stop", "run");
596 timer_mod(s
->colo_delay_timer
, qemu_clock_get_ms(QEMU_CLOCK_HOST
) +
597 migrate_checkpoint_delay());
599 while (s
->state
== MIGRATION_STATUS_COLO
) {
600 if (failover_get_state() != FAILOVER_STATUS_NONE
) {
601 error_report("failover request");
605 qemu_event_wait(&s
->colo_checkpoint_event
);
607 if (s
->state
!= MIGRATION_STATUS_COLO
) {
610 ret
= colo_do_checkpoint_transaction(s
, bioc
, fb
);
617 /* Throw the unreported error message after exited from loop */
619 error_report_err(local_err
);
627 * There are only two reasons we can get here, some error happened
628 * or the user triggered failover.
630 switch (failover_get_state()) {
631 case FAILOVER_STATUS_COMPLETED
:
632 qapi_event_send_colo_exit(COLO_MODE_PRIMARY
,
633 COLO_EXIT_REASON_REQUEST
);
636 qapi_event_send_colo_exit(COLO_MODE_PRIMARY
,
637 COLO_EXIT_REASON_ERROR
);
640 /* Hope this not to be too long to wait here */
641 qemu_sem_wait(&s
->colo_exit_sem
);
642 qemu_sem_destroy(&s
->colo_exit_sem
);
645 * It is safe to unregister notifier after failover finished.
646 * Besides, colo_delay_timer and colo_checkpoint_sem can't be
647 * released before unregister notifier, or there will be use-after-free
650 colo_compare_unregister_notifier(&packets_compare_notifier
);
651 timer_free(s
->colo_delay_timer
);
652 qemu_event_destroy(&s
->colo_checkpoint_event
);
655 * Must be called after failover BH is completed,
656 * Or the failover BH may shutdown the wrong fd that
657 * re-used by other threads after we release here.
659 if (s
->rp_state
.from_dst_file
) {
660 qemu_fclose(s
->rp_state
.from_dst_file
);
661 s
->rp_state
.from_dst_file
= NULL
;
665 void migrate_start_colo_process(MigrationState
*s
)
667 qemu_mutex_unlock_iothread();
668 qemu_event_init(&s
->colo_checkpoint_event
, false);
669 s
->colo_delay_timer
= timer_new_ms(QEMU_CLOCK_HOST
,
670 colo_checkpoint_notify
, s
);
672 qemu_sem_init(&s
->colo_exit_sem
, 0);
673 colo_process_checkpoint(s
);
674 qemu_mutex_lock_iothread();
677 static void colo_incoming_process_checkpoint(MigrationIncomingState
*mis
,
678 QEMUFile
*fb
, QIOChannelBuffer
*bioc
, Error
**errp
)
682 Error
*local_err
= NULL
;
685 qemu_mutex_lock_iothread();
686 vm_stop_force_state(RUN_STATE_COLO
);
687 qemu_mutex_unlock_iothread();
688 trace_colo_vm_state_change("run", "stop");
690 /* FIXME: This is unnecessary for periodic checkpoint mode */
691 colo_send_message(mis
->to_src_file
, COLO_MESSAGE_CHECKPOINT_REPLY
,
694 error_propagate(errp
, local_err
);
698 colo_receive_check_message(mis
->from_src_file
,
699 COLO_MESSAGE_VMSTATE_SEND
, &local_err
);
701 error_propagate(errp
, local_err
);
705 qemu_mutex_lock_iothread();
706 cpu_synchronize_all_states();
707 ret
= qemu_loadvm_state_main(mis
->from_src_file
, mis
);
708 qemu_mutex_unlock_iothread();
711 error_setg(errp
, "Load VM's live state (ram) error");
715 value
= colo_receive_message_value(mis
->from_src_file
,
716 COLO_MESSAGE_VMSTATE_SIZE
, &local_err
);
718 error_propagate(errp
, local_err
);
723 * Read VM device state data into channel buffer,
724 * It's better to re-use the memory allocated.
725 * Here we need to handle the channel buffer directly.
727 if (value
> bioc
->capacity
) {
728 bioc
->capacity
= value
;
729 bioc
->data
= g_realloc(bioc
->data
, bioc
->capacity
);
731 total_size
= qemu_get_buffer(mis
->from_src_file
, bioc
->data
, value
);
732 if (total_size
!= value
) {
733 error_setg(errp
, "Got %" PRIu64
" VMState data, less than expected"
734 " %" PRIu64
, total_size
, value
);
737 bioc
->usage
= total_size
;
738 qio_channel_io_seek(QIO_CHANNEL(bioc
), 0, 0, NULL
);
740 colo_send_message(mis
->to_src_file
, COLO_MESSAGE_VMSTATE_RECEIVED
,
743 error_propagate(errp
, local_err
);
747 qemu_mutex_lock_iothread();
748 vmstate_loading
= true;
749 colo_flush_ram_cache();
750 ret
= qemu_load_device_state(fb
);
752 error_setg(errp
, "COLO: load device state failed");
753 vmstate_loading
= false;
754 qemu_mutex_unlock_iothread();
758 #ifdef CONFIG_REPLICATION
759 replication_get_error_all(&local_err
);
761 error_propagate(errp
, local_err
);
762 vmstate_loading
= false;
763 qemu_mutex_unlock_iothread();
767 /* discard colo disk buffer */
768 replication_do_checkpoint_all(&local_err
);
770 error_propagate(errp
, local_err
);
771 vmstate_loading
= false;
772 qemu_mutex_unlock_iothread();
778 /* Notify all filters of all NIC to do checkpoint */
779 colo_notify_filters_event(COLO_EVENT_CHECKPOINT
, &local_err
);
782 error_propagate(errp
, local_err
);
783 vmstate_loading
= false;
784 qemu_mutex_unlock_iothread();
788 vmstate_loading
= false;
790 qemu_mutex_unlock_iothread();
791 trace_colo_vm_state_change("stop", "run");
793 if (failover_get_state() == FAILOVER_STATUS_RELAUNCH
) {
797 colo_send_message(mis
->to_src_file
, COLO_MESSAGE_VMSTATE_LOADED
,
799 error_propagate(errp
, local_err
);
802 static void colo_wait_handle_message(MigrationIncomingState
*mis
,
803 QEMUFile
*fb
, QIOChannelBuffer
*bioc
, Error
**errp
)
806 Error
*local_err
= NULL
;
808 msg
= colo_receive_message(mis
->from_src_file
, &local_err
);
810 error_propagate(errp
, local_err
);
815 case COLO_MESSAGE_CHECKPOINT_REQUEST
:
816 colo_incoming_process_checkpoint(mis
, fb
, bioc
, errp
);
819 error_setg(errp
, "Got unknown COLO message: %d", msg
);
824 void colo_shutdown(void)
826 MigrationIncomingState
*mis
= NULL
;
827 MigrationState
*s
= NULL
;
829 switch (get_colo_mode()) {
830 case COLO_MODE_PRIMARY
:
831 s
= migrate_get_current();
832 qemu_event_set(&s
->colo_checkpoint_event
);
833 qemu_sem_post(&s
->colo_exit_sem
);
835 case COLO_MODE_SECONDARY
:
836 mis
= migration_incoming_get_current();
837 qemu_sem_post(&mis
->colo_incoming_sem
);
844 void *colo_process_incoming_thread(void *opaque
)
846 MigrationIncomingState
*mis
= opaque
;
848 QIOChannelBuffer
*bioc
= NULL
; /* Cache incoming device state */
849 Error
*local_err
= NULL
;
851 rcu_register_thread();
852 qemu_sem_init(&mis
->colo_incoming_sem
, 0);
854 migrate_set_state(&mis
->state
, MIGRATION_STATUS_ACTIVE
,
855 MIGRATION_STATUS_COLO
);
857 if (get_colo_mode() != COLO_MODE_SECONDARY
) {
858 error_report("COLO mode must be COLO_MODE_SECONDARY");
862 failover_init_state();
864 mis
->to_src_file
= qemu_file_get_return_path(mis
->from_src_file
);
865 if (!mis
->to_src_file
) {
866 error_report("COLO incoming thread: Open QEMUFile to_src_file failed");
870 * Note: the communication between Primary side and Secondary side
871 * should be sequential, we set the fd to unblocked in migration incoming
872 * coroutine, and here we are in the COLO incoming thread, so it is ok to
873 * set the fd back to blocked.
875 qemu_file_set_blocking(mis
->from_src_file
, true);
877 colo_incoming_start_dirty_log();
879 bioc
= qio_channel_buffer_new(COLO_BUFFER_BASE_SIZE
);
880 fb
= qemu_file_new_input(QIO_CHANNEL(bioc
));
881 object_unref(OBJECT(bioc
));
883 qemu_mutex_lock_iothread();
884 #ifdef CONFIG_REPLICATION
885 replication_start_all(REPLICATION_MODE_SECONDARY
, &local_err
);
887 qemu_mutex_unlock_iothread();
894 qemu_mutex_unlock_iothread();
895 trace_colo_vm_state_change("stop", "run");
897 colo_send_message(mis
->to_src_file
, COLO_MESSAGE_CHECKPOINT_READY
,
903 while (mis
->state
== MIGRATION_STATUS_COLO
) {
904 colo_wait_handle_message(mis
, fb
, bioc
, &local_err
);
906 error_report_err(local_err
);
910 if (failover_get_state() == FAILOVER_STATUS_RELAUNCH
) {
911 failover_set_state(FAILOVER_STATUS_RELAUNCH
,
912 FAILOVER_STATUS_NONE
);
913 failover_request_active(NULL
);
917 if (failover_get_state() != FAILOVER_STATUS_NONE
) {
918 error_report("failover request");
925 * There are only two reasons we can get here, some error happened
926 * or the user triggered failover.
928 switch (failover_get_state()) {
929 case FAILOVER_STATUS_COMPLETED
:
930 qapi_event_send_colo_exit(COLO_MODE_SECONDARY
,
931 COLO_EXIT_REASON_REQUEST
);
934 qapi_event_send_colo_exit(COLO_MODE_SECONDARY
,
935 COLO_EXIT_REASON_ERROR
);
942 /* Hope this not to be too long to loop here */
943 qemu_sem_wait(&mis
->colo_incoming_sem
);
944 qemu_sem_destroy(&mis
->colo_incoming_sem
);
946 rcu_unregister_thread();