@@ -4341,3 +4341,43 @@ void bdrv_del_child(BlockDriverState *bs, BlockDriverState *child_bs,
bs->drv->bdrv_del_child(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, 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");
+ }
+}
@@ -611,4 +611,9 @@ void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp);
void bdrv_del_child(BlockDriverState *bs, 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
@@ -293,6 +293,20 @@ struct BlockDriver {
void (*bdrv_del_child)(BlockDriverState *bs, 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;
};
@@ -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