From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=55443 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pu4n1-0006EU-KO for qemu-devel@nongnu.org; Mon, 28 Feb 2011 10:13:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pu4n0-0007dB-3T for qemu-devel@nongnu.org; Mon, 28 Feb 2011 10:13:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:26233) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pu4mz-0007cu-Nz for qemu-devel@nongnu.org; Mon, 28 Feb 2011 10:13:34 -0500 Message-ID: <4D6BBC10.4080203@redhat.com> Date: Mon, 28 Feb 2011 16:15:28 +0100 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RFC][PATCH 2/2] Extend monitor command 'info block' to display cache settings for block devices. References: <20110228171956.05a84fb9@zephyr> <20110228174132.769fe22f@zephyr> In-Reply-To: <20110228174132.769fe22f@zephyr> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Prerna Saxena Cc: Anthony Liguori , Ananth Narayan , qemu-devel , Stefan Hajnoczi Am 28.02.2011 13:11, schrieb Prerna Saxena: > (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); IIUC, this is the structure that a QMP client will receive for a query-block command. The open_flags bitmask is not considered an ABI and completely meaningless outside qemu. Kevin