qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, aliguori@us.ibm.com, armbru@redhat.com
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	[thread overview]
Message-ID: <1312384765-721-3-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1312384765-721-1-git-send-email-lcapitulino@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 <lcapitulino@redhat.com>
---
 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

  parent reply	other threads:[~2011-08-03 15:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-03 15:19 [Qemu-devel] [PATCH v2 0/5]: QMP: Proper thin provisioning support Luiz Capitulino
2011-08-03 15:19 ` [Qemu-devel] [PATCH 1/5] block: Introduce get_iostatus() device model operation Luiz Capitulino
2011-08-03 15:19 ` Luiz Capitulino [this message]
2011-08-03 15:19 ` [Qemu-devel] [PATCH 3/5] virtio-blk: Support I/O status Luiz Capitulino
2011-08-03 15:19 ` [Qemu-devel] [PATCH 4/5] ide: " Luiz Capitulino
2011-08-03 15:19 ` [Qemu-devel] [PATCH 5/5] scsi-disk: " Luiz Capitulino
2011-08-03 15:39 ` [Qemu-devel] [PATCH v2 0/5]: QMP: Proper thin provisioning support Kevin Wolf
2011-08-03 18:08   ` Luiz Capitulino
2011-08-04  8:10     ` Kevin Wolf
2011-08-04  9:19       ` Markus Armbruster
2011-08-04 13:42         ` Luiz Capitulino
2011-08-03 16:31 ` Christoph Hellwig
2011-08-03 18:11   ` Luiz Capitulino
2011-08-03 18:26     ` Christoph Hellwig
2011-08-03 18:36       ` Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1312384765-721-3-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).