[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [Patch v12 resend 10/10] Add a new API to start/stop replic
From: |
Wen Congyang |
Subject: |
[Qemu-devel] [Patch v12 resend 10/10] Add a new API to start/stop replication, do checkpoint to all BDSes |
Date: |
Wed, 2 Dec 2015 13:38:30 +0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
Signed-off-by: Wen Congyang <address@hidden>
Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Gonglei <address@hidden>
---
block.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++
include/block/block.h | 4 +++
2 files changed, 87 insertions(+)
diff --git a/block.c b/block.c
index 213bee8..09ee7f1 100644
--- a/block.c
+++ b/block.c
@@ -4433,3 +4433,86 @@ void bdrv_stop_replication(BlockDriverState *bs, bool
failover, Error **errp)
" replication", bs->filename);
}
}
+
+void bdrv_start_replication_all(ReplicationMode mode, Error **errp)
+{
+ BlockDriverState *bs = NULL, *temp = NULL;
+ Error *local_err = NULL;
+
+ while ((bs = bdrv_next(bs))) {
+ if (!QLIST_EMPTY(&bs->parents)) {
+ /* It is not top BDS */
+ continue;
+ }
+
+ if (bdrv_is_read_only(bs) || !bdrv_is_inserted(bs)) {
+ continue;
+ }
+
+ bdrv_start_replication(bs, mode, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ goto fail;
+ }
+ }
+
+ return;
+
+fail:
+ while ((temp = bdrv_next(temp)) && bs != temp) {
+ bdrv_stop_replication(temp, false, NULL);
+ }
+}
+
+void bdrv_do_checkpoint_all(Error **errp)
+{
+ BlockDriverState *bs = NULL;
+ Error *local_err = NULL;
+
+ while ((bs = bdrv_next(bs))) {
+ if (!QLIST_EMPTY(&bs->parents)) {
+ /* It is not top BDS */
+ continue;
+ }
+
+ if (bdrv_is_read_only(bs) || !bdrv_is_inserted(bs)) {
+ continue;
+ }
+
+ bdrv_do_checkpoint(bs, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+ }
+}
+
+void bdrv_stop_replication_all(bool failover, Error **errp)
+{
+ BlockDriverState *bs = NULL;
+ Error *local_err = NULL;
+
+ while ((bs = bdrv_next(bs))) {
+ if (!QLIST_EMPTY(&bs->parents)) {
+ /* It is not top BDS */
+ continue;
+ }
+
+ if (bdrv_is_read_only(bs) || !bdrv_is_inserted(bs)) {
+ continue;
+ }
+
+ bdrv_stop_replication(bs, failover, &local_err);
+ if (!errp) {
+ /*
+ * The caller doesn't care the result, they just
+ * want to stop all block's replication.
+ */
+ continue;
+ }
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+ }
+}
diff --git a/include/block/block.h b/include/block/block.h
index cd39d50..39d246c 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -653,4 +653,8 @@ void bdrv_start_replication(BlockDriverState *bs,
ReplicationMode mode,
void bdrv_do_checkpoint(BlockDriverState *bs, Error **errp);
void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp);
+void bdrv_start_replication_all(ReplicationMode mode, Error **errp);
+void bdrv_do_checkpoint_all(Error **errp);
+void bdrv_stop_replication_all(bool failover, Error **errp);
+
#endif
--
2.5.0
- [Qemu-devel] [Patch v12 resend 00/10] Block replication for continuous checkpoints, Wen Congyang, 2015/12/02
- [Qemu-devel] [Patch v12 resend 01/10] unblock backup operations in backing file, Wen Congyang, 2015/12/02
- [Qemu-devel] [Patch v12 resend 02/10] Store parent BDS in BdrvChild, Wen Congyang, 2015/12/02
- [Qemu-devel] [Patch v12 resend 03/10] Backup: clear all bitmap when doing block checkpoint, Wen Congyang, 2015/12/02
- [Qemu-devel] [Patch v12 resend 04/10] Allow creating backup jobs when opening BDS, Wen Congyang, 2015/12/02
- [Qemu-devel] [Patch v12 resend 05/10] docs: block replication's description, Wen Congyang, 2015/12/02
- [Qemu-devel] [Patch v12 resend 07/10] quorum: implement block driver interfaces for block replication, Wen Congyang, 2015/12/02
- [Qemu-devel] [Patch v12 resend 06/10] Add new block driver interfaces to control block replication, Wen Congyang, 2015/12/02
- [Qemu-devel] [Patch v12 resend 08/10] Implement new driver for block replication, Wen Congyang, 2015/12/02
- [Qemu-devel] [Patch v12 resend 09/10] support replication driver in blockdev-add, Wen Congyang, 2015/12/02
- [Qemu-devel] [Patch v12 resend 10/10] Add a new API to start/stop replication, do checkpoint to all BDSes,
Wen Congyang <=
- Re: [Qemu-devel] [Patch v12 resend 00/10] Block replication for continuous checkpoints, Wen Congyang, 2015/12/17