[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH COLO-BLOCK v8 01/18] Add new block driver interface
From: |
Wen Congyang |
Subject: |
[Qemu-block] [PATCH COLO-BLOCK v8 01/18] Add new block driver interface to add/delete a BDS's child |
Date: |
Tue, 7 Jul 2015 16:42:59 +0800 |
In some cases, we want to take a quorum child offline, and take
another child online.
Signed-off-by: Wen Congyang <address@hidden>
Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Gonglei <address@hidden>
---
block.c | 39 +++++++++++++++++++++++++++++++++++++++
include/block/block.h | 4 ++++
include/block/block_int.h | 5 +++++
3 files changed, 48 insertions(+)
diff --git a/block.c b/block.c
index 7e130cc..2cbc4f9 100644
--- a/block.c
+++ b/block.c
@@ -4195,3 +4195,42 @@ BlockAcctStats *bdrv_get_stats(BlockDriverState *bs)
{
return &bs->stats;
}
+
+/*
+ * Hot add/remove a BDS's child. So the user can take a child offline when
+ * it is broken and take a new child online
+ */
+void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp)
+{
+
+ if (!bs->drv || !bs->drv->bdrv_add_child) {
+ error_setg(errp, "this feature or command is not currently supported");
+ return;
+ }
+
+ bs->drv->bdrv_add_child(bs, options, errp);
+}
+
+void bdrv_del_child(BlockDriverState *bs, BlockDriverState *child_bs,
+ Error **errp)
+{
+ BdrvChild *child;
+
+ if (!bs->drv || !bs->drv->bdrv_del_child) {
+ error_setg(errp, "this feature or command is not currently supported");
+ return;
+ }
+
+ QLIST_FOREACH(child, &bs->children, next) {
+ if (child->bs == child_bs) {
+ break;
+ }
+ }
+
+ if (!child) {
+ error_setg(errp, "Invalid child");
+ return;
+ }
+
+ bs->drv->bdrv_del_child(bs, child_bs, errp);
+}
diff --git a/include/block/block.h b/include/block/block.h
index 06e4137..29d3363 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -609,4 +609,8 @@ void bdrv_flush_io_queue(BlockDriverState *bs);
BlockAcctStats *bdrv_get_stats(BlockDriverState *bs);
+void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp);
+void bdrv_del_child(BlockDriverState *bs, BlockDriverState *child,
+ Error **errp);
+
#endif
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 8996baf..6fddea4 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -288,6 +288,11 @@ struct BlockDriver {
*/
int (*bdrv_probe_geometry)(BlockDriverState *bs, HDGeometry *geo);
+ void (*bdrv_add_child)(BlockDriverState *bs, QDict *options,
+ Error **errp);
+ void (*bdrv_del_child)(BlockDriverState *bs, BlockDriverState *child,
+ Error **errp);
+
QLIST_ENTRY(BlockDriver) list;
};
--
2.4.3
- [Qemu-block] [PATCH COLO-BLOCK v8 00/18] Block replication for continuous checkpoints, Wen Congyang, 2015/07/07
- [Qemu-block] [PATCH COLO-BLOCK v8 01/18] Add new block driver interface to add/delete a BDS's child,
Wen Congyang <=
- [Qemu-block] [PATCH COLO-BLOCK v8 02/18] quorum: implement block driver interfaces add/delete a BDS's child, Wen Congyang, 2015/07/07
- [Qemu-block] [PATCH COLO-BLOCK v8 04/18] introduce a new API qemu_opts_absorb_qdict_by_index(), Wen Congyang, 2015/07/07
- [Qemu-block] [PATCH COLO-BLOCK v8 05/18] quorum: allow ignoring child errors, Wen Congyang, 2015/07/07
- [Qemu-block] [PATCH COLO-BLOCK v8 06/18] introduce a new API to enable/disable attach device model, Wen Congyang, 2015/07/07
- [Qemu-block] [PATCH COLO-BLOCK v8 07/18] introduce a new API to check if blk is attached, Wen Congyang, 2015/07/07
- [Qemu-block] [PATCH COLO-BLOCK v8 08/18] block: make bdrv_put_ref_bh_schedule() as a public API, Wen Congyang, 2015/07/07
- [Qemu-block] [PATCH COLO-BLOCK v8 09/18] Backup: clear all bitmap when doing block checkpoint, Wen Congyang, 2015/07/07
- [Qemu-block] [PATCH COLO-BLOCK v8 10/18] allow writing to the backing file, Wen Congyang, 2015/07/07