[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH COLO-BLOCK v7 01/17] Add new block driver interface
From: |
Wen Congyang |
Subject: |
[Qemu-devel] [PATCH COLO-BLOCK v7 01/17] Add new block driver interface to add/delete a BDS's child |
Date: |
Tue, 30 Jun 2015 11:34:29 +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 81233be..617e431 100644
--- a/block.c
+++ b/block.c
@@ -4207,3 +4207,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 07bb724..c43160d 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -605,4 +605,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 b0476fc..d7af9e3 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-devel] [PATCH COLO-BLOCK v7 00/17] Block replication for continuous checkpoints, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 01/17] Add new block driver interface to add/delete a BDS's child,
Wen Congyang <=
- [Qemu-devel] [PATCH COLO-BLOCK v7 04/17] introduce a new API qemu_opts_absorb_qdict_by_index(), Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 03/17] hmp: add monitor command to add/remove a child, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 05/17] quorum: allow ignoring child errors, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 06/17] introduce a new API to enable/disable attach device model, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 08/17] block: make bdrv_put_ref_bh_schedule() as a public API, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 07/17] introduce a new API to check if blk is attached, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 09/17] Backup: clear all bitmap when doing block checkpoint, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 11/17] Allow creating backup jobs when opening BDS, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 10/17] allow writing to the backing file, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 12/17] block: Allow references for backing files, Wen Congyang, 2015/06/29