aboutsummaryrefslogtreecommitdiff
path: root/hmp.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2014-09-15 12:19:14 +0200
committerKevin Wolf <kwolf@redhat.com>2014-12-10 10:31:11 +0100
commite6bb31ec6f7ef7c78c897390ecc6c6a34a7f9f5a (patch)
treef9950cdb89114726f074ebffac2af142188fbc61 /hmp.c
parent8d6adccda25d75dc152b68d15ac75e1670e59b23 (diff)
downloadqemu-e6bb31ec6f7ef7c78c897390ecc6c6a34a7f9f5a.zip
qemu-e6bb31ec6f7ef7c78c897390ecc6c6a34a7f9f5a.tar.gz
qemu-e6bb31ec6f7ef7c78c897390ecc6c6a34a7f9f5a.tar.bz2
block/hmp: Allow node-name in 'info block'
The optional parameter specifying a block device allows now to use a node-name instead of a drive name (and therefore to inspect any node in the graph). The new -n options allows listing all named nodes instead of BlockBackends. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hmp.c')
-rw-r--r--hmp.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/hmp.c b/hmp.c
index 05ccf5f..481be80 100644
--- a/hmp.c
+++ b/hmp.c
@@ -403,10 +403,18 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
void hmp_info_block(Monitor *mon, const QDict *qdict)
{
BlockInfoList *block_list, *info;
+ BlockDeviceInfoList *blockdev_list, *blockdev;
const char *device = qdict_get_try_str(qdict, "device");
bool verbose = qdict_get_try_bool(qdict, "verbose", 0);
+ bool nodes = qdict_get_try_bool(qdict, "nodes", 0);
+ bool printed = false;
- block_list = qmp_query_block(false);
+ /* Print BlockBackend information */
+ if (!nodes) {
+ block_list = qmp_query_block(false);
+ } else {
+ block_list = NULL;
+ }
for (info = block_list; info; info = info->next) {
if (device && strcmp(device, info->value->device)) {
@@ -420,9 +428,30 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
print_block_info(mon, info->value, info->value->has_inserted
? info->value->inserted : NULL,
verbose);
+ printed = true;
}
qapi_free_BlockInfoList(block_list);
+
+ if ((!device && !nodes) || printed) {
+ return;
+ }
+
+ /* Print node information */
+ blockdev_list = qmp_query_named_block_nodes(NULL);
+ for (blockdev = blockdev_list; blockdev; blockdev = blockdev->next) {
+ assert(blockdev->value->has_node_name);
+ if (device && strcmp(device, blockdev->value->node_name)) {
+ continue;
+ }
+
+ if (blockdev != blockdev_list) {
+ monitor_printf(mon, "\n");
+ }
+
+ print_block_info(mon, NULL, blockdev->value, verbose);
+ }
+ qapi_free_BlockDeviceInfoList(blockdev_list);
}
void hmp_info_blockstats(Monitor *mon, const QDict *qdict)