diff options
author | Luiz Capitulino <lcapitulino@redhat.com> | 2009-12-10 17:16:08 -0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-12-12 07:59:49 -0600 |
commit | 588b38320134edee4a569f60ed88c9848961d6ee (patch) | |
tree | c8483cf34d82d4271cba8fd2428c76de472df08e /qemu-char.c | |
parent | 218a536a7a7c6d3679d5eca0103f32fd11fbfaf0 (diff) |
char: Convert qemu_chr_info() to QObject
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>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r-- | qemu-char.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/qemu-char.c b/qemu-char.c index c6008c395a..b13f8d4cf7 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) |