[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 57/69] Add new block driver interface to add/delete a
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 57/69] Add new block driver interface to add/delete a BDS's child |
Date: |
Thu, 12 May 2016 16:35:37 +0200 |
From: Wen Congyang <address@hidden>
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>
Signed-off-by: Changlong Xie <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
block.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++
include/block/block.h | 4 ++++
include/block/block_int.h | 5 +++++
3 files changed, 58 insertions(+)
diff --git a/block.c b/block.c
index 724b3b2..0726dab 100644
--- a/block.c
+++ b/block.c
@@ -4011,3 +4011,52 @@ void bdrv_refresh_filename(BlockDriverState *bs)
QDECREF(json);
}
}
+
+/*
+ * 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 *parent_bs, BlockDriverState *child_bs,
+ Error **errp)
+{
+
+ if (!parent_bs->drv || !parent_bs->drv->bdrv_add_child) {
+ error_setg(errp, "The node %s does not support adding a child",
+ bdrv_get_device_or_node_name(parent_bs));
+ return;
+ }
+
+ if (!QLIST_EMPTY(&child_bs->parents)) {
+ error_setg(errp, "The node %s already has a parent",
+ child_bs->node_name);
+ return;
+ }
+
+ parent_bs->drv->bdrv_add_child(parent_bs, child_bs, errp);
+}
+
+void bdrv_del_child(BlockDriverState *parent_bs, BdrvChild *child, Error
**errp)
+{
+ BdrvChild *tmp;
+
+ if (!parent_bs->drv || !parent_bs->drv->bdrv_del_child) {
+ error_setg(errp, "The node %s does not support removing a child",
+ bdrv_get_device_or_node_name(parent_bs));
+ return;
+ }
+
+ QLIST_FOREACH(tmp, &parent_bs->children, next) {
+ if (tmp == child) {
+ break;
+ }
+ }
+
+ if (!tmp) {
+ error_setg(errp, "The node %s does not have a child named %s",
+ bdrv_get_device_or_node_name(parent_bs),
+ bdrv_get_device_or_node_name(child->bs));
+ return;
+ }
+
+ parent_bs->drv->bdrv_del_child(parent_bs, child, errp);
+}
diff --git a/include/block/block.h b/include/block/block.h
index 0e8b4d1..c44d0a0 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -542,4 +542,8 @@ void bdrv_drained_begin(BlockDriverState *bs);
*/
void bdrv_drained_end(BlockDriverState *bs);
+void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child,
+ Error **errp);
+void bdrv_del_child(BlockDriverState *parent, BdrvChild *child, Error **errp);
+
#endif
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 2709488..a029c20 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -314,6 +314,11 @@ struct BlockDriver {
*/
void (*bdrv_drain)(BlockDriverState *bs);
+ void (*bdrv_add_child)(BlockDriverState *parent, BlockDriverState *child,
+ Error **errp);
+ void (*bdrv_del_child)(BlockDriverState *parent, BdrvChild *child,
+ Error **errp);
+
QLIST_ENTRY(BlockDriver) list;
};
--
1.8.3.1
- [Qemu-devel] [PULL 43/69] atapi: Switch to byte-based block access, (continued)
- [Qemu-devel] [PULL 43/69] atapi: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 45/69] qemu-img: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 52/69] block: Invalidate all children, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 55/69] iotests: fix the redirection order in 083, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 64/69] qemu-io: Add 'write -f' to test FUA flag, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 66/69] block: add support for --image-opts in block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 67/69] block: add support for encryption secrets in block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 41/69] sd: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 56/69] qemu-img: check block status of backing file when converting., Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 53/69] block: Drop superfluous invalidating bs->file from drivers, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 57/69] Add new block driver interface to add/delete a BDS's child,
Kevin Wolf <=
- [Qemu-devel] [PULL 54/69] block: Inactivate all children, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 65/69] qemu-io: Add 'write -z -u' to test MAY_UNMAP flag, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 62/69] qemu-io: Use bool for command line flags, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 58/69] quorum: implement bdrv_add_child() and bdrv_del_child(), Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 61/69] qemu-io: Make 'open' subcommand more like command line, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 60/69] qemu-io: Add missing option documentation, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 68/69] block: enable testing of LUKS driver with block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 63/69] qemu-io: Allow unaligned access by default, Kevin Wolf, 2016/05/12
- Re: [Qemu-devel] [PULL 00/69] Block layer patches, Peter Maydell, 2016/05/12