diff options
author | 2009-12-14 17:19:33 +0200 | |
---|---|---|
committer | 2009-12-14 17:19:33 +0200 | |
commit | e3b21b3a941a9b8f439a5776c3ca8869840d20fe (patch) | |
tree | 22686a4c9175a4df96d98410d528494b8586aaca /vl.c | |
parent | Merge commit '94f539bdac57daea5f5d853cfee86bd683cf81cf' into stable-0.12-merge (diff) | |
parent | monitor: Convert do_info_mice() to QObject (diff) | |
download | qemu-kvm-e3b21b3a941a9b8f439a5776c3ca8869840d20fe.tar.gz qemu-kvm-e3b21b3a941a9b8f439a5776c3ca8869840d20fe.tar.bz2 qemu-kvm-e3b21b3a941a9b8f439a5776c3ca8869840d20fe.zip |
Merge commit '3be42b28c14e2826eebbced68ad3ceb92507401d' into stable-0.12-merge
* commit '3be42b28c14e2826eebbced68ad3ceb92507401d':
monitor: Convert do_info_mice() to QObject
monitor: Convert do_info_uuid() to QObject
monitor: Convert do_info_hpet() to QObject
monitor: Convert do_info_name() to QObject
Conflicts:
vl.c
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 62 |
1 files changed, 55 insertions, 7 deletions
@@ -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 "qemu-kvm.h" #include "hw/device-assignment.h" @@ -504,25 +505,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) |