[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/73] block/hmp: Allow node-name in 'info block'
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 16/73] block/hmp: Allow node-name in 'info block' |
Date: |
Wed, 10 Dec 2014 11:33:42 +0100 |
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 <address@hidden>
---
hmp.c | 31 ++++++++++++++++++++++++++++++-
monitor.c | 6 +++---
2 files changed, 33 insertions(+), 4 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)
diff --git a/monitor.c b/monitor.c
index f1031a1..f63a3aa 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2628,10 +2628,10 @@ static mon_cmd_t info_cmds[] = {
},
{
.name = "block",
- .args_type = "verbose:-v,device:B?",
- .params = "[-v] [device]",
+ .args_type = "nodes:-n,verbose:-v,device:B?",
+ .params = "[-n] [-v] [device]",
.help = "show info of one block device or all block devices "
- "(and details of images with -v option)",
+ "(-n: show named nodes; -v: show details)",
.mhandler.cmd = hmp_info_block,
},
{
--
1.8.3.1
- [Qemu-devel] [PULL 06/73] chardev: Add -qmp-pretty, (continued)
- [Qemu-devel] [PULL 06/73] chardev: Add -qmp-pretty, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 07/73] iotests: _filter_qmp for pretty JSON output, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 09/73] blockdev: acquire AioContext in blockdev-snapshot-delete-internal-sync, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 02/73] block: Add bdrv_get_node_name, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 11/73] blockdev: acquire AioContext in eject, change, and block_passwd, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 03/73] block: Include "node-name" if present in query-blockstats, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 15/73] block/hmp: Allow info = NULL in print_block_info(), Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 13/73] block/qapi: Add cache information to query-block, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 10/73] blockdev: check for BLOCK_OP_TYPE_INTERNAL_SNAPSHOT_DELETE, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 14/73] block/hmp: Factor out print_block_info(), Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 16/73] block/hmp: Allow node-name in 'info block',
Kevin Wolf <=
- [Qemu-devel] [PULL 17/73] monitor: Fix HMP tab completion, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 21/73] ahci: replace SATA FIS type magic numbers with constants, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 23/73] block: Add AioContextNotifier functions to BB, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 19/73] iotests: Plain blkdebug filename generation, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 20/73] ahci: avoid #ifdef DEBUG_AHCI bitrot, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 22/73] block: Lift more functions into BlockBackend, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 24/73] block: Add blk_add_close_notifier() for BB, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 25/73] nbd: Change external interface to BlockBackend, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 26/73] nbd: Use BlockBackend internally, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 27/73] qemu-nbd: Use BlockBackend where reasonable, Kevin Wolf, 2014/12/10