From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lai Jiangshan Subject: [PATCH 6/6] qemu,qmp: Convert do_sendkey() to QObject,QError Date: Thu, 09 Dec 2010 14:59:40 +0800 Message-ID: <4D007E5C.4070003@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit To: Luiz Capitulino , qemu-devel@nongnu.org, kvm@vger.kernel.org Return-path: Received: from cn.fujitsu.com ([222.73.24.84]:59098 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1755054Ab0LIG4k (ORCPT ); Thu, 9 Dec 2010 01:56:40 -0500 Sender: kvm-owner@vger.kernel.org List-ID: Convert do_sendkey() to QObject,QError, we need to use it.(via libvirt) It is a trivial conversion, carefully converted the error reports. Signed-off-by: Lai Jiangshan --- diff --git a/hmp-commands.hx b/hmp-commands.hx index 23024ba..7a49b74 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -436,7 +436,8 @@ ETEXI .args_type = "string: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, + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_sendkey, }, STEXI diff --git a/monitor.c b/monitor.c index ec31eac..729a7cb 100644 --- a/monitor.c +++ b/monitor.c @@ -1678,7 +1678,7 @@ static void release_keys(void *opaque) } } -static void do_sendkey(Monitor *mon, const QDict *qdict) +static int do_sendkey(Monitor *mon, const QDict *qdict, QObject **ret_data) { char keyname_buf[16]; char *separator; @@ -1700,18 +1700,18 @@ static void do_sendkey(Monitor *mon, const QDict *qdict) if (keyname_len > 0) { pstrcpy(keyname_buf, sizeof(keyname_buf), string); if (keyname_len > sizeof(keyname_buf) - 1) { - monitor_printf(mon, "invalid key: '%s...'\n", keyname_buf); - return; + qerror_report(QERR_INVALID_KEY, keyname_buf); + return -1; } if (i == MAX_KEYCODES) { - monitor_printf(mon, "too many keys\n"); - return; + qerror_report(QERR_TOO_MANY_KEYS); + return -1; } keyname_buf[keyname_len] = 0; keycode = get_keycode(keyname_buf); if (keycode < 0) { - monitor_printf(mon, "unknown key: '%s'\n", keyname_buf); - return; + qerror_report(QERR_UNKNOWN_KEY, keyname_buf); + return -1; } keycodes[i++] = keycode; } @@ -1730,6 +1730,7 @@ static void do_sendkey(Monitor *mon, const QDict *qdict) /* delayed key up events */ qemu_mod_timer(key_timer, qemu_get_clock(vm_clock) + muldiv64(get_ticks_per_sec(), hold_time, 1000)); + return 0; } static int mouse_button_state; diff --git a/qmp-commands.hx b/qmp-commands.hx index e5f157f..a385b66 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -225,6 +225,30 @@ Example: <- { "return": {} } EQMP + { + .name = "sendkey", + .args_type = "string: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)", + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_sendkey, + }, + +SQMP +@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: +@example +sendkey ctrl-alt-f1 +@end example + +This command is useful to send keys that your graphical user interface +intercepts at low level, such as @code{ctrl-alt-f1} in X Window. + +EQMP { .name = "system_reset", From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53473 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQaQt-0007Ma-9H for qemu-devel@nongnu.org; Thu, 09 Dec 2010 01:56:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PQaQn-0000Gp-RP for qemu-devel@nongnu.org; Thu, 09 Dec 2010 01:56:51 -0500 Received: from [222.73.24.84] (port=56990 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PQaQn-0000GJ-3P for qemu-devel@nongnu.org; Thu, 09 Dec 2010 01:56:45 -0500 Message-ID: <4D007E5C.4070003@cn.fujitsu.com> Date: Thu, 09 Dec 2010 14:59:40 +0800 From: Lai Jiangshan MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8 Subject: [Qemu-devel] [PATCH 6/6] qemu, qmp: Convert do_sendkey() to QObject, QError List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino , qemu-devel@nongnu.org, kvm@vger.kernel.org Convert do_sendkey() to QObject,QError, we need to use it.(via libvirt) It is a trivial conversion, carefully converted the error reports. Signed-off-by: Lai Jiangshan --- diff --git a/hmp-commands.hx b/hmp-commands.hx index 23024ba..7a49b74 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -436,7 +436,8 @@ ETEXI .args_type = "string: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, + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_sendkey, }, STEXI diff --git a/monitor.c b/monitor.c index ec31eac..729a7cb 100644 --- a/monitor.c +++ b/monitor.c @@ -1678,7 +1678,7 @@ static void release_keys(void *opaque) } } -static void do_sendkey(Monitor *mon, const QDict *qdict) +static int do_sendkey(Monitor *mon, const QDict *qdict, QObject **ret_data) { char keyname_buf[16]; char *separator; @@ -1700,18 +1700,18 @@ static void do_sendkey(Monitor *mon, const QDict *qdict) if (keyname_len > 0) { pstrcpy(keyname_buf, sizeof(keyname_buf), string); if (keyname_len > sizeof(keyname_buf) - 1) { - monitor_printf(mon, "invalid key: '%s...'\n", keyname_buf); - return; + qerror_report(QERR_INVALID_KEY, keyname_buf); + return -1; } if (i == MAX_KEYCODES) { - monitor_printf(mon, "too many keys\n"); - return; + qerror_report(QERR_TOO_MANY_KEYS); + return -1; } keyname_buf[keyname_len] = 0; keycode = get_keycode(keyname_buf); if (keycode < 0) { - monitor_printf(mon, "unknown key: '%s'\n", keyname_buf); - return; + qerror_report(QERR_UNKNOWN_KEY, keyname_buf); + return -1; } keycodes[i++] = keycode; } @@ -1730,6 +1730,7 @@ static void do_sendkey(Monitor *mon, const QDict *qdict) /* delayed key up events */ qemu_mod_timer(key_timer, qemu_get_clock(vm_clock) + muldiv64(get_ticks_per_sec(), hold_time, 1000)); + return 0; } static int mouse_button_state; diff --git a/qmp-commands.hx b/qmp-commands.hx index e5f157f..a385b66 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -225,6 +225,30 @@ Example: <- { "return": {} } EQMP + { + .name = "sendkey", + .args_type = "string: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)", + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_sendkey, + }, + +SQMP +@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: +@example +sendkey ctrl-alt-f1 +@end example + +This command is useful to send keys that your graphical user interface +intercepts at low level, such as @code{ctrl-alt-f1} in X Window. + +EQMP { .name = "system_reset",