]> git.proxmox.com Git - mirror_qemu.git/blame - migration/colo-comm.c
xbzrle: Drop unused cache_resize()
[mirror_qemu.git] / migration / colo-comm.c
CommitLineData
5821ebf9
HZ
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"
6666c96a 15#include "migration.h"
c59be019 16#include "migration/colo.h"
987772d9 17#include "migration/vmstate.h"
5821ebf9
HZ
18#include "trace.h"
19
20typedef struct {
21 bool colo_requested;
22} COLOInfo;
23
24static COLOInfo colo_info;
25
d89e666e
HZ
26COLOMode get_colo_mode(void)
27{
28 if (migration_in_colo_state()) {
29 return COLO_MODE_PRIMARY;
30 } else if (migration_incoming_in_colo_state()) {
31 return COLO_MODE_SECONDARY;
32 } else {
33 return COLO_MODE_UNKNOWN;
34 }
35}
36
5821ebf9
HZ
37static void colo_info_pre_save(void *opaque)
38{
39 COLOInfo *s = opaque;
40
41 s->colo_requested = migrate_colo_enabled();
42}
43
44static bool colo_info_need(void *opaque)
45{
46 return migrate_colo_enabled();
47}
48
49static const VMStateDescription colo_state = {
50 .name = "COLOState",
51 .version_id = 1,
52 .minimum_version_id = 1,
53 .pre_save = colo_info_pre_save,
54 .needed = colo_info_need,
55 .fields = (VMStateField[]) {
56 VMSTATE_BOOL(colo_requested, COLOInfo),
57 VMSTATE_END_OF_LIST()
58 },
59};
60
61void colo_info_init(void)
62{
63 vmstate_register(NULL, 0, &colo_state, &colo_info);
64}
25d0c16f
HZ
65
66bool migration_incoming_enable_colo(void)
67{
68 return colo_info.colo_requested;
69}
70
71void migration_incoming_exit_colo(void)
72{
73 colo_info.colo_requested = false;
74}