From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:40059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QodEf-0001Ro-PV for qemu-devel@nongnu.org; Wed, 03 Aug 2011 11:19:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QodEe-0006vl-Pk for qemu-devel@nongnu.org; Wed, 03 Aug 2011 11:19:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QodEe-0006vf-AP for qemu-devel@nongnu.org; Wed, 03 Aug 2011 11:19:52 -0400 From: Luiz Capitulino Date: Wed, 3 Aug 2011 12:19:22 -0300 Message-Id: <1312384765-721-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1312384765-721-1-git-send-email-lcapitulino@redhat.com> References: <1312384765-721-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 2/5] QMP/HMP: Add the 'io-status' field to query-block and info block List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, aliguori@us.ibm.com, armbru@redhat.com This field is only available if the device model implements the get_iostatus() operation and the VM is stopped. It contains the I/O status before the VM being stopped. Please, also note that it's necessary to add qemu_is_running() to qemu-tool.c so that we can use it in block.c. Signed-off-by: Luiz Capitulino --- block.c | 19 +++++++++++++++++++ qemu-tool.c | 6 ++++++ qmp-commands.hx | 3 +++ 3 files changed, 28 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index c86e144..41e4f89 100644 --- a/block.c +++ b/block.c @@ -1760,6 +1760,10 @@ static void bdrv_print_dict(QObject *obj, void *opaque) if (qdict_get_try_bool(bs_dict, "ejected", false)) { monitor_printf(mon, " ejected"); } + if (qdict_haskey(bs_dict, "io-status")) { + monitor_printf(mon, " io-status=%s", + qdict_get_str(bs_dict, "io-status")); + } if (qdict_haskey(bs_dict, "inserted")) { QDict *qdict = qobject_to_qdict(qdict_get(bs_dict, "inserted")); @@ -1785,6 +1789,12 @@ void bdrv_info_print(Monitor *mon, const QObject *data) qlist_iter(qobject_to_qlist(data), bdrv_print_dict, mon); } +static const char *const block_iostatus_name[] = { + [BDRV_IOS_OK] = "ok", + [BDRV_IOS_FAILED] = "failed", + [BDRV_IOS_ENOSPC] = "nospace", +}; + void bdrv_info(Monitor *mon, QObject **ret_data) { QList *bs_list; @@ -1822,6 +1832,15 @@ void bdrv_info(Monitor *mon, QObject **ret_data) qdict_put_obj(bs_dict, "inserted", obj); } + + if (!qemu_is_running()) { + BlockDevIOStatus iostatus = bdrv_dev_iostatus(bs); + if (iostatus != BDRV_IOS_INVAL) { + qdict_put(bs_dict, "io-status", + qstring_from_str(block_iostatus_name[iostatus])); + } + } + qlist_append_obj(bs_list, bs_obj); } diff --git a/qemu-tool.c b/qemu-tool.c index 41e5c41..9381c56 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -15,6 +15,7 @@ #include "monitor.h" #include "qemu-timer.h" #include "qemu-log.h" +#include "sysemu.h" #include @@ -96,3 +97,8 @@ int64_t qemu_get_clock_ns(QEMUClock *clock) { return 0; } + +int qemu_is_running(void) +{ + return 0; +} diff --git a/qmp-commands.hx b/qmp-commands.hx index b141221..1007ec6 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1132,6 +1132,9 @@ Each json-object contain the following: - "removable": true if the device is removable, false otherwise (json-bool) - "locked": true if the device is locked, false otherwise (json-bool) - "ejected": present and true if the device ejected its media (json-bool) +- "io-status": contains the status of the last I/O operation. It's only + present if the device supports it and if the Virtual Machine is stopped + (json-bool, optional). Possible values: "ok", "nospace", "failed" - "inserted": only present if the device is inserted, it is a json-object containing the following: - "file": device file name (json-string) -- 1.7.6.396.ge0613