Patchwork [06/25] Monitor: Convert qemu_chr_info_print() into qemu_chr_info()

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

Comments

Luiz Capitulino - Dec. 6, 2010, 6:23 p.m.
The new handler directly calls qmp_query_chardev() 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>
---
 monitor.c   |    3 +--
 qemu-char.c |    8 ++++++--
 qemu-char.h |    2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)

Patch

diff --git a/monitor.c b/monitor.c
index 56575a6..d48c137 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2402,8 +2402,7 @@  static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the character devices",
-        .user_print = qemu_chr_info_print,
-        .mhandler.info_new = qmp_query_chardev,
+        .mhandler.info = qemu_chr_info,
     },
     {
         .name       = "block",
diff --git a/qemu-char.c b/qemu-char.c
index e8788e6..063943f 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2584,9 +2584,13 @@  static void qemu_chr_qlist_iter(QObject *obj, void *opaque)
                                          qdict_get_str(chr_dict, "filename"));
 }
 
-void qemu_chr_info_print(Monitor *mon, const QObject *ret_data)
+void qemu_chr_info(Monitor *mon)
 {
-    qlist_iter(qobject_to_qlist(ret_data), qemu_chr_qlist_iter, mon);
+    QObject *data;
+
+    qmp_query_chardev(NULL, &data);
+    qlist_iter(qobject_to_qlist(data), qemu_chr_qlist_iter, mon);
+    qobject_decref(data);
 }
 
 void qmp_query_chardev(Monitor *mon, QObject **ret_data)
diff --git a/qemu-char.h b/qemu-char.h
index a456bb9..09d3de3 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -92,7 +92,7 @@  int qemu_chr_can_read(CharDriverState *s);
 void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len);
 int qemu_chr_get_msgfd(CharDriverState *s);
 void qemu_chr_accept_input(CharDriverState *s);
-void qemu_chr_info_print(Monitor *mon, const QObject *ret_data);
+void qemu_chr_info(Monitor *mon);
 void qmp_query_chardev(Monitor *mon, QObject **ret_data);
 CharDriverState *qemu_chr_find(const char *name);