Received: from eggs.gnu.org ([2001:4830:134:3::10]:58719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xyebo-0008Tr-Tt for qemu-devel@nongnu.org; Wed, 10 Dec 2014 05:35:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xyebh-0007PR-BF for qemu-devel@nongnu.org; Wed, 10 Dec 2014 05:35:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55582) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xyebh-0007OX-3G for qemu-devel@nongnu.org; Wed, 10 Dec 2014 05:34:57 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBAAYuiq028585 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 10 Dec 2014 05:34:56 -0500 From: Kevin Wolf Date: Wed, 10 Dec 2014 11:33:41 +0100 Message-Id: <1418207679-32260-16-git-send-email-kwolf@redhat.com> In-Reply-To: <1418207679-32260-1-git-send-email-kwolf@redhat.com> References: <1418207679-32260-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 15/73] 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 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 2e2b91b..05ccf5f 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