[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [Patch v12 resend 06/10] Add new block driver interfaces to
From: |
Wen Congyang |
Subject: |
[Qemu-block] [Patch v12 resend 06/10] Add new block driver interfaces to control block replication |
Date: |
Wed, 2 Dec 2015 13:31:47 +0800 |
Signed-off-by: Wen Congyang <address@hidden>
Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Gonglei <address@hidden>
Cc: Luiz Capitulino <address@hidden>
Cc: Michael Roth <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
---
block.c | 43 +++++++++++++++++++++++++++++++++++++++++++
include/block/block.h | 5 +++++
include/block/block_int.h | 14 ++++++++++++++
qapi/block-core.json | 13 +++++++++++++
4 files changed, 75 insertions(+)
diff --git a/block.c b/block.c
index 0a0468f..213bee8 100644
--- a/block.c
+++ b/block.c
@@ -4390,3 +4390,46 @@ void bdrv_del_child(BlockDriverState *parent_bs,
BlockDriverState *child_bs,
parent_bs->drv->bdrv_del_child(parent_bs, child_bs, errp);
}
+
+void bdrv_start_replication(BlockDriverState *bs, ReplicationMode mode,
+ Error **errp)
+{
+ BlockDriver *drv = bs->drv;
+
+ if (drv && drv->bdrv_start_replication) {
+ drv->bdrv_start_replication(bs, mode, errp);
+ } else if (bs->file) {
+ bdrv_start_replication(bs->file->bs, mode, errp);
+ } else {
+ error_setg(errp, "The BDS %s doesn't support starting block"
+ " replication", bs->filename);
+ }
+}
+
+void bdrv_do_checkpoint(BlockDriverState *bs, Error **errp)
+{
+ BlockDriver *drv = bs->drv;
+
+ if (drv && drv->bdrv_do_checkpoint) {
+ drv->bdrv_do_checkpoint(bs, errp);
+ } else if (bs->file) {
+ bdrv_do_checkpoint(bs->file->bs, errp);
+ } else {
+ error_setg(errp, "The BDS %s doesn't support block checkpoint",
+ bs->filename);
+ }
+}
+
+void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp)
+{
+ BlockDriver *drv = bs->drv;
+
+ if (drv && drv->bdrv_stop_replication) {
+ drv->bdrv_stop_replication(bs, failover, errp);
+ } else if (bs->file) {
+ bdrv_stop_replication(bs->file->bs, failover, errp);
+ } else {
+ error_setg(errp, "The BDS %s doesn't support stopping block"
+ " replication", bs->filename);
+ }
+}
diff --git a/include/block/block.h b/include/block/block.h
index 1d3b9c6..cd39d50 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -648,4 +648,9 @@ void bdrv_add_child(BlockDriverState *parent,
BlockDriverState *child,
void bdrv_del_child(BlockDriverState *parent, BlockDriverState *child,
Error **errp);
+void bdrv_start_replication(BlockDriverState *bs, ReplicationMode mode,
+ Error **errp);
+void bdrv_do_checkpoint(BlockDriverState *bs, Error **errp);
+void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp);
+
#endif
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 1f56046..a6aba8b 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -307,6 +307,20 @@ struct BlockDriver {
void (*bdrv_del_child)(BlockDriverState *parent, BlockDriverState *child,
Error **errp);
+ void (*bdrv_start_replication)(BlockDriverState *bs, ReplicationMode mode,
+ Error **errp);
+ /* Drop Disk buffer when doing checkpoint. */
+ void (*bdrv_do_checkpoint)(BlockDriverState *bs, Error **errp);
+ /*
+ * After failover, we should flush Disk buffer into secondary disk
+ * and stop block replication.
+ *
+ * If the guest is shutdown, we should drop Disk buffer and stop
+ * block representation.
+ */
+ void (*bdrv_stop_replication)(BlockDriverState *bs, bool failover,
+ Error **errp);
+
QLIST_ENTRY(BlockDriver) list;
};
diff --git a/qapi/block-core.json b/qapi/block-core.json
index feb8da2..2c6bd3f 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1925,6 +1925,19 @@
'*read-pattern': 'QuorumReadPattern' } }
##
+# @ReplicationMode
+#
+# An enumeration of replication modes.
+#
+# @primary: Primary mode, the vm's state will be sent to secondary QEMU.
+#
+# @secondary: Secondary mode, receive the vm's state from primary QEMU.
+#
+# Since: 2.5
+##
+{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] }
+
+##
# @BlockdevOptions
#
# Options for creating a block device.
--
2.5.0
- [Qemu-block] [Patch v12 resend 00/10] Block replication for continuous checkpoints, Wen Congyang, 2015/12/02
- [Qemu-block] [Patch v12 resend 02/10] Store parent BDS in BdrvChild, Wen Congyang, 2015/12/02
- [Qemu-block] [Patch v12 resend 01/10] unblock backup operations in backing file, Wen Congyang, 2015/12/02
- [Qemu-block] [Patch v12 resend 03/10] Backup: clear all bitmap when doing block checkpoint, Wen Congyang, 2015/12/02
- [Qemu-block] [Patch v12 resend 04/10] Allow creating backup jobs when opening BDS, Wen Congyang, 2015/12/02
- [Qemu-block] [Patch v12 resend 05/10] docs: block replication's description, Wen Congyang, 2015/12/02
- [Qemu-block] [Patch v12 resend 06/10] Add new block driver interfaces to control block replication,
Wen Congyang <=
- [Qemu-block] [Patch v12 resend 07/10] quorum: implement block driver interfaces for block replication, Wen Congyang, 2015/12/02
- [Qemu-block] [Patch v12 resend 08/10] Implement new driver for block replication, Wen Congyang, 2015/12/02
- [Qemu-block] [Patch v12 resend 09/10] support replication driver in blockdev-add, Wen Congyang, 2015/12/02
- [Qemu-block] [Patch v12 resend 10/10] Add a new API to start/stop replication, do checkpoint to all BDSes, Wen Congyang, 2015/12/02
- Re: [Qemu-block] [Patch v12 resend 00/10] Block replication for continuous checkpoints, Wen Congyang, 2015/12/17