From 46eade7be83c110659ea9a6883fbd898d455ec06 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 11 Jul 2017 13:27:38 +0200 Subject: block/qapi: Add qdev device name to query-block With -blockdev/-device, users can indirectly create anonymous BlockBackends, while the state of such backends is still of interest. As a preparation for making such BBs visible in query-block, make sure that they can be identified even without a name by adding the ID/QOM path of their qdev device to BlockInfo. Signed-off-by: Kevin Wolf Reviewed-by: John Snow --- hmp.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'hmp.c') diff --git a/hmp.c b/hmp.c index b42ae59a29..0e57f47682 100644 --- a/hmp.c +++ b/hmp.c @@ -425,6 +425,9 @@ static void print_block_info(Monitor *mon, BlockInfo *info, } if (info) { + if (info->has_qdev) { + monitor_printf(mon, " Attached to: %s\n", info->qdev); + } if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) { monitor_printf(mon, " I/O status: %s\n", BlockDeviceIoStatus_lookup[info->io_status]); -- cgit v1.2.3-55-g7522 From ec18b0a93a0b8f6f9a72bf2461dc7a0930391bfa Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 11 Jul 2017 14:00:57 +0200 Subject: block: List anonymous device BBs in query-block 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 Reviewed-by: Eric Blake Reviewed-by: John Snow --- block/qapi.c | 2 +- hmp.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'hmp.c') diff --git a/block/qapi.c b/block/qapi.c index 164dd2b9a9..95b2e2daa5 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -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 0e57f47682..bf1de747d5 100644 --- 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 : ""); } -- cgit v1.2.3-55-g7522