[Qemu-devel] [PATCH 4/9] block/qapi: Use blk_all_next() for query-block

Kevin Wolf posted 9 patches 8 years, 6 months ago
There is a newer version of this series
[Qemu-devel] [PATCH 4/9] block/qapi: Use blk_all_next() for query-block
Posted by Kevin Wolf 8 years, 6 months ago
This patch replaces the blk_next() loop in query-block by a
blk_all_next() one so that we also get access to BlockBackends that
aren't owned by the monitor. For now, the next thing we do is check
whether each BB has a name, so there is no semantical difference.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qapi.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/block/qapi.c b/block/qapi.c
index 705cd11..2f86c79 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -472,8 +472,14 @@ BlockInfoList *qmp_query_block(Error **errp)
     BlockBackend *blk;
     Error *local_err = NULL;
 
-    for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
-        BlockInfoList *info = g_malloc0(sizeof(*info));
+    for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
+        BlockInfoList *info;
+
+        if (!*blk_name(blk)) {
+            continue;
+        }
+
+        info = g_malloc0(sizeof(*info));
         bdrv_query_info(blk, &info->value, &local_err);
         if (local_err) {
             error_propagate(errp, local_err);
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH 4/9] block/qapi: Use blk_all_next() for query-block
Posted by Eric Blake 8 years, 6 months ago
On 07/12/2017 07:57 AM, Kevin Wolf wrote:
> This patch replaces the blk_next() loop in query-block by a
> blk_all_next() one so that we also get access to BlockBackends that
> aren't owned by the monitor. For now, the next thing we do is check
> whether each BB has a name, so there is no semantical difference.

s/semantical/semantic/

> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/qapi.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org