From patchwork Fri Jun 17 16:37:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Supriya Kannery X-Patchwork-Id: 100829 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5CAB7B6FB7 for ; Sat, 18 Jun 2011 02:29:37 +1000 (EST) Received: from localhost ([::1]:47083 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXbvK-0000WO-81 for incoming@patchwork.ozlabs.org; Fri, 17 Jun 2011 12:29:34 -0400 Received: from eggs.gnu.org ([140.186.70.92]:51261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXbra-0000ML-8E for qemu-devel@nongnu.org; Fri, 17 Jun 2011 12:25:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QXbrY-00080s-KC for qemu-devel@nongnu.org; Fri, 17 Jun 2011 12:25:42 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:41155) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXbrY-00080b-3F for qemu-devel@nongnu.org; Fri, 17 Jun 2011 12:25:40 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e9.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p5HFspOe003816 for ; Fri, 17 Jun 2011 11:54:51 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p5HGPcej153320 for ; Fri, 17 Jun 2011 12:25:38 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p5HGPaa2027994 for ; Fri, 17 Jun 2011 13:25:37 -0300 Received: from [127.0.0.1] ([9.79.233.226]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p5HGPYRZ027848; Fri, 17 Jun 2011 13:25:35 -0300 From: Supriya Kannery To: qemu-devel@nongnu.org Date: Fri, 17 Jun 2011 22:07:35 +0530 Message-Id: <20110617163735.2933.67191.sendpatchset@skannery> In-Reply-To: <20110617163710.2933.89020.sendpatchset@skannery> References: <20110617163710.2933.89020.sendpatchset@skannery> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 32.97.182.139 Cc: Kevin Wolf , Supriya Kannery , Christoph Hellwig Subject: [Qemu-devel] [V3 1/3] Enhance "info block" to display hostcache setting X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Enhance "info block" to display hostcache setting for each block device. Example: (qemu) info block ide0-hd0: type=hd removable=0 file=../rhel6-32.qcow2 ro=0 drv=qcow2 encrypted=0 Enhanced to display "hostcache" setting: (qemu) info block ide0-hd0: type=hd removable=0 hostcache=true file=../rhel6-32.qcow2 ro=0 drv=qcow2 encrypted=0 Signed-off-by: Supriya Kannery --- block.c | 21 +++++++++++++++++---- qmp-commands.hx | 2 ++ 2 files changed, 19 insertions(+), 4 deletions(-) Index: qemu/block.c =================================================================== --- qemu.orig/block.c +++ qemu/block.c @@ -1694,6 +1694,14 @@ static void bdrv_print_dict(QObject *obj monitor_printf(mon, " locked=%d", qdict_get_bool(bs_dict, "locked")); } + if (qdict_haskey(bs_dict, "open_flags")) { + int open_flags = qdict_get_int(bs_dict, "open_flags"); + if (open_flags & BDRV_O_NOCACHE) + monitor_printf(mon, " hostcache=false"); + else + monitor_printf(mon, " hostcache=true"); + } + if (qdict_haskey(bs_dict, "inserted")) { QDict *qdict = qobject_to_qdict(qdict_get(bs_dict, "inserted")); @@ -1730,13 +1738,18 @@ void bdrv_info(Monitor *mon, QObject **r QObject *bs_obj; bs_obj = qobject_from_jsonf("{ 'device': %s, 'type': 'unknown', " - "'removable': %i, 'locked': %i }", - bs->device_name, bs->removable, - bs->locked); + "'removable': %i, 'locked': %i, " + "'hostcache': %s }", + bs->device_name, bs->removable, + bs->locked, + (bs->open_flags & BDRV_O_NOCACHE) ? + "false" : "true"); + + QDict *bs_dict = qobject_to_qdict(bs_obj); + qdict_put(bs_dict, "open_flags", qint_from_int(bs->open_flags)); if (bs->drv) { QObject *obj; - QDict *bs_dict = qobject_to_qdict(bs_obj); obj = qobject_from_jsonf("{ 'file': %s, 'ro': %i, 'drv': %s, " "'encrypted': %i }", Index: qemu/qmp-commands.hx =================================================================== --- qemu.orig/qmp-commands.hx +++ qemu/qmp-commands.hx @@ -1070,6 +1070,7 @@ Each json-object contain the following: - Possible values: "unknown" - "removable": true if the device is removable, false otherwise (json-bool) - "locked": true if the device is locked, false otherwise (json-bool) +- "hostcache": true if hostcache enabled, false otherwise (json-bool) - "inserted": only present if the device is inserted, it is a json-object containing the following: - "file": device file name (json-string) @@ -1091,6 +1092,7 @@ Example: { "device":"ide0-hd0", "locked":false, + "hostcache":false, "removable":false, "inserted":{ "ro":false,