]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
block: List anonymous device BBs in query-block
authorKevin Wolf <kwolf@redhat.com>
Tue, 11 Jul 2017 12:00:57 +0000 (14:00 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 18 Jul 2017 13:14:36 +0000 (15:14 +0200)
Instead of listing only monitor-owned BlockBackends in query-block, also
add those anonymous BlockBackends that are owned by a qdev device and as
such under the control of the user.

This allows using query-block to inspect BlockBackends for the modern
configuration syntax with -blockdev and -device.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
block/qapi.c
hmp.c

index 164dd2b9a9b1f035d5fcf1b0773b54a3987d0134..95b2e2daa5dd10f9e416e829e7b9df2a67f2de74 100644 (file)
@@ -475,7 +475,7 @@ BlockInfoList *qmp_query_block(Error **errp)
     for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
         BlockInfoList *info;
 
-        if (!*blk_name(blk)) {
+        if (!*blk_name(blk) && !blk_get_attached_dev(blk)) {
             continue;
         }
 
diff --git a/hmp.c b/hmp.c
index 0e57f476823f2a25a632f4060bfb95d30736429a..bf1de747d5413cb30e5643fbc182aefb2838509a 100644 (file)
--- a/hmp.c
+++ b/hmp.c
@@ -401,16 +401,16 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
 
     assert(!info || !info->has_inserted || info->inserted == inserted);
 
-    if (info) {
+    if (info && *info->device) {
         monitor_printf(mon, "%s", info->device);
         if (inserted && inserted->has_node_name) {
             monitor_printf(mon, " (%s)", inserted->node_name);
         }
     } else {
-        assert(inserted);
+        assert(info || inserted);
         monitor_printf(mon, "%s",
-                       inserted->has_node_name
-                       ? inserted->node_name
+                       inserted && inserted->has_node_name ? inserted->node_name
+                       : info && info->has_qdev ? info->qdev
                        : "<anonymous>");
     }