From patchwork Fri Jun 3 07:04:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 9151963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 63BE56074E for ; Fri, 3 Jun 2016 07:13:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55A2E26C9B for ; Fri, 3 Jun 2016 07:13:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A51928309; Fri, 3 Jun 2016 07:13:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.9 required=2.0 tests=BAYES_00,FSL_HELO_HOME, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E281126C9B for ; Fri, 3 Jun 2016 07:12:56 +0000 (UTC) Received: from localhost ([::1]:52433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8jHq-0002oA-Q2 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 03 Jun 2016 03:12:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8j9w-0003pq-Cg for qemu-devel@nongnu.org; Fri, 03 Jun 2016 03:04:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8j9o-0006PV-Sa for qemu-devel@nongnu.org; Fri, 03 Jun 2016 03:04:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8j9o-0006Oh-Ke for qemu-devel@nongnu.org; Fri, 03 Jun 2016 03:04:36 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3D96E80084 for ; Fri, 3 Jun 2016 07:04:36 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-36.ams2.redhat.com [10.36.116.36]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5374Yx8007106; Fri, 3 Jun 2016 03:04:35 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 8B93A81B35; Fri, 3 Jun 2016 09:04:30 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 3 Jun 2016 09:04:28 +0200 Message-Id: <1464937468-14816-8-git-send-email-kraxel@redhat.com> In-Reply-To: <1464937468-14816-1-git-send-email-kraxel@redhat.com> References: <1464937468-14816-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 03 Jun 2016 07:04:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/7] vnc: add configurable keyboard delay X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Limits the rate kbd events from the vnc server are forwarded to the guest, so input devices which are typically low-bandwidth can keep up even on bulky input. v2: update documentation too. v3: spell fixes. Signed-off-by: Gerd Hoffmann Tested-by: Yang Hongyang Message-id: 1464762150-25817-1-git-send-email-kraxel@redhat.com --- qemu-options.hx | 8 ++++++++ ui/vnc.c | 13 +++++++++++-- ui/vnc.h | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 6106520..9f33361 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1410,6 +1410,14 @@ everybody else. 'ignore' completely ignores the shared flag and allows everybody connect unconditionally. Doesn't conform to the rfb spec but is traditional QEMU behavior. +@item key-delay-ms + +Set keyboard delay, for key down and key up events, in milliseconds. +Default is 1. Keyboards are low-bandwidth devices, so this slowdown +can help the device and guest to keep up and not lose events in case +events are arriving in bulk. Possible causes for the latter are flaky +network connections, or scripts for automated testing. + @end table ETEXI diff --git a/ui/vnc.c b/ui/vnc.c index ddd01fd..c862fdc 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1629,6 +1629,7 @@ static void reset_keys(VncState *vs) for(i = 0; i < 256; i++) { if (vs->modifiers_state[i]) { qemu_input_event_send_key_number(vs->vd->dcl.con, i, false); + qemu_input_event_send_key_delay(vs->vd->key_delay_ms); vs->modifiers_state[i] = 0; } } @@ -1638,9 +1639,9 @@ static void press_key(VncState *vs, int keysym) { int keycode = keysym2scancode(vs->vd->kbd_layout, keysym) & SCANCODE_KEYMASK; qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, true); - qemu_input_event_send_key_delay(0); + qemu_input_event_send_key_delay(vs->vd->key_delay_ms); qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, false); - qemu_input_event_send_key_delay(0); + qemu_input_event_send_key_delay(vs->vd->key_delay_ms); } static int current_led_state(VncState *vs) @@ -1792,6 +1793,7 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) if (qemu_console_is_graphic(NULL)) { qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, down); + qemu_input_event_send_key_delay(vs->vd->key_delay_ms); } else { bool numlock = vs->modifiers_state[0x45]; bool control = (vs->modifiers_state[0x1d] || @@ -1913,6 +1915,7 @@ static void vnc_release_modifiers(VncState *vs) continue; } qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, false); + qemu_input_event_send_key_delay(vs->vd->key_delay_ms); } } @@ -3278,6 +3281,9 @@ static QemuOptsList qemu_vnc_opts = { .name = "lock-key-sync", .type = QEMU_OPT_BOOL, },{ + .name = "key-delay-ms", + .type = QEMU_OPT_NUMBER, + },{ .name = "sasl", .type = QEMU_OPT_BOOL, },{ @@ -3515,6 +3521,7 @@ void vnc_display_open(const char *id, Error **errp) #endif int acl = 0; int lock_key_sync = 1; + int key_delay_ms; if (!vs) { error_setg(errp, "VNC display not active"); @@ -3633,6 +3640,7 @@ void vnc_display_open(const char *id, Error **errp) reverse = qemu_opt_get_bool(opts, "reverse", false); lock_key_sync = qemu_opt_get_bool(opts, "lock-key-sync", true); + key_delay_ms = qemu_opt_get_number(opts, "key-delay-ms", 1); sasl = qemu_opt_get_bool(opts, "sasl", false); #ifndef CONFIG_VNC_SASL if (sasl) { @@ -3764,6 +3772,7 @@ void vnc_display_open(const char *id, Error **errp) } #endif vs->lock_key_sync = lock_key_sync; + vs->key_delay_ms = key_delay_ms; device_id = qemu_opt_get(opts, "display"); if (device_id) { diff --git a/ui/vnc.h b/ui/vnc.h index 81a3261..6568bca 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -155,6 +155,7 @@ struct VncDisplay DisplayChangeListener dcl; kbd_layout_t *kbd_layout; int lock_key_sync; + int key_delay_ms; QemuMutex mutex; QEMUCursor *cursor;