diff options
author | Aurelien Jarno <aurelien@aurel32.net> | 2012-09-10 15:04:36 +0200 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2012-09-10 15:04:36 +0200 |
commit | e22b1e9907833d72f4a959b34c5eefc3533c7711 (patch) | |
tree | 662cf685e04726bb68d8eeee94a06d694f35f95a /hmp.c | |
parent | a32354e206895400d17c3de9a8df1de96d3df289 (diff) | |
parent | 0ab6b63655ba59d7c05089017acb721a44979526 (diff) |
Merge branch 'queue/qmp' of git://repo.or.cz/qemu/qmp-unstable
* 'queue/qmp' of git://repo.or.cz/qemu/qmp-unstable:
tcx: tcx_screen_dump(): add error handling
tcx: tcx24_screen_dump(): add error handling
g364fb: g364fb_screen_dump(): add error handling
omap_lcdc: omap_ppm_save(): add error handling
omap_lcdc: rename ppm_save() to omap_ppm_save()
vga: ppm_save(): add error handling
qapi: convert screendump
console: vga_hw_screen_dump_ptr: take Error argument
error: add error_setg()
json-parser: Fix potential NULL pointer segfault
qapi: Fix potential NULL pointer segfault
qapi: convert sendkey
monitor: move key_defs[] table and introduce two help functions
qapi: add the QKeyCode enum
qapi: generate list struct and visit_list for enum
hmp: rename arguments
monitor: rename keyname '<' to 'less'
fix doc of using raw values with sendkey
Add support for pretty-printing response in qmp-shell
Diffstat (limited to 'hmp.c')
-rw-r--r-- | hmp.c | 64 |
1 files changed, 64 insertions, 0 deletions
@@ -19,6 +19,7 @@ #include "qemu-timer.h" #include "qmp-commands.h" #include "monitor.h" +#include "console.h" static void hmp_handle_error(Monitor *mon, Error **errp) { @@ -1102,3 +1103,66 @@ void hmp_closefd(Monitor *mon, const QDict *qdict) qmp_closefd(fdname, &errp); hmp_handle_error(mon, &errp); } + +void hmp_send_key(Monitor *mon, const QDict *qdict) +{ + const char *keys = qdict_get_str(qdict, "keys"); + QKeyCodeList *keylist, *head = NULL, *tmp = NULL; + int has_hold_time = qdict_haskey(qdict, "hold-time"); + int hold_time = qdict_get_try_int(qdict, "hold-time", -1); + Error *err = NULL; + char keyname_buf[16]; + char *separator; + int keyname_len, idx; + + while (1) { + separator = strchr(keys, '-'); + keyname_len = separator ? separator - keys : strlen(keys); + pstrcpy(keyname_buf, sizeof(keyname_buf), keys); + + /* Be compatible with old interface, convert user inputted "<" */ + if (!strncmp(keyname_buf, "<", 1) && keyname_len == 1) { + pstrcpy(keyname_buf, sizeof(keyname_buf), "less"); + keyname_len = 4; + } + keyname_buf[keyname_len] = 0; + + idx = index_from_key(keyname_buf); + if (idx == Q_KEY_CODE_MAX) { + monitor_printf(mon, "invalid parameter: %s\n", keyname_buf); + break; + } + + keylist = g_malloc0(sizeof(*keylist)); + keylist->value = idx; + keylist->next = NULL; + + if (!head) { + head = keylist; + } + if (tmp) { + tmp->next = keylist; + } + tmp = keylist; + + if (!separator) { + break; + } + keys = separator + 1; + } + + if (idx != Q_KEY_CODE_MAX) { + qmp_send_key(head, has_hold_time, hold_time, &err); + } + hmp_handle_error(mon, &err); + qapi_free_QKeyCodeList(head); +} + +void hmp_screen_dump(Monitor *mon, const QDict *qdict) +{ + const char *filename = qdict_get_str(qdict, "filename"); + Error *err = NULL; + + qmp_screendump(filename, &err); + hmp_handle_error(mon, &err); +} |