From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUaMv-0001aJ-HC for qemu-devel@nongnu.org; Thu, 18 Sep 2014 07:59:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUaMp-0000Bg-CF for qemu-devel@nongnu.org; Thu, 18 Sep 2014 07:59:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUaMp-0000BM-4c for qemu-devel@nongnu.org; Thu, 18 Sep 2014 07:59:19 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8IBxCKf026419 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 18 Sep 2014 07:59:12 -0400 From: Markus Armbruster References: <1410881796-18452-1-git-send-email-kwolf@redhat.com> <1410881796-18452-4-git-send-email-kwolf@redhat.com> Date: Thu, 18 Sep 2014 13:59:09 +0200 In-Reply-To: <1410881796-18452-4-git-send-email-kwolf@redhat.com> (Kevin Wolf's message of "Tue, 16 Sep 2014 17:36:33 +0200") Message-ID: <87d2atta0i.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 3/6] block: Introduce query-block-node List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, stefanha@redhat.com Kevin Wolf writes: > This new command is a renamed version of query-named-block-nodes > with an additional argument that allows querying only one specific > BlockDriverState instead of getting a list for all of them. > > Signed-off-by: Kevin Wolf > --- > block.c | 15 +++++++++++++-- > blockdev.c | 8 +++++++- > include/block/block.h | 2 +- > qapi/block-core.json | 19 ++++++++++++++++--- > 4 files changed, 37 insertions(+), 7 deletions(-) > > diff --git a/block.c b/block.c > index bcd952a..6c538d3 100644 > --- a/block.c > +++ b/block.c > @@ -3823,13 +3823,24 @@ BlockDriverState *bdrv_find_node(const char *node_name) > } > > /* Put this QMP function here so it can access the static graph_bdrv_states. */ > -BlockDeviceInfoList *bdrv_named_nodes_list(void) > +BlockDeviceInfoList *bdrv_named_nodes_list(const char *device, Error **errp) > { > BlockDeviceInfoList *list, *entry; > BlockDriverState *bs; > + Error *local_err = NULL; > + > + if (device) { > + bs = bdrv_lookup_bs(device, device, &local_err); > + if (local_err) { > + error_propagate(errp, local_err); > + return NULL; > + } > + } else { > + bs = QTAILQ_FIRST(&graph_bdrv_states); > + } > > list = NULL; > - QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) { > + for (; bs; bs = device ? NULL : QTAILQ_NEXT(bs, node_list)) { > entry = g_malloc0(sizeof(*entry)); > entry->value = bdrv_block_device_info(bs); > entry->next = list; Same loop as in PATCH 2/6, same suggestion to simplify it. > diff --git a/blockdev.c b/blockdev.c > index b361fbb..a194d04 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -2127,9 +2127,15 @@ void qmp_drive_backup(const char *device, const char *target, > } > } > > +BlockDeviceInfoList *qmp_query_block_node(bool has_device, const char *device, > + Error **errp) > +{ > + return bdrv_named_nodes_list(has_device ? device : NULL, errp); > +} > + > BlockDeviceInfoList *qmp_query_named_block_nodes(Error **errp) > { > - return bdrv_named_nodes_list(); > + return qmp_query_block_node(false, NULL, errp); > } > > #define DEFAULT_MIRROR_BUF_SIZE (10 << 20) > diff --git a/include/block/block.h b/include/block/block.h > index 07d6d8e..0caab0d 100644 > --- a/include/block/block.h > +++ b/include/block/block.h > @@ -403,7 +403,7 @@ void bdrv_eject(BlockDriverState *bs, bool eject_flag); > const char *bdrv_get_format_name(BlockDriverState *bs); > BlockDriverState *bdrv_find(const char *name); > BlockDriverState *bdrv_find_node(const char *node_name); > -BlockDeviceInfoList *bdrv_named_nodes_list(void); > +BlockDeviceInfoList *bdrv_named_nodes_list(const char *device, Error **errp); > BlockDriverState *bdrv_lookup_bs(const char *device, > const char *node_name, > Error **errp); > diff --git a/qapi/block-core.json b/qapi/block-core.json > index ddc3fe0..f170c7e 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -797,13 +797,26 @@ > ## > # @query-named-block-nodes > # > -# Get the named block driver list > +# Deprecated, may be removed in future versions. Use query-block-node instead. > +# > +# Since 2.0, until 2.1 Suggest ## # @query-named-block-nodes # # Get the named block driver list # # Since 2.0 +# Deprecated since 2.1, use query-block-node instead and a general understanding that "deprecated" implies "should not be used anymore" and "may be removed in a future release". > +## > +{ 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] } > + > +## > +# @query-block-node > +# > +# Gets information about one or all block device nodes. > +# > +# @device: #optional The id or node-name of the block device to inspect. > # > # Returns: the list of BlockDeviceInfo > # > -# Since 2.0 > +# Since 2.2 > ## > -{ 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] } > +{ 'command': 'query-block-node', > + 'data': { '*device': 'str' }, > + 'returns': [ 'BlockDeviceInfo' ] } > > ## > # @drive-mirror