4 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
5 * Copyright (c) 2016 Intel Corporation
6 * Copyright (c) 2016 FUJITSU LIMITED
11 * This work is licensed under the terms of the GNU GPL, version 2 or later.
12 * See the COPYING file in the top-level directory.
15 #include "qemu/osdep.h"
16 #include "qapi/error.h"
17 #include "block/replication.h"
19 static QLIST_HEAD(, ReplicationState) replication_states;
21 ReplicationState *replication_new(void *opaque, ReplicationOps *ops)
26 rs = g_new0(ReplicationState, 1);
29 QLIST_INSERT_HEAD(&replication_states, rs, node);
34 void replication_remove(ReplicationState *rs)
37 QLIST_REMOVE(rs, node);
43 * The caller of the function MUST make sure vm stopped
45 void replication_start_all(ReplicationMode mode, Error **errp)
47 ReplicationState *rs, *next;
48 Error *local_err = NULL;
50 QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
51 if (rs->ops && rs->ops->start) {
52 rs->ops->start(rs, mode, &local_err);
55 error_propagate(errp, local_err);
61 void replication_do_checkpoint_all(Error **errp)
63 ReplicationState *rs, *next;
64 Error *local_err = NULL;
66 QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
67 if (rs->ops && rs->ops->checkpoint) {
68 rs->ops->checkpoint(rs, &local_err);
71 error_propagate(errp, local_err);
77 void replication_get_error_all(Error **errp)
79 ReplicationState *rs, *next;
80 Error *local_err = NULL;
82 QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
83 if (rs->ops && rs->ops->get_error) {
84 rs->ops->get_error(rs, &local_err);
87 error_propagate(errp, local_err);
93 void replication_stop_all(bool failover, Error **errp)
95 ReplicationState *rs, *next;
96 Error *local_err = NULL;
98 QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
99 if (rs->ops && rs->ops->stop) {
100 rs->ops->stop(rs, failover, &local_err);
103 error_propagate(errp, local_err);