From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH 13/19] monitor: Convert do_info_mice() to QObject
Date: Wed, 9 Dec 2009 14:27:52 -0200 [thread overview]
Message-ID: <1260376078-8694-14-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1260376078-8694-1-git-send-email-lcapitulino@redhat.com>
Each mouse is represented by a QDict, the returned QObject is a QList of
all mice.
This commit should not change user output.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
console.h | 3 +-
monitor.c | 3 +-
vl.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
3 files changed, 59 insertions(+), 9 deletions(-)
diff --git a/console.h b/console.h
index 9615f56..c7172f6 100644
--- a/console.h
+++ b/console.h
@@ -44,7 +44,8 @@ struct MouseTransformInfo {
int a[7];
};
-void do_info_mice(Monitor *mon);
+void do_info_mice_print(Monitor *mon, const QObject *data);
+void do_info_mice(Monitor *mon, QObject **ret_data);
void do_mouse_set(Monitor *mon, const QDict *qdict);
/* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
diff --git a/monitor.c b/monitor.c
index f0cb759..d5e8dda 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2492,7 +2492,8 @@ static const mon_cmd_t info_cmds[] = {
.args_type = "",
.params = "",
.help = "show which guest mouse is receiving events",
- .mhandler.info = do_info_mice,
+ .user_print = do_info_mice_print,
+ .mhandler.info_new = do_info_mice,
},
{
.name = "vnc",
diff --git a/vl.c b/vl.c
index 09a0ec5..73737ee 100644
--- a/vl.c
+++ b/vl.c
@@ -156,6 +156,7 @@ int main(int argc, char **argv)
#include "balloon.h"
#include "qemu-option.h"
#include "qemu-config.h"
+#include "qemu-objects.h"
#include "disas.h"
@@ -458,25 +459,72 @@ int kbd_mouse_is_absolute(void)
return qemu_put_mouse_event_current->qemu_put_mouse_event_absolute;
}
-void do_info_mice(Monitor *mon)
+static void info_mice_iter(QObject *data, void *opaque)
+{
+ QDict *mouse;
+ Monitor *mon = opaque;
+
+ mouse = qobject_to_qdict(data);
+ monitor_printf(mon, "%c Mouse #%" PRId64 ": %s\n",
+ (qdict_get_bool(mouse, "current") ? '*' : ' '),
+ qdict_get_int(mouse, "index"), qdict_get_str(mouse, "name"));
+}
+
+void do_info_mice_print(Monitor *mon, const QObject *data)
+{
+ QList *mice_list;
+
+ mice_list = qobject_to_qlist(data);
+ if (qlist_empty(mice_list)) {
+ monitor_printf(mon, "No mouse devices connected\n");
+ return;
+ }
+
+ qlist_iter(mice_list, info_mice_iter, mon);
+}
+
+/**
+ * do_info_mice(): Show VM mice information
+ *
+ * Each mouse is represented by a QDict, the returned QObject is a QList of
+ * all mice.
+ *
+ * The mouse QDict contains the following:
+ *
+ * - "name": mouse's name
+ * - "index": mouse's index
+ * - "current": true if this mouse is receiving events, false otherwise
+ *
+ * Example:
+ *
+ * [ { "name": "QEMU Microsoft Mouse", "index": 0, "current": false },
+ * { "name": "QEMU PS/2 Mouse", "index": 1, "current": true } ]
+ */
+void do_info_mice(Monitor *mon, QObject **ret_data)
{
QEMUPutMouseEntry *cursor;
+ QList *mice_list;
int index = 0;
+ mice_list = qlist_new();
+
if (!qemu_put_mouse_event_head) {
- monitor_printf(mon, "No mouse devices connected\n");
- return;
+ goto out;
}
- monitor_printf(mon, "Mouse devices available:\n");
cursor = qemu_put_mouse_event_head;
while (cursor != NULL) {
- monitor_printf(mon, "%c Mouse #%d: %s\n",
- (cursor == qemu_put_mouse_event_current ? '*' : ' '),
- index, cursor->qemu_put_mouse_event_name);
+ QObject *obj;
+ obj = qobject_from_jsonf("{ 'name': %s, 'index': %d, 'current': %i }",
+ cursor->qemu_put_mouse_event_name,
+ index, cursor == qemu_put_mouse_event_current);
+ qlist_append_obj(mice_list, obj);
index++;
cursor = cursor->next;
}
+
+out:
+ *ret_data = QOBJECT(mice_list);
}
void do_mouse_set(Monitor *mon, const QDict *qdict)
--
1.6.6.rc1.39.g9a42
next prev parent reply other threads:[~2009-12-09 16:39 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-09 16:27 [Qemu-devel] [FOR 0.12 v3 00/19]: info handlers conversions to QObject Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 01/19] Introduce qemu-objects.h header file Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 02/19] Makefile: move QObject objs to their own entry Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 03/19] QDict: Introduce qdict_get_qbool() Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 04/19] QDict: Introduce qdict_get_qlist() Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 05/19] monitor: Fix do_info_balloon() output Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 06/19] monitor: do_info_cpus(): Use QBool Luiz Capitulino
2009-12-10 10:44 ` Markus Armbruster
2009-12-10 12:00 ` Luiz Capitulino
2009-12-10 13:01 ` Anthony Liguori
2009-12-10 13:05 ` Luiz Capitulino
2009-12-10 13:08 ` Anthony Liguori
2009-12-10 13:10 ` Anthony Liguori
2009-12-10 13:22 ` Markus Armbruster
2009-12-09 16:27 ` [Qemu-devel] [PATCH 07/19] monitor: do_info_version(): Use QDict Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 08/19] monitor: Convert do_info_status() to QObject Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 09/19] monitor: Convert do_info_kvm() " Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 10/19] monitor: Convert do_info_name() " Luiz Capitulino
2009-12-10 10:09 ` Markus Armbruster
2009-12-10 11:52 ` Luiz Capitulino
2009-12-10 12:56 ` Anthony Liguori
2009-12-10 15:55 ` Avi Kivity
2009-12-10 15:57 ` Avi Kivity
2009-12-10 16:03 ` Anthony Liguori
2009-12-10 16:10 ` Avi Kivity
2009-12-10 16:20 ` Anthony Liguori
2009-12-10 16:24 ` Avi Kivity
2009-12-10 16:54 ` Luiz Capitulino
2009-12-10 17:02 ` Avi Kivity
2009-12-10 17:12 ` Luiz Capitulino
2009-12-10 17:38 ` Daniel P. Berrange
2009-12-10 17:49 ` Luiz Capitulino
2009-12-10 18:00 ` Daniel P. Berrange
2009-12-11 12:54 ` Luiz Capitulino
2009-12-11 13:14 ` Anthony Liguori
2009-12-11 13:20 ` Anthony Liguori
2009-12-11 19:46 ` Daniel P. Berrange
2009-12-11 13:18 ` Anthony Liguori
2009-12-11 13:27 ` Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 11/19] monitor: Convert do_info_hpet() " Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 12/19] monitor: Convert do_info_uuid() " Luiz Capitulino
2009-12-10 10:14 ` Markus Armbruster
2009-12-09 16:27 ` Luiz Capitulino [this message]
2009-12-09 16:27 ` [Qemu-devel] [PATCH 14/19] migration: Convert do_info_migrate() " Luiz Capitulino
2009-12-10 10:19 ` Markus Armbruster
2009-12-09 16:27 ` [Qemu-devel] [PATCH 15/19] block: Convert bdrv_info() " Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 16/19] block: Convert bdrv_info_stats() " Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 17/19] char: Convert qemu_chr_info() " Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 18/19] PCI: Convert pci_device_hot_add() " Luiz Capitulino
2009-12-09 16:27 ` [Qemu-devel] [PATCH 19/19] VNC: Convert do_info_vnc() " Luiz Capitulino
2009-12-10 10:34 ` Markus Armbruster
2009-12-10 11:56 ` Luiz Capitulino
2009-12-10 12:12 ` Daniel P. Berrange
2009-12-10 13:00 ` Anthony Liguori
2009-12-10 10:49 ` [Qemu-devel] [FOR 0.12 v3 00/19]: info handlers conversions " Markus Armbruster
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=1260376078-8694-14-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).