From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTuoM-0006J8-Vy for qemu-devel@nongnu.org; Tue, 16 Sep 2014 11:37:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XTuoF-0002AK-Mt for qemu-devel@nongnu.org; Tue, 16 Sep 2014 11:36:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52592) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTuoF-00029V-F1 for qemu-devel@nongnu.org; Tue, 16 Sep 2014 11:36:51 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8GFalO7031839 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 16 Sep 2014 11:36:47 -0400 From: Kevin Wolf Date: Tue, 16 Sep 2014 17:36:35 +0200 Message-Id: <1410881796-18452-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1410881796-18452-1-git-send-email-kwolf@redhat.com> References: <1410881796-18452-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 5/6] block/hmp: Allow info = NULL in print_block_info() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com 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 --- hmp.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/hmp.c b/hmp.c index be55b9b..811ceba 100644 --- a/hmp.c +++ b/hmp.c @@ -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 + : ""); + } + 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"); + } } -- 1.8.3.1