diff options
Diffstat (limited to 'block/qapi.c')
-rw-r--r-- | block/qapi.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/block/qapi.c b/block/qapi.c index 080eb8f115..95b2e2daa5 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); @@ -462,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) && !blk_get_attached_dev(blk)) { + continue; + } + + info = g_malloc0(sizeof(*info)); bdrv_query_info(blk, &info->value, &local_err); if (local_err) { error_propagate(errp, local_err); |