hw/arm/virt-acpi-build: don't save VirtGuestInfo on AcpiBuildState
[qemu.git] / migration / colo-comm.c
1 /*
2 * COarse-grain LOck-stepping Virtual Machines for Non-stop Service (COLO)
3 * (a.k.a. Fault Tolerance or Continuous Replication)
4 *
5 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
6 * Copyright (c) 2016 FUJITSU LIMITED
7 * Copyright (c) 2016 Intel Corporation
8 *
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.
11 *
12 */
13
14 #include "qemu/osdep.h"
15 #include <migration/colo.h>
16 #include "trace.h"
17
18 typedef struct {
19 bool colo_requested;
20 } COLOInfo;
21
22 static COLOInfo colo_info;
23
24 COLOMode get_colo_mode(void)
25 {
26 if (migration_in_colo_state()) {
27 return COLO_MODE_PRIMARY;
28 } else if (migration_incoming_in_colo_state()) {
29 return COLO_MODE_SECONDARY;
30 } else {
31 return COLO_MODE_UNKNOWN;
32 }
33 }
34
35 static void colo_info_pre_save(void *opaque)
36 {
37 COLOInfo *s = opaque;
38
39 s->colo_requested = migrate_colo_enabled();
40 }
41
42 static bool colo_info_need(void *opaque)
43 {
44 return migrate_colo_enabled();
45 }
46
47 static const VMStateDescription colo_state = {
48 .name = "COLOState",
49 .version_id = 1,
50 .minimum_version_id = 1,
51 .pre_save = colo_info_pre_save,
52 .needed = colo_info_need,
53 .fields = (VMStateField[]) {
54 VMSTATE_BOOL(colo_requested, COLOInfo),
55 VMSTATE_END_OF_LIST()
56 },
57 };
58
59 void colo_info_init(void)
60 {
61 vmstate_register(NULL, 0, &colo_state, &colo_info);
62 }
63
64 bool migration_incoming_enable_colo(void)
65 {
66 return colo_info.colo_requested;
67 }
68
69 void migration_incoming_exit_colo(void)
70 {
71 colo_info.colo_requested = false;
72 }