From: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
To: qemu devel <qemu-devel@nongnu.org>,
Eric Blake <eblake@redhat.com>, Alberto Garcia <berto@igalia.com>,
Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Cc: zhanghailiang <zhang.zhanghailiang@huawei.com>,
qemu block <qemu-block@nongnu.org>,
Jiang Yunhong <yunhong.jiang@intel.com>,
Dong Eddie <eddie.dong@intel.com>,
Markus Armbruster <armbru@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Gonglei <arei.gonglei@huawei.com>
Subject: Re: [Qemu-devel] [PATCH v12 3/3] qmp: add monitor command to add/remove a child
Date: Mon, 28 Mar 2016 14:09:30 +0800 [thread overview]
Message-ID: <56F8CA9A.7080008@cn.fujitsu.com> (raw)
In-Reply-To: <1457578181-27111-4-git-send-email-xiecl.fnst@cn.fujitsu.com>
On 03/10/2016 10:49 AM, Changlong Xie wrote:
> From: Wen Congyang <wency@cn.fujitsu.com>
>
> The new QMP command name is x-blockdev-change. It's just for adding/removing
> quorum's child now, and doesn't support all kinds of children, all kinds of
> operations, nor all block drivers. So it is experimental now.
>
> 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>
> Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
> Reviewed-by: Max Reitz <mreitz@redhat.com>
> ---
> blockdev.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> qapi/block-core.json | 32 ++++++++++++++++++++++++++++++
> qmp-commands.hx | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 141 insertions(+)
>
> diff --git a/blockdev.c b/blockdev.c
> index 0f20c65..435631e 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -4017,6 +4017,61 @@ out:
> aio_context_release(aio_context);
> }
>
> +static BdrvChild *bdrv_find_child(BlockDriverState *parent_bs,
> + const char *child_name)
> +{
> + BdrvChild *child;
> +
> + QLIST_FOREACH(child, &parent_bs->children, next) {
> + if (strcmp(child->name, child_name) == 0) {
> + return child;
> + }
> + }
> +
> + return NULL;
> +}
> +
> +void qmp_x_blockdev_change(const char *parent, bool has_child,
> + const char *child, bool has_node,
> + const char *node, Error **errp)
> +{
> + BlockDriverState *parent_bs, *new_bs = NULL;
> + BdrvChild *p_child;
> +
> + parent_bs = bdrv_lookup_bs(parent, parent, errp);
> + if (!parent_bs) {
> + return;
> + }
> +
> + if (has_child == has_node) {
> + if (has_child) {
> + error_setg(errp, "The parameters child and node are in conflict");
> + } else {
> + error_setg(errp, "Either child or node must be specified");
> + }
> + return;
> + }
> +
> + if (has_child) {
> + p_child = bdrv_find_child(parent_bs, child);
> + if (!p_child) {
> + error_setg(errp, "Node '%s' does not have child '%s'",
> + parent, child);
> + return;
> + }
> + bdrv_del_child(parent_bs, p_child, errp);
> + }
> +
> + if (has_node) {
> + new_bs = bdrv_find_node(node);
> + if (!new_bs) {
> + error_setg(errp, "Node '%s' not found", node);
> + return;
> + }
> + bdrv_add_child(parent_bs, new_bs, errp);
> + }
> +}
> +
> 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 9bf1b22..bc3fd0b 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -2548,3 +2548,35 @@
> ##
> { 'command': 'block-set-write-threshold',
> 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } }
> +
> +##
> +# @x-blockdev-change
> +#
> +# Dynamically reconfigure the block driver state graph. It can be used
> +# to add, remove, insert or replace a graph node. Currently only the
> +# Quorum driver implements this feature to add or remove its child. This
> +# is useful to fix a broken quorum child.
> +#
> +# If @node is specified, it will be inserted under @parent. @child
> +# may not be specified in this case. If both @parent and @child are
> +# specified but @node is not, @child will be detached from @parent.
> +#
> +# @parent: the id or name of the parent node.
> +#
> +# @child: #optional the name of a child under the given parent node.
> +#
> +# @node: #optional the name of the node that will be added.
> +#
> +# Note: this command is experimental, and its API is not stable. It
> +# does not support all kinds of operations, all kinds of children, nor
> +# all block drivers.
> +#
> +# Warning: The data in a new quorum child MUST be consistent with that of
> +# the rest of the array.
> +#
> +# Since: 2.6
> +##
> +{ 'command': 'x-blockdev-change',
> + 'data' : { 'parent': 'str',
> + '*child': 'str',
> + '*node': 'str' } }
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index b629673..2a55135 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -4398,6 +4398,60 @@ Example:
> EQMP
>
> {
> + .name = "x-blockdev-change",
> + .args_type = "parent:B,child:B?,node:B?",
> + .mhandler.cmd_new = qmp_marshal_x_blockdev_change,
> + },
> +
> +SQMP
> +x-blockdev-change
> +-----------------
> +
> +Dynamically reconfigure the block driver state graph. It can be used
> +to add, remove, insert or replace a graph node. Currently only the
> +Quorum driver implements this feature to add or remove its child. This
> +is useful to fix a broken quorum child.
> +
> +If @node is specified, it will be inserted under @parent. @child
> +may not be specified in this case. If both @parent and @child are
> +specified but @node is not, @child will be detached from @parent.
> +
> +Arguments:
> +- "parent": the id or name of the parent node (json-string)
> +- "child": the name of a child under the given parent node (json-string, optional)
> +- "node": the name of the node that will be added (json-string, optional)
> +
> +Note: this command is experimental, and not a stable API. It doesn't
> +support all kinds of operations, all kinds of children, nor all block
> +drivers.
> +
> +Warning: The data in a new quorum child MUST be consistent with that of
> +the rest of the array.
> +
> +Example:
> +
> +Add a new node to a quorum
> +-> { "execute": "blockdev-add",
> + "arguments": { "options": { "driver": "raw",
> + "node-name": "new_node",
> + "id": "test_new_node",
Since f21d96d04 block: Use BdrvChild in BlockBackend, if we want to
create a node without BB, we should not pass " "id": "test_new_node" ",
will fix in next version.
Thanks
-Xie
> + "file": { "driver": "file",
> + "filename": "test.raw" } } } }
> +<- { "return": {} }
> +-> { "execute": "x-blockdev-change",
> + "arguments": { "parent": "disk1",
> + "node": "new_node" } }
> +<- { "return": {} }
> +
> +Delete a quorum's node
> +-> { "execute": "x-blockdev-change",
> + "arguments": { "parent": "disk1",
> + "child": "children.1" } }
> +<- { "return": {} }
> +
> +EQMP
> +
> + {
> .name = "query-named-block-nodes",
> .args_type = "",
> .mhandler.cmd_new = qmp_marshal_query_named_block_nodes,
>
prev parent reply other threads:[~2016-03-28 6:07 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-10 2:49 [Qemu-devel] [PATCH v12 0/3] qapi: child add/delete support Changlong Xie
2016-03-10 2:49 ` [Qemu-devel] [PATCH v12 1/3] Add new block driver interface to add/delete a BDS's child Changlong Xie
2016-03-10 14:57 ` Alberto Garcia
2016-03-11 1:17 ` Changlong Xie
2016-03-10 2:49 ` [Qemu-devel] [PATCH v12 2/3] quorum: implement bdrv_add_child() and bdrv_del_child() Changlong Xie
2016-03-11 12:21 ` Alberto Garcia
2016-03-14 1:33 ` Changlong Xie
2016-03-14 6:02 ` Changlong Xie
2016-03-16 12:38 ` Alberto Garcia
2016-03-17 1:22 ` Wen Congyang
2016-03-17 9:10 ` Alberto Garcia
2016-03-17 9:44 ` Wen Congyang
2016-03-17 9:48 ` Dr. David Alan Gilbert
2016-03-17 9:56 ` Wen Congyang
2016-03-17 9:59 ` Dr. David Alan Gilbert
2016-03-17 10:07 ` Alberto Garcia
2016-03-17 10:23 ` Wen Congyang
2016-03-17 11:25 ` Dr. David Alan Gilbert
2016-03-18 2:56 ` Wen Congyang
2016-03-18 10:48 ` Dr. David Alan Gilbert
2016-03-29 15:38 ` Max Reitz
2016-03-29 15:44 ` Eric Blake
2016-03-29 15:50 ` Dr. David Alan Gilbert
2016-03-29 15:52 ` Max Reitz
2016-03-29 15:54 ` Dr. David Alan Gilbert
2016-03-29 15:59 ` Max Reitz
2016-03-29 16:03 ` Dr. David Alan Gilbert
2016-03-29 16:09 ` Max Reitz
2016-03-29 17:33 ` Dr. David Alan Gilbert
2016-03-29 15:51 ` Max Reitz
2016-03-30 11:39 ` Alberto Garcia
2016-03-30 15:07 ` Max Reitz
2016-03-31 11:42 ` Alberto Garcia
2016-03-31 12:31 ` Dr. David Alan Gilbert
2016-04-01 15:20 ` Max Reitz
2016-04-06 7:48 ` Wen Congyang
2016-04-11 5:18 ` Changlong Xie
2016-04-12 16:21 ` Max Reitz
2016-03-16 2:10 ` Wen Congyang
2016-03-10 2:49 ` [Qemu-devel] [PATCH v12 3/3] qmp: add monitor command to add/remove a child Changlong Xie
2016-03-11 12:48 ` Alberto Garcia
2016-03-28 6:09 ` Changlong Xie [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56F8CA9A.7080008@cn.fujitsu.com \
--to=xiecl.fnst@cn.fujitsu.com \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=eddie.dong@intel.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=yunhong.jiang@intel.com \
--cc=zhang.zhanghailiang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.