From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH 18/20] char: Convert qemu_chr_info() to QObject
Date: Thu, 10 Dec 2009 12:43:33 -0200 [thread overview]
Message-ID: <1260456215-31022-19-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1260456215-31022-1-git-send-email-lcapitulino@redhat.com>
Each device is represented by a QDict. The returned QObject is a QList
of all devices.
This commit should not change user output.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
monitor.c | 3 ++-
qemu-char.c | 43 +++++++++++++++++++++++++++++++++++++++++--
qemu-char.h | 4 +++-
3 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/monitor.c b/monitor.c
index 5c092d0..a74578f 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2356,7 +2356,8 @@ static const mon_cmd_t info_cmds[] = {
.args_type = "",
.params = "",
.help = "show the character devices",
- .mhandler.info = qemu_chr_info,
+ .user_print = qemu_chr_info_print,
+ .mhandler.info_new = qemu_chr_info,
},
{
.name = "block",
diff --git a/qemu-char.c b/qemu-char.c
index da5c15c..c0d1cb0 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -32,6 +32,7 @@
#include "hw/usb.h"
#include "hw/baum.h"
#include "hw/msmouse.h"
+#include "qemu-objects.h"
#include <unistd.h>
#include <fcntl.h>
@@ -2469,13 +2470,51 @@ void qemu_chr_close(CharDriverState *chr)
qemu_free(chr);
}
-void qemu_chr_info(Monitor *mon)
+static void qemu_chr_qlist_iter(QObject *obj, void *opaque)
{
+ QDict *chr_dict;
+ Monitor *mon = opaque;
+
+ chr_dict = qobject_to_qdict(obj);
+ monitor_printf(mon, "%s: filename=%s\n", qdict_get_str(chr_dict, "label"),
+ qdict_get_str(chr_dict, "filename"));
+}
+
+void qemu_chr_info_print(Monitor *mon, const QObject *ret_data)
+{
+ qlist_iter(qobject_to_qlist(ret_data), qemu_chr_qlist_iter, mon);
+}
+
+/**
+ * qemu_chr_info(): Character devices information
+ *
+ * Each device is represented by a QDict. The returned QObject is a QList
+ * of all devices.
+ *
+ * The QDict contains the following:
+ *
+ * - "label": device's label
+ * - "filename": device's file
+ *
+ * Example:
+ *
+ * [ { "label": "monitor", "filename", "stdio" },
+ * { "label": "serial0", "filename": "vc" } ]
+ */
+void qemu_chr_info(Monitor *mon, QObject **ret_data)
+{
+ QList *chr_list;
CharDriverState *chr;
+ chr_list = qlist_new();
+
QTAILQ_FOREACH(chr, &chardevs, next) {
- monitor_printf(mon, "%s: filename=%s\n", chr->label, chr->filename);
+ QObject *obj = qobject_from_jsonf("{ 'label': %s, 'filename': %s }",
+ chr->label, chr->filename);
+ qlist_append_obj(chr_list, obj);
}
+
+ *ret_data = QOBJECT(chr_list);
}
CharDriverState *qemu_chr_find(const char *name)
diff --git a/qemu-char.h b/qemu-char.h
index 9957db1..48f54d8 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -5,6 +5,7 @@
#include "qemu-queue.h"
#include "qemu-option.h"
#include "qemu-config.h"
+#include "qobject.h"
/* character device */
@@ -87,7 +88,8 @@ 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(Monitor *mon);
+void qemu_chr_info_print(Monitor *mon, const QObject *ret_data);
+void qemu_chr_info(Monitor *mon, QObject **ret_data);
CharDriverState *qemu_chr_find(const char *name);
extern int term_escape_char;
--
1.6.6.rc1.39.g9a42
next prev parent reply other threads:[~2009-12-10 14:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-10 14:43 [Qemu-devel] [FOR 0.12 v4 00/20]: info handlers conversions to QObject Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 01/20] Introduce qemu-objects.h header file Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 02/20] Makefile: move QObject objs to their own entry Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 03/20] QDict: Introduce qdict_get_qbool() Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 04/20] QDict: Introduce qdict_get_qlist() Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 05/20] monitor: Fix do_info_balloon() output Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 06/20] monitor: Fix do_info_commands() output Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 07/20] monitor: do_info_cpus(): Use QBool Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 08/20] monitor: do_info_version(): Use QDict Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 09/20] monitor: Convert do_info_status() to QObject Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 10/20] monitor: Convert do_info_kvm() " Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 11/20] monitor: Convert do_info_name() " Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 12/20] monitor: Convert do_info_hpet() " Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 13/20] monitor: Convert do_info_uuid() " Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 14/20] monitor: Convert do_info_mice() " Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 15/20] migration: Convert do_info_migrate() " Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 16/20] block: Convert bdrv_info() " Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 17/20] block: Convert bdrv_info_stats() " Luiz Capitulino
2009-12-10 14:43 ` Luiz Capitulino [this message]
2009-12-10 14:43 ` [Qemu-devel] [PATCH 19/20] PCI: Convert pci_device_hot_add() " Luiz Capitulino
2009-12-10 14:43 ` [Qemu-devel] [PATCH 20/20] VNC: Convert do_info_vnc() " Luiz Capitulino
2009-12-10 15:26 ` malc
2009-12-10 15:30 ` Anthony Liguori
2009-12-10 18:37 ` Luiz Capitulino
-- strict thread matches above, loose matches on Subject: below --
2009-12-10 19:15 [Qemu-devel] [FOR 0.12 v5 00/20]: info handlers conversions " Luiz Capitulino
2009-12-10 19:16 ` [Qemu-devel] [PATCH 18/20] char: Convert qemu_chr_info() " 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=1260456215-31022-19-git-send-email-lcapitulino@redhat.com \
--to=lcapitulino@redhat.com \
--cc=aliguori@us.ibm.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).