diff options
author | Kevin Wolf <kwolf@redhat.com> | 2014-09-15 12:12:52 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-12-10 10:31:11 +0100 |
commit | 8d6adccda25d75dc152b68d15ac75e1670e59b23 (patch) | |
tree | 276c1743c88448c643899f8f4b025f296d891e8c /hmp.c | |
parent | 289b276c69a8b5f90531b41917a536e16bf71837 (diff) | |
download | qemu-8d6adccda25d75dc152b68d15ac75e1670e59b23.zip qemu-8d6adccda25d75dc152b68d15ac75e1670e59b23.tar.gz qemu-8d6adccda25d75dc152b68d15ac75e1670e59b23.tar.bz2 |
block/hmp: Allow info = NULL in print_block_info()
This allows printing infos of BlockDriverStates that aren't at the root
of the graph (and logically implementing a BlockBackend).
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hmp.c')
-rw-r--r-- | hmp.c | 34 |
1 files changed, 25 insertions, 9 deletions
@@ -295,7 +295,21 @@ static void print_block_info(Monitor *mon, BlockInfo *info, { ImageInfo *image_info; - monitor_printf(mon, "%s", info->device); + assert(!info || !info->has_inserted || info->inserted == inserted); + + if (info) { + monitor_printf(mon, "%s", info->device); + if (inserted && inserted->has_node_name) { + monitor_printf(mon, " (%s)", inserted->node_name); + } + } else { + assert(inserted); + monitor_printf(mon, "%s", + inserted->has_node_name + ? inserted->node_name + : "<anonymous>"); + } + if (inserted) { monitor_printf(mon, ": %s (%s%s%s)\n", inserted->file, @@ -306,15 +320,17 @@ static void print_block_info(Monitor *mon, BlockInfo *info, monitor_printf(mon, ": [not inserted]\n"); } - 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]); - } + if (info) { + 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]); + } - if (info->removable) { - monitor_printf(mon, " Removable device: %slocked, tray %s\n", - info->locked ? "" : "not ", - info->tray_open ? "open" : "closed"); + if (info->removable) { + monitor_printf(mon, " Removable device: %slocked, tray %s\n", + info->locked ? "" : "not ", + info->tray_open ? "open" : "closed"); + } } |