(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; -- 1.7.2.3 -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India