* [Qemu-devel] [PATCH v4 1/4] Add new block driver interface to add/delete a BDS's child
2015-09-18 10:13 [Qemu-devel] [PATCH v4 0/4] qapi: child add/delete support Wen Congyang
@ 2015-09-18 10:13 ` Wen Congyang
2015-09-18 14:52 ` Eric Blake
2015-09-18 10:13 ` [Qemu-devel] [PATCH v4 2/4] quorum: implement bdrv_add_child() and bdrv_del_child() Wen Congyang
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Wen Congyang @ 2015-09-18 10:13 UTC (permalink / raw)
To: qemu devel, Eric Blake, Markus Armbruster, Alberto Garcia,
Stefan Hajnoczi
Cc: Kevin Wolf, qemu block, Jiang Yunhong, Dong Eddie,
Dr. David Alan Gilbert, Gonglei, Yang Hongyang, zhanghailiang
In some cases, we want to take a quorum child offline, and take
another child online.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
block.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
include/block/block.h | 5 +++++
include/block/block_int.h | 5 +++++
3 files changed, 60 insertions(+)
diff --git a/block.c b/block.c
index e815d73..bb7657b 100644
--- a/block.c
+++ b/block.c
@@ -4265,3 +4265,53 @@ 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 *parent_bs, BlockDriverState *child_bs,
+ Error **errp)
+{
+
+ if (!parent_bs->drv || !parent_bs->drv->bdrv_add_child) {
+ error_setg(errp, "The BDS %s doesn't support adding a child",
+ bdrv_get_device_or_node_name(parent_bs));
+ return;
+ }
+
+ if (!QLIST_EMPTY(&child_bs->parents)) {
+ error_setg(errp, "The BDS %s already has parent",
+ child_bs->node_name);
+ return;
+ }
+
+ parent_bs->drv->bdrv_add_child(parent_bs, child_bs, errp);
+}
+
+void bdrv_del_child(BlockDriverState *parent_bs, BlockDriverState *child_bs,
+ Error **errp)
+{
+ BdrvChild *child;
+
+ if (!parent_bs->drv || !parent_bs->drv->bdrv_del_child) {
+ error_setg(errp, "The BDS %s doesn't support removing a child",
+ bdrv_get_device_or_node_name(parent_bs));
+ return;
+ }
+
+ QLIST_FOREACH(child, &parent_bs->children, next) {
+ if (child->bs == child_bs) {
+ break;
+ }
+ }
+
+ if (!child) {
+ error_setg(errp, "The BDS %s is not the BDS %s's child",
+ bdrv_get_device_or_node_name(child_bs),
+ bdrv_get_device_or_node_name(parent_bs));
+ return;
+ }
+
+ parent_bs->drv->bdrv_del_child(parent_bs, child_bs, errp);
+}
diff --git a/include/block/block.h b/include/block/block.h
index ef67353..665c56f 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -616,4 +616,9 @@ void bdrv_flush_io_queue(BlockDriverState *bs);
BlockAcctStats *bdrv_get_stats(BlockDriverState *bs);
+void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child,
+ Error **errp);
+void bdrv_del_child(BlockDriverState *parent, BlockDriverState *child,
+ Error **errp);
+
#endif
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 2f2c47b..64cbc55 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 *parent, BlockDriverState *child,
+ Error **errp);
+ void (*bdrv_del_child)(BlockDriverState *parent, BlockDriverState *child,
+ Error **errp);
+
QLIST_ENTRY(BlockDriver) list;
};
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v4 1/4] Add new block driver interface to add/delete a BDS's child
2015-09-18 10:13 ` [Qemu-devel] [PATCH v4 1/4] Add new block driver interface to add/delete a BDS's child Wen Congyang
@ 2015-09-18 14:52 ` Eric Blake
0 siblings, 0 replies; 8+ messages in thread
From: Eric Blake @ 2015-09-18 14:52 UTC (permalink / raw)
To: Wen Congyang, qemu devel, Markus Armbruster, Alberto Garcia,
Stefan Hajnoczi
Cc: Kevin Wolf, zhanghailiang, qemu block, Jiang Yunhong, Dong Eddie,
Dr. David Alan Gilbert, Gonglei, Yang Hongyang
[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]
On 09/18/2015 04:13 AM, Wen Congyang wrote:
> In some cases, we want to take a quorum child offline, and take
> another child online.
>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> block.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
> include/block/block.h | 5 +++++
> include/block/block_int.h | 5 +++++
> 3 files changed, 60 insertions(+)
>
> +void bdrv_del_child(BlockDriverState *parent_bs, BlockDriverState *child_bs,
> + Error **errp)
> +{
> + BdrvChild *child;
> + if (!child) {
> + error_setg(errp, "The BDS %s is not the BDS %s's child",
> + bdrv_get_device_or_node_name(child_bs),
> + bdrv_get_device_or_node_name(parent_bs));
Better would be:
"BDS %s is not a child of %s"
With that,
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v4 2/4] quorum: implement bdrv_add_child() and bdrv_del_child()
2015-09-18 10:13 [Qemu-devel] [PATCH v4 0/4] qapi: child add/delete support Wen Congyang
2015-09-18 10:13 ` [Qemu-devel] [PATCH v4 1/4] Add new block driver interface to add/delete a BDS's child Wen Congyang
@ 2015-09-18 10:13 ` Wen Congyang
2015-09-18 10:13 ` [Qemu-devel] [PATCH v4 3/4] qmp: add monitor command to add/remove a child Wen Congyang
2015-09-18 10:13 ` [Qemu-devel] [PATCH v4 4/4] hmp: " Wen Congyang
3 siblings, 0 replies; 8+ messages in thread
From: Wen Congyang @ 2015-09-18 10:13 UTC (permalink / raw)
To: qemu devel, Eric Blake, Markus Armbruster, Alberto Garcia,
Stefan Hajnoczi
Cc: Kevin Wolf, qemu block, Jiang Yunhong, Dong Eddie,
Dr. David Alan Gilbert, Gonglei, Yang Hongyang, zhanghailiang
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
block.c | 6 ++---
block/quorum.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++--
include/block/block.h | 3 +++
3 files changed, 76 insertions(+), 5 deletions(-)
diff --git a/block.c b/block.c
index bb7657b..4dc0e29 100644
--- a/block.c
+++ b/block.c
@@ -1079,9 +1079,9 @@ static int bdrv_fill_options(QDict **options, const char **pfilename,
return 0;
}
-static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
- BlockDriverState *child_bs,
- const BdrvChildRole *child_role)
+BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
+ BlockDriverState *child_bs,
+ const BdrvChildRole *child_role)
{
BdrvChild *child = g_new(BdrvChild, 1);
*child = (BdrvChild) {
diff --git a/block/quorum.c b/block/quorum.c
index 8fe53b4..111a57b 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -66,6 +66,9 @@ typedef struct QuorumVotes {
typedef struct BDRVQuorumState {
BlockDriverState **bs; /* children BlockDriverStates */
int num_children; /* children count */
+ int max_children; /* The maximum children count, we need to reallocate
+ * bs if num_children grows larger than maximum.
+ */
int threshold; /* if less than threshold children reads gave the
* same result a quorum error occurs.
*/
@@ -874,9 +877,9 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
ret = -EINVAL;
goto exit;
}
- if (s->num_children < 2) {
+ if (s->num_children < 1) {
error_setg(&local_err,
- "Number of provided children must be greater than 1");
+ "Number of provided children must be 1 or more");
ret = -EINVAL;
goto exit;
}
@@ -925,6 +928,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
/* allocate the children BlockDriverState array */
s->bs = g_new0(BlockDriverState *, s->num_children);
opened = g_new0(bool, s->num_children);
+ s->max_children = s->num_children;
for (i = 0; i < s->num_children; i++) {
char indexstr[32];
@@ -995,6 +999,67 @@ static void quorum_attach_aio_context(BlockDriverState *bs,
}
}
+static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs,
+ Error **errp)
+{
+ BDRVQuorumState *s = bs->opaque;
+
+ bdrv_drain(bs);
+
+ if (s->num_children == s->max_children) {
+ if (s->max_children >= INT_MAX) {
+ error_setg(errp, "Too many children");
+ return;
+ }
+
+ s->bs = g_renew(BlockDriverState *, s->bs, s->max_children + 1);
+ s->bs[s->num_children] = NULL;
+ s->max_children++;
+ }
+
+ bdrv_ref(child_bs);
+ bdrv_attach_child(bs, child_bs, &child_format);
+ s->bs[s->num_children++] = child_bs;
+}
+
+static void quorum_del_child(BlockDriverState *bs, BlockDriverState *child_bs,
+ Error **errp)
+{
+ BDRVQuorumState *s = bs->opaque;
+ BdrvChild *child;
+ int i;
+
+ for (i = 0; i < s->num_children; i++) {
+ if (s->bs[i] == child_bs) {
+ break;
+ }
+ }
+
+ QLIST_FOREACH(child, &bs->children, next) {
+ if (child->bs == child_bs) {
+ break;
+ }
+ }
+
+ /* we have checked it in bdrv_del_child() */
+ assert(i < s->num_children && child);
+
+ if (s->num_children <= s->threshold) {
+ error_setg(errp,
+ "The number of children cannot be lower than the vote threshold %d",
+ s->threshold);
+ return;
+ }
+
+ bdrv_drain(bs);
+ /* We can safely remove this child now */
+ memmove(&s->bs[i], &s->bs[i + 1],
+ (s->num_children - i - 1) * sizeof(void *));
+ s->num_children--;
+ s->bs[s->num_children] = NULL;
+ bdrv_unref_child(bs, child);
+}
+
static void quorum_refresh_filename(BlockDriverState *bs)
{
BDRVQuorumState *s = bs->opaque;
@@ -1049,6 +1114,9 @@ static BlockDriver bdrv_quorum = {
.bdrv_detach_aio_context = quorum_detach_aio_context,
.bdrv_attach_aio_context = quorum_attach_aio_context,
+ .bdrv_add_child = quorum_add_child,
+ .bdrv_del_child = quorum_del_child,
+
.is_filter = true,
.bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter,
};
diff --git a/include/block/block.h b/include/block/block.h
index 665c56f..bd97399 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -514,6 +514,9 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs);
void bdrv_ref(BlockDriverState *bs);
void bdrv_unref(BlockDriverState *bs);
void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child);
+BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
+ BlockDriverState *child_bs,
+ const BdrvChildRole *child_role);
bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp);
void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason);
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v4 3/4] qmp: add monitor command to add/remove a child
2015-09-18 10:13 [Qemu-devel] [PATCH v4 0/4] qapi: child add/delete support Wen Congyang
2015-09-18 10:13 ` [Qemu-devel] [PATCH v4 1/4] Add new block driver interface to add/delete a BDS's child Wen Congyang
2015-09-18 10:13 ` [Qemu-devel] [PATCH v4 2/4] quorum: implement bdrv_add_child() and bdrv_del_child() Wen Congyang
@ 2015-09-18 10:13 ` Wen Congyang
2015-09-18 14:58 ` Eric Blake
2015-09-18 10:13 ` [Qemu-devel] [PATCH v4 4/4] hmp: " Wen Congyang
3 siblings, 1 reply; 8+ messages in thread
From: Wen Congyang @ 2015-09-18 10:13 UTC (permalink / raw)
To: qemu devel, Eric Blake, Markus Armbruster, Alberto Garcia,
Stefan Hajnoczi
Cc: Kevin Wolf, qemu block, Jiang Yunhong, Dong Eddie,
Dr. David Alan Gilbert, Gonglei, Yang Hongyang, zhanghailiang
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
blockdev.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++
qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++
qmp-commands.hx | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 136 insertions(+)
diff --git a/blockdev.c b/blockdev.c
index 32b04b4..8da0ffb 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3086,6 +3086,54 @@ fail:
qmp_output_visitor_cleanup(ov);
}
+void qmp_x_blockdev_child_add(const char *parent, const char *child,
+ Error **errp)
+{
+ BlockDriverState *parent_bs, *child_bs;
+ Error *local_err = NULL;
+
+ parent_bs = bdrv_lookup_bs(parent, parent, &local_err);
+ if (!parent_bs) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
+ child_bs = bdrv_find_node(child);
+ if (!child_bs) {
+ error_setg(errp, "Node '%s' not found", child);
+ return;
+ }
+
+ bdrv_add_child(parent_bs, child_bs, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ }
+}
+
+void qmp_x_blockdev_child_del(const char *parent, const char *child,
+ Error **errp)
+{
+ BlockDriverState *parent_bs, *child_bs;
+ Error *local_err = NULL;
+
+ parent_bs = bdrv_lookup_bs(parent, parent, &local_err);
+ if (!parent_bs) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
+ child_bs = bdrv_find_node(child);
+ if (!child_bs) {
+ error_setg(errp, "Node '%s' not found", child);
+ return;
+ }
+
+ bdrv_del_child(parent_bs, child_bs, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ }
+}
+
BlockJobInfoList *qmp_query_block_jobs(Error **errp)
{
BlockJobInfoList *head = NULL, **p_next = &head;
diff --git a/qapi/block-core.json b/qapi/block-core.json
index bb2189e..9418f05 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2114,3 +2114,37 @@
##
{ 'command': 'block-set-write-threshold',
'data': { 'node-name': 'str', 'write-threshold': 'uint64' } }
+
+##
+# @x-blockdev-child-add
+#
+# Add a new child to the parent BDS. Currently only the Quorum driver
+# implements this feature. This is useful to fix a broken quorum child.
+#
+# @parent: graph node name or id which the child will be added to.
+#
+# @child: graph node name that will be added.
+#
+# Note: this command is experimental, and not a stable API.
+#
+# Since: 2.5
+##
+{ 'command': 'x-blockdev-child-add',
+ 'data' : { 'parent': 'str', 'child': 'str' } }
+
+##
+# @x-blockdev-child-del
+#
+# Remove a child from the parent BDS. Currently only the Quorum driver
+# implements this feature. This is useful to fix a broken quorum child.
+# Note, you can't remove a child if it would bring the quorum below its
+# threshold.
+#
+# @parent: graph node name or id from which the child will removed.
+#
+# @child: graph node name that will be removed.
+#
+# Since: 2.5
+##
+{ 'command': 'x-blockdev-child-del',
+ 'data' : { 'parent': 'str', 'child': 'str' } }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 9848fd8..11a007d 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3897,6 +3897,60 @@ Example (2):
EQMP
{
+ .name = "x-blockdev-child-add",
+ .args_type = "parent:B,child:B",
+ .mhandler.cmd_new = qmp_marshal_input_x_blockdev_child_add,
+ },
+
+SQMP
+x-blockdev-child-add
+------------
+
+Add a child to a quorum node.
+
+Arguments:
+
+- "parent": the quorum's id or node name
+- "child": the child node-name which will be added
+
+Note: this command is experimental, and not a stable API. It doesn't
+support all kinds of child, and not support all block drivers.
+
+Example:
+
+-> { "execute": "x-blockdev-child-add",
+ "arguments": { "parent": "disk1", "child": "new_node" } }
+<- { "return": {} }
+
+EQMP
+
+ {
+ .name = "x-blockdev-child-del",
+ .args_type = "parent:B,child:B",
+ .mhandler.cmd_new = qmp_marshal_input_x_blockdev_child_del,
+ },
+
+SQMP
+x-blockdev-child-del
+------------
+
+Delete a child from a quorum node. It can be used to remove a broken
+quorum child.
+
+Arguments:
+
+- "parent": the quorum's id or node name
+- "child": the child node-name which will be removed
+
+Example:
+
+-> { "execute": "x-blockdev-child-del",
+ "arguments": { "parent": "disk1", "child": "new_node" } }
+<- { "return": {} }
+
+EQMP
+
+ {
.name = "query-named-block-nodes",
.args_type = "",
.mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes,
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v4 3/4] qmp: add monitor command to add/remove a child
2015-09-18 10:13 ` [Qemu-devel] [PATCH v4 3/4] qmp: add monitor command to add/remove a child Wen Congyang
@ 2015-09-18 14:58 ` Eric Blake
0 siblings, 0 replies; 8+ messages in thread
From: Eric Blake @ 2015-09-18 14:58 UTC (permalink / raw)
To: Wen Congyang, qemu devel, Markus Armbruster, Alberto Garcia,
Stefan Hajnoczi
Cc: Kevin Wolf, zhanghailiang, qemu block, Jiang Yunhong, Dong Eddie,
Dr. David Alan Gilbert, Gonglei, Yang Hongyang
[-- Attachment #1: Type: text/plain, Size: 1616 bytes --]
On 09/18/2015 04:13 AM, Wen Congyang wrote:
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Commit message should probably mention the name of the new commands.
Also, if you still want the command to be experimental, it would be nice
to explain in the commit message why you have chosen that, and what
might change in the future to make us either commit to the interface or
replace it with a better one.
> ---
> blockdev.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++
> qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++
> qmp-commands.hx | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 136 insertions(+)
> +SQMP
> +x-blockdev-child-add
> +------------
> +
> +Add a child to a quorum node.
> +
> +Arguments:
> +
> +- "parent": the quorum's id or node name
> +- "child": the child node-name which will be added
> +
> +Note: this command is experimental, and not a stable API. It doesn't
> +support all kinds of child, and not support all block drivers.
s/of child/of children/
s/and not support/nor/
> +
> +Example:
> +
> +-> { "execute": "x-blockdev-child-add",
> + "arguments": { "parent": "disk1", "child": "new_node" } }
> +<- { "return": {} }
Might be nice to extend the example to show the blockdev-add that
created "new_node" before this command plugs it in.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v4 4/4] hmp: add monitor command to add/remove a child
2015-09-18 10:13 [Qemu-devel] [PATCH v4 0/4] qapi: child add/delete support Wen Congyang
` (2 preceding siblings ...)
2015-09-18 10:13 ` [Qemu-devel] [PATCH v4 3/4] qmp: add monitor command to add/remove a child Wen Congyang
@ 2015-09-18 10:13 ` Wen Congyang
2015-09-18 15:00 ` Eric Blake
3 siblings, 1 reply; 8+ messages in thread
From: Wen Congyang @ 2015-09-18 10:13 UTC (permalink / raw)
To: qemu devel, Eric Blake, Markus Armbruster, Alberto Garcia,
Stefan Hajnoczi
Cc: Kevin Wolf, qemu block, Jiang Yunhong, Dong Eddie,
Dr. David Alan Gilbert, Luiz Capitulino, Gonglei, Yang Hongyang,
zhanghailiang
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
---
hmp-commands.hx | 28 ++++++++++++++++++++++++++++
hmp.c | 20 ++++++++++++++++++++
hmp.h | 2 ++
3 files changed, 50 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index a511004..6c5fe82 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -193,6 +193,34 @@ actions (drive options rerror, werror).
ETEXI
{
+ .name = "blockdev_child_add",
+ .args_type = "id:B,child:B",
+ .params = "parent child",
+ .help = "add a child to a BDS",
+ .mhandler.cmd = hmp_blockdev_child_add,
+ },
+
+STEXI
+@item blockdev_child_add @var{parent device} @var{child device}
+@findex blockdev_child_add
+Add a child to the block device.
+ETEXI
+
+ {
+ .name = "blockdev_child_del",
+ .args_type = "id:B,child:B",
+ .params = "parent child",
+ .help = "remove a child from a BDS",
+ .mhandler.cmd = hmp_blockdev_child_del,
+ },
+
+STEXI
+@item blockdev_child_del @var{parent device} @var{child device}
+@findex blockdev_child_del
+Remove a child from the parent device.
+ETEXI
+
+ {
.name = "change",
.args_type = "device:B,target:F,arg:s?",
.params = "device filename [format]",
diff --git a/hmp.c b/hmp.c
index 3f807b7..1dc1bed 100644
--- a/hmp.c
+++ b/hmp.c
@@ -2325,3 +2325,23 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)
qapi_free_RockerOfDpaGroupList(list);
}
+
+void hmp_blockdev_child_add(Monitor *mon, const QDict *qdict)
+{
+ const char *id = qdict_get_str(qdict, "id");
+ const char *child_id = qdict_get_str(qdict, "child");
+ Error *local_err = NULL;
+
+ qmp_x_blockdev_child_add(id, child_id, &local_err);
+ hmp_handle_error(mon, &local_err);
+}
+
+void hmp_blockdev_child_del(Monitor *mon, const QDict *qdict)
+{
+ const char *id = qdict_get_str(qdict, "id");
+ const char *child_id = qdict_get_str(qdict, "child");
+ Error *local_err = NULL;
+
+ qmp_x_blockdev_child_del(id, child_id, &local_err);
+ hmp_handle_error(mon, &local_err);
+}
diff --git a/hmp.h b/hmp.h
index 81656c3..3033648 100644
--- a/hmp.h
+++ b/hmp.h
@@ -130,5 +130,7 @@ void hmp_rocker(Monitor *mon, const QDict *qdict);
void hmp_rocker_ports(Monitor *mon, const QDict *qdict);
void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict);
void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict);
+void hmp_blockdev_child_add(Monitor *mon, const QDict *qdict);
+void hmp_blockdev_child_del(Monitor *mon, const QDict *qdict);
#endif
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v4 4/4] hmp: add monitor command to add/remove a child
2015-09-18 10:13 ` [Qemu-devel] [PATCH v4 4/4] hmp: " Wen Congyang
@ 2015-09-18 15:00 ` Eric Blake
0 siblings, 0 replies; 8+ messages in thread
From: Eric Blake @ 2015-09-18 15:00 UTC (permalink / raw)
To: Wen Congyang, qemu devel, Markus Armbruster, Alberto Garcia,
Stefan Hajnoczi
Cc: Kevin Wolf, zhanghailiang, qemu block, Jiang Yunhong, Dong Eddie,
Dr. David Alan Gilbert, Luiz Capitulino, Gonglei, Yang Hongyang
[-- Attachment #1: Type: text/plain, Size: 944 bytes --]
On 09/18/2015 04:13 AM, Wen Congyang wrote:
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> Cc: Luiz Capitulino <lcapitulino@redhat.com>
> ---
> hmp-commands.hx | 28 ++++++++++++++++++++++++++++
> hmp.c | 20 ++++++++++++++++++++
> hmp.h | 2 ++
> 3 files changed, 50 insertions(+)
>
> +
> +STEXI
> +@item blockdev_child_add @var{parent device} @var{child device}
This produces poor-looking info that makes it appear that the command
takes 4 parameters, with two of those parameters both named 'device'.
I'd use just:
@item blockdev_child_add @var{parent} @var{child}
> +STEXI
> +@item blockdev_child_del @var{parent device} @var{child device}
Likewise.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread