From patchwork Mon Feb 28 12:11:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prerna Saxena X-Patchwork-Id: 84825 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 84906B6F12 for ; Mon, 28 Feb 2011 23:13:41 +1100 (EST) Received: from localhost ([127.0.0.1]:39047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pu1ys-0005bP-He for incoming@patchwork.ozlabs.org; Mon, 28 Feb 2011 07:13:38 -0500 Received: from [140.186.70.92] (port=37189 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pu1x1-000575-9X for qemu-devel@nongnu.org; Mon, 28 Feb 2011 07:11:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pu1wz-0000xU-NN for qemu-devel@nongnu.org; Mon, 28 Feb 2011 07:11:42 -0500 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:55090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pu1wz-0000xC-6m for qemu-devel@nongnu.org; Mon, 28 Feb 2011 07:11:41 -0500 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [202.81.31.245]) by e23smtp09.au.ibm.com (8.14.4/8.13.1) with ESMTP id p1SCBb6r015984 for ; Mon, 28 Feb 2011 23:11:37 +1100 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p1SCBb9T647346 for ; Mon, 28 Feb 2011 23:11:37 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p1SCBamX000936 for ; Mon, 28 Feb 2011 23:11:36 +1100 Received: from zephyr ([9.124.31.62]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p1SCBZoW000912; Mon, 28 Feb 2011 23:11:35 +1100 Date: Mon, 28 Feb 2011 17:41:32 +0530 From: Prerna Saxena To: qemu-devel Message-ID: <20110228174132.769fe22f@zephyr> In-Reply-To: <20110228171956.05a84fb9@zephyr> References: <20110228171956.05a84fb9@zephyr> Organization: IBM X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; i386-redhat-linux-gnu) Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 202.81.31.142 Cc: kwolf@redhat.com, Anthony Liguori , Ananth Narayan , Stefan Hajnoczi Subject: [Qemu-devel] [RFC][PATCH 2/2] Extend monitor command 'info block' to display cache settings for block devices. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org (qemu)info block SAMPLE output : ide0-hd0: type=hd removable=0 cache=none file=/tmp/abc.img ro=0 drv=qcow2 encrypted=0 --- block.c | 22 ++++++++++++++++++++-- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index f7d91a2..c717888 100644 --- a/block.c +++ b/block.c @@ -1707,6 +1707,23 @@ static void bdrv_print_dict(QObject *obj, void *opaque) monitor_printf(mon, " locked=%d", qdict_get_bool(bs_dict, "locked")); } + if (qdict_haskey(bs_dict, "open_flags") && + !strcmp(qdict_get_str(bs_dict, "type"), "hd")) { + int open_flags = qdict_get_int(bs_dict, "open_flags"); + if (open_flags & BDRV_O_NOCACHE) { + monitor_printf(mon, " cache=none"); + } else if (open_flags & BDRV_O_CACHE_WB) { + if (open_flags & BDRV_O_NO_FLUSH) { + monitor_printf(mon, " cache=unsafe"); + } + else { + monitor_printf(mon, " cache=writeback"); + } + } else { + monitor_printf(mon, " cache=writethrough"); + } + } + if (qdict_haskey(bs_dict, "inserted")) { QDict *qdict = qobject_to_qdict(qdict_get(bs_dict, "inserted")); @@ -1756,9 +1773,10 @@ void bdrv_info(Monitor *mon, QObject **ret_data) } bs_obj = qobject_from_jsonf("{ 'device': %s, 'type': %s, " - "'removable': %i, 'locked': %i }", + "'removable': %i, 'locked': %i, " + "'open_flags': %d }", bs->device_name, type, bs->removable, - bs->locked); + bs->locked, bs->open_flags); if (bs->drv) { QObject *obj;