[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/5] QMP/HMP: Add the 'io-status' field to query-blo
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 2/5] QMP/HMP: Add the 'io-status' field to query-block and info block |
Date: |
Wed, 3 Aug 2011 12:19:22 -0300 |
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 <address@hidden>
---
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 <sys/time.h>
@@ -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
[Qemu-devel] [PATCH 3/5] virtio-blk: Support I/O status, Luiz Capitulino, 2011/08/03
Re: [Qemu-devel] [PATCH v2 0/5]: QMP: Proper thin provisioning support, Christoph Hellwig, 2011/08/03