replication: move include out of root directory
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 17 May 2021 11:36:56 +0000 (07:36 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 26 May 2021 12:49:46 +0000 (14:49 +0200)
The replication.h file is included from migration/colo.c and tests/unit/test-replication.c,
so it should be in include/.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block/replication.c
include/block/replication.h [new file with mode: 0644]
migration/colo.c
replication.c
replication.h [deleted file]
tests/unit/test-replication.c

index 97be7ef4de54686705c833dced03187f5cb222b8..52163f2d1f98d1006815b4d7c9fef4db519ba8cc 100644 (file)
@@ -22,7 +22,7 @@
 #include "sysemu/block-backend.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qdict.h"
-#include "replication.h"
+#include "block/replication.h"
 
 typedef enum {
     BLOCK_REPLICATION_NONE,             /* block replication is not started */
diff --git a/include/block/replication.h b/include/block/replication.h
new file mode 100644 (file)
index 0000000..21931b4
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * Replication filter
+ *
+ * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
+ * Copyright (c) 2016 Intel Corporation
+ * Copyright (c) 2016 FUJITSU LIMITED
+ *
+ * Author:
+ *   Changlong Xie <xiecl.fnst@cn.fujitsu.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef REPLICATION_H
+#define REPLICATION_H
+
+#include "qapi/qapi-types-block-core.h"
+#include "qemu/module.h"
+#include "qemu/queue.h"
+
+typedef struct ReplicationOps ReplicationOps;
+typedef struct ReplicationState ReplicationState;
+
+/**
+ * SECTION:block/replication.h
+ * @title:Base Replication System
+ * @short_description: interfaces for handling replication
+ *
+ * The Replication Model provides a framework for handling Replication
+ *
+ * <example>
+ *   <title>How to use replication interfaces</title>
+ *   <programlisting>
+ * #include "block/replication.h"
+ *
+ * typedef struct BDRVReplicationState {
+ *     ReplicationState *rs;
+ * } BDRVReplicationState;
+ *
+ * static void replication_start(ReplicationState *rs, ReplicationMode mode,
+ *                               Error **errp);
+ * static void replication_do_checkpoint(ReplicationState *rs, Error **errp);
+ * static void replication_get_error(ReplicationState *rs, Error **errp);
+ * static void replication_stop(ReplicationState *rs, bool failover,
+ *                              Error **errp);
+ *
+ * static ReplicationOps replication_ops = {
+ *     .start = replication_start,
+ *     .checkpoint = replication_do_checkpoint,
+ *     .get_error = replication_get_error,
+ *     .stop = replication_stop,
+ * }
+ *
+ * static int replication_open(BlockDriverState *bs, QDict *options,
+ *                             int flags, Error **errp)
+ * {
+ *     BDRVReplicationState *s = bs->opaque;
+ *     s->rs = replication_new(bs, &replication_ops);
+ *     return 0;
+ * }
+ *
+ * static void replication_close(BlockDriverState *bs)
+ * {
+ *     BDRVReplicationState *s = bs->opaque;
+ *     replication_remove(s->rs);
+ * }
+ *
+ * BlockDriver bdrv_replication = {
+ *     .format_name                = "replication",
+ *     .instance_size              = sizeof(BDRVReplicationState),
+ *
+ *     .bdrv_open                  = replication_open,
+ *     .bdrv_close                 = replication_close,
+ * };
+ *
+ * static void bdrv_replication_init(void)
+ * {
+ *     bdrv_register(&bdrv_replication);
+ * }
+ *
+ * block_init(bdrv_replication_init);
+ *   </programlisting>
+ * </example>
+ *
+ * We create an example about how to use replication interfaces in above.
+ * Then in migration, we can use replication_(start/stop/do_checkpoint/
+ * get_error)_all to handle all replication operations.
+ */
+
+/**
+ * ReplicationState:
+ * @opaque: opaque pointer value passed to this ReplicationState
+ * @ops: replication operation of this ReplicationState
+ * @node: node that we will insert into @replication_states QLIST
+ */
+struct ReplicationState {
+    void *opaque;
+    ReplicationOps *ops;
+    QLIST_ENTRY(ReplicationState) node;
+};
+
+/**
+ * ReplicationOps:
+ * @start: callback to start replication
+ * @stop: callback to stop replication
+ * @checkpoint: callback to do checkpoint
+ * @get_error: callback to check if error occurred during replication
+ */
+struct ReplicationOps {
+    void (*start)(ReplicationState *rs, ReplicationMode mode, Error **errp);
+    void (*stop)(ReplicationState *rs, bool failover, Error **errp);
+    void (*checkpoint)(ReplicationState *rs, Error **errp);
+    void (*get_error)(ReplicationState *rs, Error **errp);
+};
+
+/**
+ * replication_new:
+ * @opaque: opaque pointer value passed to ReplicationState
+ * @ops: replication operation of the new relevant ReplicationState
+ *
+ * Called to create a new ReplicationState instance, and then insert it
+ * into @replication_states QLIST
+ *
+ * Returns: the new ReplicationState instance
+ */
+ReplicationState *replication_new(void *opaque, ReplicationOps *ops);
+
+/**
+ * replication_remove:
+ * @rs: the ReplicationState instance to remove
+ *
+ * Called to remove a ReplicationState instance, and then delete it from
+ * @replication_states QLIST
+ */
+void replication_remove(ReplicationState *rs);
+
+/**
+ * replication_start_all:
+ * @mode: replication mode that could be "primary" or "secondary"
+ * @errp: returns an error if this function fails
+ *
+ * Start replication, called in migration/checkpoint thread
+ *
+ * Note: the caller of the function MUST make sure vm stopped
+ */
+void replication_start_all(ReplicationMode mode, Error **errp);
+
+/**
+ * replication_do_checkpoint_all:
+ * @errp: returns an error if this function fails
+ *
+ * This interface is called after all VM state is transferred to Secondary QEMU
+ */
+void replication_do_checkpoint_all(Error **errp);
+
+/**
+ * replication_get_error_all:
+ * @errp: returns an error if this function fails
+ *
+ * This interface is called to check if error occurred during replication
+ */
+void replication_get_error_all(Error **errp);
+
+/**
+ * replication_stop_all:
+ * @failover: boolean value that indicates if we need do failover or not
+ * @errp: returns an error if this function fails
+ *
+ * It is called on failover. The vm should be stopped before calling it, if you
+ * use this API to shutdown the guest, or other things except failover
+ */
+void replication_stop_all(bool failover, Error **errp);
+
+#endif /* REPLICATION_H */
index de27662cab561605d3d53d3b5659f4e0e78c5a19..e498fdb125d87f8d4b8ee20fb132fd1c2b8f4c05 100644 (file)
@@ -28,7 +28,7 @@
 #include "migration/failover.h"
 #include "migration/ram.h"
 #ifdef CONFIG_REPLICATION
-#include "replication.h"
+#include "block/replication.h"
 #endif
 #include "net/colo-compare.h"
 #include "net/colo.h"
index be3a42f9c9dcc67704c5e9b10b3baf49dc1a10fd..4acd3f8004cbbee3b38f6bc3f09b86bf6d2126e0 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "replication.h"
+#include "block/replication.h"
 
 static QLIST_HEAD(, ReplicationState) replication_states;
 
diff --git a/replication.h b/replication.h
deleted file mode 100644 (file)
index d49fc22..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Replication filter
- *
- * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
- * Copyright (c) 2016 Intel Corporation
- * Copyright (c) 2016 FUJITSU LIMITED
- *
- * Author:
- *   Changlong Xie <xiecl.fnst@cn.fujitsu.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef REPLICATION_H
-#define REPLICATION_H
-
-#include "qapi/qapi-types-block-core.h"
-#include "qemu/module.h"
-#include "qemu/queue.h"
-
-typedef struct ReplicationOps ReplicationOps;
-typedef struct ReplicationState ReplicationState;
-
-/**
- * SECTION:replication.h
- * @title:Base Replication System
- * @short_description: interfaces for handling replication
- *
- * The Replication Model provides a framework for handling Replication
- *
- * <example>
- *   <title>How to use replication interfaces</title>
- *   <programlisting>
- * #include "replication.h"
- *
- * typedef struct BDRVReplicationState {
- *     ReplicationState *rs;
- * } BDRVReplicationState;
- *
- * static void replication_start(ReplicationState *rs, ReplicationMode mode,
- *                               Error **errp);
- * static void replication_do_checkpoint(ReplicationState *rs, Error **errp);
- * static void replication_get_error(ReplicationState *rs, Error **errp);
- * static void replication_stop(ReplicationState *rs, bool failover,
- *                              Error **errp);
- *
- * static ReplicationOps replication_ops = {
- *     .start = replication_start,
- *     .checkpoint = replication_do_checkpoint,
- *     .get_error = replication_get_error,
- *     .stop = replication_stop,
- * }
- *
- * static int replication_open(BlockDriverState *bs, QDict *options,
- *                             int flags, Error **errp)
- * {
- *     BDRVReplicationState *s = bs->opaque;
- *     s->rs = replication_new(bs, &replication_ops);
- *     return 0;
- * }
- *
- * static void replication_close(BlockDriverState *bs)
- * {
- *     BDRVReplicationState *s = bs->opaque;
- *     replication_remove(s->rs);
- * }
- *
- * BlockDriver bdrv_replication = {
- *     .format_name                = "replication",
- *     .instance_size              = sizeof(BDRVReplicationState),
- *
- *     .bdrv_open                  = replication_open,
- *     .bdrv_close                 = replication_close,
- * };
- *
- * static void bdrv_replication_init(void)
- * {
- *     bdrv_register(&bdrv_replication);
- * }
- *
- * block_init(bdrv_replication_init);
- *   </programlisting>
- * </example>
- *
- * We create an example about how to use replication interfaces in above.
- * Then in migration, we can use replication_(start/stop/do_checkpoint/
- * get_error)_all to handle all replication operations.
- */
-
-/**
- * ReplicationState:
- * @opaque: opaque pointer value passed to this ReplicationState
- * @ops: replication operation of this ReplicationState
- * @node: node that we will insert into @replication_states QLIST
- */
-struct ReplicationState {
-    void *opaque;
-    ReplicationOps *ops;
-    QLIST_ENTRY(ReplicationState) node;
-};
-
-/**
- * ReplicationOps:
- * @start: callback to start replication
- * @stop: callback to stop replication
- * @checkpoint: callback to do checkpoint
- * @get_error: callback to check if error occurred during replication
- */
-struct ReplicationOps {
-    void (*start)(ReplicationState *rs, ReplicationMode mode, Error **errp);
-    void (*stop)(ReplicationState *rs, bool failover, Error **errp);
-    void (*checkpoint)(ReplicationState *rs, Error **errp);
-    void (*get_error)(ReplicationState *rs, Error **errp);
-};
-
-/**
- * replication_new:
- * @opaque: opaque pointer value passed to ReplicationState
- * @ops: replication operation of the new relevant ReplicationState
- *
- * Called to create a new ReplicationState instance, and then insert it
- * into @replication_states QLIST
- *
- * Returns: the new ReplicationState instance
- */
-ReplicationState *replication_new(void *opaque, ReplicationOps *ops);
-
-/**
- * replication_remove:
- * @rs: the ReplicationState instance to remove
- *
- * Called to remove a ReplicationState instance, and then delete it from
- * @replication_states QLIST
- */
-void replication_remove(ReplicationState *rs);
-
-/**
- * replication_start_all:
- * @mode: replication mode that could be "primary" or "secondary"
- * @errp: returns an error if this function fails
- *
- * Start replication, called in migration/checkpoint thread
- *
- * Note: the caller of the function MUST make sure vm stopped
- */
-void replication_start_all(ReplicationMode mode, Error **errp);
-
-/**
- * replication_do_checkpoint_all:
- * @errp: returns an error if this function fails
- *
- * This interface is called after all VM state is transferred to Secondary QEMU
- */
-void replication_do_checkpoint_all(Error **errp);
-
-/**
- * replication_get_error_all:
- * @errp: returns an error if this function fails
- *
- * This interface is called to check if error occurred during replication
- */
-void replication_get_error_all(Error **errp);
-
-/**
- * replication_stop_all:
- * @failover: boolean value that indicates if we need do failover or not
- * @errp: returns an error if this function fails
- *
- * It is called on failover. The vm should be stopped before calling it, if you
- * use this API to shutdown the guest, or other things except failover
- */
-void replication_stop_all(bool failover, Error **errp);
-
-#endif /* REPLICATION_H */
index b067240adddcfbe40070fc07b4a081677a208b0f..afff908d77a1f4a80c7822cad836d020e25d374b 100644 (file)
@@ -14,7 +14,7 @@
 #include "qapi/qmp/qdict.h"
 #include "qemu/option.h"
 #include "qemu/main-loop.h"
-#include "replication.h"
+#include "block/replication.h"
 #include "block/block_int.h"
 #include "block/qdict.h"
 #include "sysemu/block-backend.h"