[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC][PATCH 2/2] Extend monitor command 'info block' to
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [RFC][PATCH 2/2] Extend monitor command 'info block' to display cache settings for block devices. |
Date: |
Mon, 28 Feb 2011 16:15:28 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101027 Fedora/3.0.10-1.fc12 Thunderbird/3.0.10 |
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