* [Qemu-devel] [PATCH v3 0/6] convert sendkey to qapi
@ 2012-06-20 4:47 Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 1/6] fix doc of using raw values with sendkey Amos Kong
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Amos Kong @ 2012-06-20 4:47 UTC (permalink / raw)
To: aliguori, eblake, berrange, lcapitulino, qemu-devel; +Cc: Amos Kong
This series converted 'sendkey' command to qapi. The raw value
in hexadecimal format is not supported by 'sendkey' of qmp.
Amos Kong (6):
fix doc of using raw values with sendkey
monitor: rename keyname '<' to 'less'
hmp: rename arguments
qapi: generate list struct and visit_list for enum
qapi: convert sendkey
ps2: output warning when event queue full
hmp-commands.hx | 10 ++--
hmp.c | 45 ++++++++++++++++++++++
hmp.h | 1 +
hw/ps2.c | 4 +-
monitor.c | 99 +++++++++++++++++++++++--------------------------
monitor.h | 2 +
qapi-schema.json | 45 ++++++++++++++++++++++
qmp-commands.hx | 27 +++++++++++++
scripts/qapi-types.py | 16 +++++++-
scripts/qapi-visit.py | 14 ++++++-
10 files changed, 202 insertions(+), 61 deletions(-)
---
Changes from v1:
- using a JSON array for the key names
- rename new error to 'QERR_OVERFLOW'
- fix command descriptions
- qapi: generate list struct for enum
- add '<' fixing
Changes from v2:
- fix support of raw value in hexadecimal format
- fix bug in processing of '<-x'
- don't generate useless cleanup functions for enum
- introduced two functions for enum in qapi scripts
- fix command description
- drop keys number limitation in sendkey
- drop patch: qerror: add QERR_OVERFLOW
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v3 1/6] fix doc of using raw values with sendkey
2012-06-20 4:47 [Qemu-devel] [PATCH v3 0/6] convert sendkey to qapi Amos Kong
@ 2012-06-20 4:47 ` Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 2/6] monitor: rename keyname '<' to 'less' Amos Kong
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Amos Kong @ 2012-06-20 4:47 UTC (permalink / raw)
To: aliguori, eblake, berrange, lcapitulino, qemu-devel; +Cc: Amos Kong
(qemu) sendkey a
(qemu) sendkey 0x1e
(qemu) sendkey #0x1e
unknown key: '#0x1e'
The last command doesn't work, '#' is not requested before
raw values. And the raw value in decimal format is also not
supported.
Signed-off-by: Amos Kong <akong@redhat.com>
---
hmp-commands.hx | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index f5d9d91..30243b6 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -512,9 +512,9 @@ STEXI
@item sendkey @var{keys}
@findex sendkey
-Send @var{keys} to the emulator. @var{keys} could be the name of the
-key or @code{#} followed by the raw value in either decimal or hexadecimal
-format. Use @code{-} to press several keys simultaneously. Example:
+Send @var{keys} to the guest. @var{keys} could be the name of the
+key or the raw value in hexadecimal format. Use @code{-} to press
+several keys simultaneously. Example:
@example
sendkey ctrl-alt-f1
@end example
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v3 2/6] monitor: rename keyname '<' to 'less'
2012-06-20 4:47 [Qemu-devel] [PATCH v3 0/6] convert sendkey to qapi Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 1/6] fix doc of using raw values with sendkey Amos Kong
@ 2012-06-20 4:47 ` Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 3/6] hmp: rename arguments Amos Kong
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Amos Kong @ 2012-06-20 4:47 UTC (permalink / raw)
To: aliguori, eblake, berrange, lcapitulino, qemu-devel; +Cc: Amos Kong
There are many maps of keycode 0x56 in pc-bios/keymaps/*
pc-bios/keymaps/common:less 0x56
pc-bios/keymaps/common:greater 0x56 shift
pc-bios/keymaps/common:bar 0x56 altgr
pc-bios/keymaps/common:brokenbar 0x56 shift altgr
This patch just renames '<' to 'less', QAPI would add new
variable by adding a prefix to keyname, '$PREFIX_<' is not
available, '$PREFIX_less' is ok.
For compatibility, convert user inputted '<' to 'less'.
Signed-off-by: Amos Kong <akong@redhat.com>
---
monitor.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/monitor.c b/monitor.c
index f6107ba..e87677d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1431,7 +1431,7 @@ static const KeyDef key_defs[] = {
{ 0x48, "kp_8" },
{ 0x49, "kp_9" },
- { 0x56, "<" },
+ { 0x56, "less" },
{ 0x57, "f11" },
{ 0x58, "f12" },
@@ -1535,6 +1535,13 @@ static void do_sendkey(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "too many keys\n");
return;
}
+
+ /* 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;
keycode = get_keycode(keyname_buf);
if (keycode < 0) {
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v3 3/6] hmp: rename arguments
2012-06-20 4:47 [Qemu-devel] [PATCH v3 0/6] convert sendkey to qapi Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 1/6] fix doc of using raw values with sendkey Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 2/6] monitor: rename keyname '<' to 'less' Amos Kong
@ 2012-06-20 4:47 ` Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 4/6] qapi: generate list struct and visit_list for enum Amos Kong
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Amos Kong @ 2012-06-20 4:47 UTC (permalink / raw)
To: aliguori, eblake, berrange, lcapitulino, qemu-devel; +Cc: Amos Kong
Rename 'string' to 'keys', rename 'hold_time' to 'hold-time'.
Signed-off-by: Amos Kong <akong@redhat.com>
---
hmp-commands.hx | 2 +-
monitor.c | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 30243b6..e336251 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -502,7 +502,7 @@ ETEXI
{
.name = "sendkey",
- .args_type = "string:s,hold_time:i?",
+ .args_type = "keys:s,hold-time:i?",
.params = "keys [hold_ms]",
.help = "send keys to the VM (e.g. 'sendkey ctrl-alt-f1', default hold time=100 ms)",
.mhandler.cmd = do_sendkey,
diff --git a/monitor.c b/monitor.c
index e87677d..6fa0104 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1511,9 +1511,9 @@ static void do_sendkey(Monitor *mon, const QDict *qdict)
char keyname_buf[16];
char *separator;
int keyname_len, keycode, i;
- const char *string = qdict_get_str(qdict, "string");
- int has_hold_time = qdict_haskey(qdict, "hold_time");
- int hold_time = qdict_get_try_int(qdict, "hold_time", -1);
+ const char *keys = qdict_get_str(qdict, "keys");
+ int has_hold_time = qdict_haskey(qdict, "hold-time");
+ int hold_time = qdict_get_try_int(qdict, "hold-time", -1);
if (nb_pending_keycodes > 0) {
qemu_del_timer(key_timer);
@@ -1523,10 +1523,10 @@ static void do_sendkey(Monitor *mon, const QDict *qdict)
hold_time = 100;
i = 0;
while (1) {
- separator = strchr(string, '-');
- keyname_len = separator ? separator - string : strlen(string);
+ separator = strchr(keys, '-');
+ keyname_len = separator ? separator - keys : strlen(keys);
if (keyname_len > 0) {
- pstrcpy(keyname_buf, sizeof(keyname_buf), string);
+ pstrcpy(keyname_buf, sizeof(keyname_buf), keys);
if (keyname_len > sizeof(keyname_buf) - 1) {
monitor_printf(mon, "invalid key: '%s...'\n", keyname_buf);
return;
@@ -1552,7 +1552,7 @@ static void do_sendkey(Monitor *mon, const QDict *qdict)
}
if (!separator)
break;
- string = separator + 1;
+ keys = separator + 1;
}
nb_pending_keycodes = i;
/* key down events */
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v3 4/6] qapi: generate list struct and visit_list for enum
2012-06-20 4:47 [Qemu-devel] [PATCH v3 0/6] convert sendkey to qapi Amos Kong
` (2 preceding siblings ...)
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 3/6] hmp: rename arguments Amos Kong
@ 2012-06-20 4:47 ` Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 5/6] qapi: convert sendkey Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 6/6] ps2: output warning when event queue full Amos Kong
5 siblings, 0 replies; 8+ messages in thread
From: Amos Kong @ 2012-06-20 4:47 UTC (permalink / raw)
To: aliguori, eblake, berrange, lcapitulino, qemu-devel; +Cc: Amos Kong
Currently, if define an 'enum' and use it in one command's data,
List struct for enum could not be generated, but it's used in
qmp function.
For example: KeyCodesList could not be generated.
>>> qapi-schema.json:
{ 'enum': 'KeyCodes',
'data': [ 'shift', 'alt' ... ] }
{ 'command': 'sendkey',
'data': { 'keys': ['KeyCodes'], '*hold-time': 'int' } }
>>> qmp-command.h:
void qmp_sendkey(KeyCodesList * keys, bool has_hold_time, int64_t
hold_time, Error **errp);
This patch makes qapi can generate List struct for enum.
Signed-off-by: Amos Kong <akong@redhat.com>
---
scripts/qapi-types.py | 16 +++++++++++++++-
scripts/qapi-visit.py | 14 +++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 4a734f5..648eac7 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -28,6 +28,16 @@ typedef struct %(name)sList
''',
name=name)
+def generate_fwd_enum_struct(name, members):
+ return mcgen('''
+typedef struct %(name)sList
+{
+ %(name)s value;
+ struct %(name)sList *next;
+} %(name)sList;
+''',
+ name=name)
+
def generate_struct(structname, fieldname, members):
ret = mcgen('''
struct %(name)s
@@ -265,7 +275,8 @@ for expr in exprs:
if expr.has_key('type'):
ret += generate_fwd_struct(expr['type'], expr['data'])
elif expr.has_key('enum'):
- ret += generate_enum(expr['enum'], expr['data'])
+ ret += generate_enum(expr['enum'], expr['data']) + "\n"
+ ret += generate_fwd_enum_struct(expr['enum'], expr['data'])
fdef.write(generate_enum_lookup(expr['enum'], expr['data']))
elif expr.has_key('union'):
ret += generate_fwd_struct(expr['union'], expr['data']) + "\n"
@@ -289,6 +300,9 @@ for expr in exprs:
fdef.write(generate_type_cleanup(expr['union'] + "List") + "\n")
ret += generate_type_cleanup_decl(expr['union'])
fdef.write(generate_type_cleanup(expr['union']) + "\n")
+ elif expr.has_key('enum'):
+ ret += generate_type_cleanup_decl(expr['enum'] + "List")
+ fdef.write(generate_type_cleanup(expr['enum'] + "List") + "\n")
else:
continue
fdecl.write(ret)
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 8d4e94a..4d282d5 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -175,6 +175,16 @@ void visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name,
return ret
+def generate_enum_declaration(name, members, genlist=True):
+ ret = ""
+ if genlist:
+ ret += mcgen('''
+void visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name, Error **errp);
+''',
+ name=name)
+
+ return ret
+
def generate_decl_enum(name, members, genlist=True):
return mcgen('''
@@ -293,10 +303,12 @@ for expr in exprs:
ret += generate_declaration(expr['union'], expr['data'])
fdecl.write(ret)
elif expr.has_key('enum'):
- ret = generate_visit_enum(expr['enum'], expr['data'])
+ ret = generate_visit_list(expr['enum'], expr['data'])
+ ret += generate_visit_enum(expr['enum'], expr['data'])
fdef.write(ret)
ret = generate_decl_enum(expr['enum'], expr['data'])
+ ret += generate_enum_declaration(expr['enum'], expr['data'])
fdecl.write(ret)
fdecl.write('''
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v3 5/6] qapi: convert sendkey
2012-06-20 4:47 [Qemu-devel] [PATCH v3 0/6] convert sendkey to qapi Amos Kong
` (3 preceding siblings ...)
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 4/6] qapi: generate list struct and visit_list for enum Amos Kong
@ 2012-06-20 4:47 ` Amos Kong
2012-06-20 12:53 ` Eric Blake
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 6/6] ps2: output warning when event queue full Amos Kong
5 siblings, 1 reply; 8+ messages in thread
From: Amos Kong @ 2012-06-20 4:47 UTC (permalink / raw)
To: aliguori, eblake, berrange, lcapitulino, qemu-devel; +Cc: Amos Kong
Convert 'sendkey' to use QAPI. do_sendkey() depends on some
variables/functions in monitor.c, so reserve qmp_sendkey()
to monitor.c
key_defs[] in monitor.c is the mapping of key name to keycode,
Keys' order in the enmu and key_defs[] is same.
Signed-off-by: Amos Kong <akong@redhat.com>
---
hmp-commands.hx | 2 +-
hmp.c | 45 ++++++++++++++++++++++++
hmp.h | 1 +
monitor.c | 102 +++++++++++++++++++++++------------------------------
monitor.h | 2 +
qapi-schema.json | 45 ++++++++++++++++++++++++
qmp-commands.hx | 27 ++++++++++++++
7 files changed, 165 insertions(+), 59 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index e336251..fee4c14 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -505,7 +505,7 @@ ETEXI
.args_type = "keys:s,hold-time:i?",
.params = "keys [hold_ms]",
.help = "send keys to the VM (e.g. 'sendkey ctrl-alt-f1', default hold time=100 ms)",
- .mhandler.cmd = do_sendkey,
+ .mhandler.cmd = hmp_sendkey,
},
STEXI
diff --git a/hmp.c b/hmp.c
index b9cec1d..846e8b9 100644
--- a/hmp.c
+++ b/hmp.c
@@ -19,6 +19,7 @@
#include "qemu-timer.h"
#include "qmp-commands.h"
#include "monitor.h"
+#include "qapi-types.h"
static void hmp_handle_error(Monitor *mon, Error **errp)
{
@@ -1000,3 +1001,47 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)
qmp_netdev_del(id, &err);
hmp_handle_error(mon, &err);
}
+
+void hmp_sendkey(Monitor *mon, const QDict *qdict)
+{
+ const char *keys = qdict_get_str(qdict, "keys");
+ KeyCodesList *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;
+
+ 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;
+
+ keylist = g_malloc0(sizeof(*keylist));
+ keylist->value = get_key_index(keyname_buf);
+ keylist->next = NULL;
+
+ if (tmp)
+ tmp->next = keylist;
+ tmp = keylist;
+ if (!head)
+ head = keylist;
+
+ if (!separator)
+ break;
+ keys = separator + 1;
+ }
+
+ qmp_sendkey(head, has_hold_time, hold_time, &err);
+ hmp_handle_error(mon, &err);
+ qapi_free_KeyCodesList(head);
+}
diff --git a/hmp.h b/hmp.h
index 79d138d..bcc74d2 100644
--- a/hmp.h
+++ b/hmp.h
@@ -64,5 +64,6 @@ void hmp_device_del(Monitor *mon, const QDict *qdict);
void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict);
void hmp_netdev_add(Monitor *mon, const QDict *qdict);
void hmp_netdev_del(Monitor *mon, const QDict *qdict);
+void hmp_sendkey(Monitor *mon, const QDict *qdict);
#endif
diff --git a/monitor.c b/monitor.c
index 6fa0104..863c0c6 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1470,98 +1470,84 @@ static const KeyDef key_defs[] = {
{ 0, NULL },
};
-static int get_keycode(const char *key)
+int get_key_index(const char *key)
{
- const KeyDef *p;
+ int i, keycode;
char *endp;
- int ret;
+ const KeyDef *p;
- for(p = key_defs; p->name != NULL; p++) {
- if (!strcmp(key, p->name))
- return p->keycode;
+ for (i = 0; KeyCodes_lookup[i] != NULL; i++) {
+ if (!strcmp(key, KeyCodes_lookup[i]))
+ return i;
}
+
if (strstart(key, "0x", NULL)) {
- ret = strtoul(key, &endp, 0);
- if (*endp == '\0' && ret >= 0x01 && ret <= 0xff)
- return ret;
+ keycode = strtoul(key, &endp, 0);
+ if (*endp == '\0' && keycode >= 0x01 && keycode <= 0xff)
+ i = 0;
+ for (p = key_defs; p->name != NULL; p++) {
+ if (keycode == p->keycode)
+ return i;
+ i++;
+ }
}
+
return -1;
}
-#define MAX_KEYCODES 16
-static uint8_t keycodes[MAX_KEYCODES];
-static int nb_pending_keycodes;
+static KeyCodesList *keycodes;
static QEMUTimer *key_timer;
static void release_keys(void *opaque)
{
int keycode;
- while (nb_pending_keycodes > 0) {
- nb_pending_keycodes--;
- keycode = keycodes[nb_pending_keycodes];
+ while (keycodes != NULL) {
+ if (keycodes->value > sizeof(key_defs) / sizeof(*(key_defs))) {
+ keycodes = NULL;
+ break;
+ }
+
+ keycode = key_defs[keycodes->value].keycode;
if (keycode & 0x80)
kbd_put_keycode(0xe0);
kbd_put_keycode(keycode | 0x80);
+
+ keycodes = keycodes->next;
}
}
-static void do_sendkey(Monitor *mon, const QDict *qdict)
+void qmp_sendkey(KeyCodesList *keys, bool has_hold_time, int64_t hold_time,
+ Error **errp)
{
- char keyname_buf[16];
- char *separator;
- int keyname_len, keycode, i;
- const char *keys = qdict_get_str(qdict, "keys");
- int has_hold_time = qdict_haskey(qdict, "hold-time");
- int hold_time = qdict_get_try_int(qdict, "hold-time", -1);
+ int keycode;
+ char value[5];
- if (nb_pending_keycodes > 0) {
+ if (keycodes != NULL) {
qemu_del_timer(key_timer);
release_keys(NULL);
}
if (!has_hold_time)
hold_time = 100;
- i = 0;
- while (1) {
- separator = strchr(keys, '-');
- keyname_len = separator ? separator - keys : strlen(keys);
- if (keyname_len > 0) {
- pstrcpy(keyname_buf, sizeof(keyname_buf), keys);
- if (keyname_len > sizeof(keyname_buf) - 1) {
- monitor_printf(mon, "invalid key: '%s...'\n", keyname_buf);
- return;
- }
- if (i == MAX_KEYCODES) {
- monitor_printf(mon, "too many keys\n");
- return;
- }
-
- /* 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;
- keycode = get_keycode(keyname_buf);
- if (keycode < 0) {
- monitor_printf(mon, "unknown key: '%s'\n", keyname_buf);
- return;
- }
- keycodes[i++] = keycode;
+ keycodes = keys;
+ while (keycodes != NULL) {
+ if (keycodes->value > sizeof(key_defs) / sizeof(*(key_defs))) {
+ sprintf(value, "%d", keycodes->value);
+ error_set(errp, QERR_INVALID_PARAMETER, value);
+ return;
}
- if (!separator)
- break;
- keys = separator + 1;
- }
- nb_pending_keycodes = i;
- /* key down events */
- for (i = 0; i < nb_pending_keycodes; i++) {
- keycode = keycodes[i];
+
+ /* key down events */
+ keycode = key_defs[keycodes->value].keycode;
if (keycode & 0x80)
kbd_put_keycode(0xe0);
kbd_put_keycode(keycode & 0x7f);
+
+ keycodes = keycodes->next;
}
+ keycodes = keys;
+
/* delayed key up events */
qemu_mod_timer(key_timer, qemu_get_clock_ns(vm_clock) +
muldiv64(get_ticks_per_sec(), hold_time, 1000));
diff --git a/monitor.h b/monitor.h
index 5f4de1b..1723622 100644
--- a/monitor.h
+++ b/monitor.h
@@ -86,4 +86,6 @@ int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret);
int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret);
+int get_key_index(const char *key);
+
#endif /* !MONITOR_H */
diff --git a/qapi-schema.json b/qapi-schema.json
index 3b6e346..5717467 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1862,3 +1862,48 @@
# Since: 0.14.0
##
{ 'command': 'netdev_del', 'data': {'id': 'str'} }
+
+##
+# @KeyCodes:
+#
+# An enumeration of key name.
+#
+# This is used by the sendkey command.
+#
+# Since: 1.2
+##
+{ 'enum': 'KeyCodes',
+ 'data': [ 'shift', 'shift_r', 'alt', 'alt_r', 'altgr', 'altgr_r', 'ctrl',
+ 'ctrl_r', 'menu', 'esc', '1', '2', '3', '4', '5', '6', '7', '8',
+ '9', '0', 'minus', 'equal', 'backspace', 'tab', 'q', 'w', 'e',
+ 'r', 't', 'y', 'u', 'i', 'o', 'p', 'bracket_left', 'bracket_right',
+ 'ret', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'semicolon',
+ 'apostrophe', 'grave_accent', 'backslash', 'z', 'x', 'c', 'v', 'b',
+ 'n', 'm', 'comma', 'dot', 'slash', 'asterisk', 'spc', 'caps_lock',
+ 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10',
+ 'num_lock', 'scroll_lock', 'kp_divide', 'kp_multiply',
+ 'kp_subtract', 'kp_add', 'kp_enter', 'kp_decimal', 'sysrq', 'kp_0',
+ 'kp_1', 'kp_2', 'kp_3', 'kp_4', 'kp_5', 'kp_6', 'kp_7', 'kp_8',
+ 'kp_9', 'less', 'f11', 'f12', 'print', 'home', 'pgup', 'pgdn', 'end',
+ 'left', 'up', 'down', 'right', 'insert', 'delete', 'stop', 'again',
+ 'props', 'undo', 'front', 'copy', 'open', 'paste', 'find', 'cut',
+ 'lf', 'help', 'meta_l', 'meta_r', 'compose' ] }
+
+##
+# @sendkey:
+#
+# Send keys to VM.
+#
+# @keys: key sequence
+# @hold-time: time to delay key up events, milliseconds
+#
+# Returns: Nothing on success
+# If key is unknown or redundant, QERR_INVALID_PARAMETER
+#
+# Notes: Send keys to the guest. 'keys' could be the name of the
+# key. Use a JSON array to press several keys simultaneously.
+#
+# Since: 1.2
+##
+{ 'command': 'sendkey',
+ 'data': { 'keys': ['KeyCodes'], '*hold-time': 'int' } }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 2e1a38e..bcc6c4b 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -335,6 +335,33 @@ Example:
EQMP
{
+ .name = "sendkey",
+ .args_type = "keys:O,hold-time:i?",
+ .mhandler.cmd_new = qmp_marshal_input_sendkey,
+ },
+
+SQMP
+sendkey
+----------
+
+Send keys to VM.
+
+Arguments:
+
+keys array:
+ - "key": key sequence (json-string)
+
+- hold-time: time to delay key up events, milliseconds (josn-int, optional)
+
+Example:
+
+-> { "execute": "sendkey",
+ "arguments": { 'keys': [ 'ctrl', 'alt', 'delete' ] } }
+<- { "return": {} }
+
+EQMP
+
+ {
.name = "cpu",
.args_type = "index:i",
.mhandler.cmd_new = qmp_marshal_input_cpu,
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v3 6/6] ps2: output warning when event queue full
2012-06-20 4:47 [Qemu-devel] [PATCH v3 0/6] convert sendkey to qapi Amos Kong
` (4 preceding siblings ...)
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 5/6] qapi: convert sendkey Amos Kong
@ 2012-06-20 4:47 ` Amos Kong
5 siblings, 0 replies; 8+ messages in thread
From: Amos Kong @ 2012-06-20 4:47 UTC (permalink / raw)
To: aliguori, eblake, berrange, lcapitulino, qemu-devel; +Cc: Amos Kong
Event would be ignored if ps2 queue is full, this patch
added a warning in ignore path.
Signed-off-by: Amos Kong <akong@redhat.com>
---
hw/ps2.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/hw/ps2.c b/hw/ps2.c
index f93cd24..799c36b 100644
--- a/hw/ps2.c
+++ b/hw/ps2.c
@@ -137,8 +137,10 @@ void ps2_queue(void *opaque, int b)
PS2State *s = (PS2State *)opaque;
PS2Queue *q = &s->queue;
- if (q->count >= PS2_QUEUE_SIZE)
+ if (q->count >= PS2_QUEUE_SIZE) {
+ fprintf(stderr, "ps2: warning: event queue full\n");
return;
+ }
q->data[q->wptr] = b;
if (++q->wptr == PS2_QUEUE_SIZE)
q->wptr = 0;
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v3 5/6] qapi: convert sendkey
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 5/6] qapi: convert sendkey Amos Kong
@ 2012-06-20 12:53 ` Eric Blake
0 siblings, 0 replies; 8+ messages in thread
From: Eric Blake @ 2012-06-20 12:53 UTC (permalink / raw)
To: Amos Kong; +Cc: aliguori, qemu-devel, lcapitulino
[-- Attachment #1: Type: text/plain, Size: 1243 bytes --]
On 06/19/2012 10:47 PM, Amos Kong wrote:
> Convert 'sendkey' to use QAPI. do_sendkey() depends on some
> variables/functions in monitor.c, so reserve qmp_sendkey()
> to monitor.c
>
> key_defs[] in monitor.c is the mapping of key name to keycode,
> Keys' order in the enmu and key_defs[] is same.
>
The interface looks like we have settled into something useful that
libvirt can live with. I will leave a more thorough review of the
series to those more familiar with qemu's internals. However, as long
as we are fine-tuning things, I have some questions that might be worth
one more spin:
> +##
> +# @sendkey:
Should this be named 'send-key', given that most QMP commands separate
words with '-' rather than squasheverythingtogether?
> +SQMP
> +sendkey
> +----------
> +
> +Send keys to VM.
> +
> +Arguments:
> +
> +keys array:
> + - "key": key sequence (json-string)
I'm not sure if json-string is the right designation any more. Rather,
it is a json-array of key enum values.
> +
> +- hold-time: time to delay key up events, milliseconds (josn-int, optional)
s/josn/json/
--
Eric Blake eblake@redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-06-20 12:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-20 4:47 [Qemu-devel] [PATCH v3 0/6] convert sendkey to qapi Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 1/6] fix doc of using raw values with sendkey Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 2/6] monitor: rename keyname '<' to 'less' Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 3/6] hmp: rename arguments Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 4/6] qapi: generate list struct and visit_list for enum Amos Kong
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 5/6] qapi: convert sendkey Amos Kong
2012-06-20 12:53 ` Eric Blake
2012-06-20 4:47 ` [Qemu-devel] [PATCH v3 6/6] ps2: output warning when event queue full Amos Kong
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).