diff options
author | Kevin Wolf | 2017-07-11 13:27:38 +0200 |
---|---|---|
committer | Kevin Wolf | 2017-07-18 15:14:35 +0200 |
commit | 46eade7be83c110659ea9a6883fbd898d455ec06 (patch) | |
tree | c5f8fc27e2eaf478743d3f1a4ee1607c1e63eb03 /block | |
parent | block: Make blk_get_attached_dev_id() public (diff) | |
download | qemu-46eade7be83c110659ea9a6883fbd898d455ec06.tar.gz qemu-46eade7be83c110659ea9a6883fbd898d455ec06.tar.xz qemu-46eade7be83c110659ea9a6883fbd898d455ec06.zip |
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 <kwolf@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/qapi.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/block/qapi.c b/block/qapi.c index 080eb8f115..c8a45ec54c 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -322,11 +322,21 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, { BlockInfo *info = g_malloc0(sizeof(*info)); BlockDriverState *bs = blk_bs(blk); + char *qdev; + info->device = g_strdup(blk_name(blk)); info->type = g_strdup("unknown"); info->locked = blk_dev_is_medium_locked(blk); info->removable = blk_dev_has_removable_media(blk); + qdev = blk_get_attached_dev_id(blk); + if (qdev && *qdev) { + info->has_qdev = true; + info->qdev = qdev; + } else { + g_free(qdev); + } + if (blk_dev_has_tray(blk)) { info->has_tray_open = true; info->tray_open = blk_dev_is_tray_open(blk); |