[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH COLO-Block v6 11/16] Add new block driver interfaces
From: |
Wen Congyang |
Subject: |
[Qemu-block] [PATCH COLO-Block v6 11/16] Add new block driver interfaces to control block replication |
Date: |
Thu, 18 Jun 2015 16:49:16 +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 | 40 ++++++++++++++++++++++++++++++++++++++++
include/block/block.h | 5 +++++
include/block/block_int.h | 14 ++++++++++++++
qapi/block.json | 16 ++++++++++++++++
4 files changed, 75 insertions(+)
diff --git a/block.c b/block.c
index 59071d4..06222bf 100644
--- a/block.c
+++ b/block.c
@@ -4424,3 +4424,43 @@ void bdrv_disconnect(BlockDriverState *bs)
bdrv_disconnect(bs->file);
}
}
+
+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, mode, errp);
+ } else {
+ error_setg(errp, "this feature or command is not currently supported");
+ }
+}
+
+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, errp);
+ } else {
+ error_setg(errp, "this feature or command is not currently supported");
+ }
+}
+
+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, failover, errp);
+ } else {
+ error_setg(errp, "this feature or command is not currently supported");
+ }
+}
diff --git a/include/block/block.h b/include/block/block.h
index 4b3a2b9..573d39f 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -610,4 +610,9 @@ BlockAcctStats *bdrv_get_stats(BlockDriverState *bs);
void bdrv_connect(BlockDriverState *bs, Error **errp);
void bdrv_disconnect(BlockDriverState *bs);
+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 a3e5372..27ff3da 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -293,6 +293,20 @@ struct BlockDriver {
void (*bdrv_connect)(BlockDriverState *bs, Error **errp);
void (*bdrv_disconnect)(BlockDriverState *bs);
+ 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.json b/qapi/block.json
index aad645c..04dc4c2 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -40,6 +40,22 @@
'data': ['auto', 'none', 'lba', 'large', 'rechs']}
##
+# @ReplicationMode
+#
+# An enumeration of replication modes.
+#
+# @unprotected: Replication is not started or after failover.
+#
+# @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.4
+##
+{ 'enum' : 'ReplicationMode',
+ 'data' : ['unprotected', 'primary', 'secondary']}
+
+##
# @BlockdevSnapshotInternal
#
# @device: the name of the device to generate the snapshot from
--
2.4.3
- Re: [Qemu-block] [Qemu-devel] [PATCH COLO-Block v6 07/16] Add new block driver interface to connect/disconnect the remote target, (continued)
- [Qemu-block] [PATCH COLO-Block v6 04/16] block: Parse "backing_reference" option to reference existing BDS, Wen Congyang, 2015/06/18
- [Qemu-block] [PATCH COLO-Block v6 09/16] Introduce a new -drive option to control whether to connect to remote target, Wen Congyang, 2015/06/18
- [Qemu-block] [PATCH COLO-Block v6 10/16] NBD client: connect to nbd server later, Wen Congyang, 2015/06/18
- [Qemu-block] [PATCH COLO-Block v6 08/16] NBD client: implement block driver interfaces to connect/disconnect NBD server, Wen Congyang, 2015/06/18
- [Qemu-block] [PATCH COLO-Block v6 13/16] quorum: implement block driver interfaces for block replication, Wen Congyang, 2015/06/18
- [Qemu-block] [PATCH COLO-Block v6 11/16] Add new block driver interfaces to control block replication,
Wen Congyang <=
- [Qemu-block] [PATCH COLO-Block v6 12/16] skip nbd_target when starting block replication, Wen Congyang, 2015/06/18
- [Qemu-block] [PATCH COLO-Block v6 14/16] introduce a new API qemu_opts_absorb_qdict_by_index(), Wen Congyang, 2015/06/18
- [Qemu-block] [PATCH COLO-Block v6 15/16] quorum: allow ignoring child errors, Wen Congyang, 2015/06/18
- [Qemu-block] [PATCH COLO-Block v6 16/16] Implement new driver for block replication, Wen Congyang, 2015/06/18