Patchwork [08/25] Monitor: Convert bdrv_stats_print() into bdrv_stats()

login
register
mail settings
Submitter Luiz Capitulino
Date Dec. 6, 2010, 6:23 p.m.
Message ID <1291659852-23028-9-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/74446/
State New
Headers show

Comments

Luiz Capitulino - Dec. 6, 2010, 6:23 p.m.
The new handler directly calls qmp_query_blockstats() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 block.c   |    6 +++++-
 block.h   |    2 +-
 monitor.c |    3 +--
 3 files changed, 7 insertions(+), 4 deletions(-)

Patch

diff --git a/block.c b/block.c
index 2eadd70..5b89790 100644
--- a/block.c
+++ b/block.c
@@ -1671,9 +1671,13 @@  static void bdrv_stats_iter(QObject *data, void *opaque)
                         qdict_get_int(qdict, "wr_operations"));
 }
 
-void bdrv_stats_print(Monitor *mon, const QObject *data)
+void bdrv_stats(Monitor *mon)
 {
+    QObject *data;
+
+    qmp_query_blockstats(NULL, &data);
     qlist_iter(qobject_to_qlist(data), bdrv_stats_iter, mon);
+    qobject_decref(data);
 }
 
 static QObject* bdrv_info_stats_bs(BlockDriverState *bs)
diff --git a/block.h b/block.h
index e71b6ad..ff79f02 100644
--- a/block.h
+++ b/block.h
@@ -54,7 +54,7 @@  void bdrv_mon_event(const BlockDriverState *bdrv,
                     BlockMonEventAction action, int is_read);
 void qmp_query_block(Monitor *mon, QObject **ret_data);
 void bdrv_info(Monitor *mon);
-void bdrv_stats_print(Monitor *mon, const QObject *data);
+void bdrv_stats(Monitor *mon);
 void qmp_query_blockstats(Monitor *mon, QObject **ret_data);
 
 void bdrv_init(void);
diff --git a/monitor.c b/monitor.c
index 2bdaf03..3091a1a 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2416,8 +2416,7 @@  static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show block device statistics",
-        .user_print = bdrv_stats_print,
-        .mhandler.info_new = qmp_query_blockstats,
+        .mhandler.info = bdrv_stats,
     },
     {
         .name       = "registers",