From nobody Thu May 2 22:27:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508750690797417.0673951098571; Mon, 23 Oct 2017 02:24:50 -0700 (PDT) Received: from localhost ([::1]:37646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6YyR-0001AT-5a for importer@patchew.org; Mon, 23 Oct 2017 05:24:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Ytp-0005y3-3e for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6Ytl-0005Yq-US for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58178) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6Ytl-0005Ya-Nk for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D23EF2D0FA3 for ; Mon, 23 Oct 2017 09:19:52 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCCB84251; Mon, 23 Oct 2017 09:19:49 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B9854278; Mon, 23 Oct 2017 11:19:47 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D23EF2D0FA3 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 11:19:39 +0200 Message-Id: <20171023091947.20771-2-kraxel@redhat.com> In-Reply-To: <20171023091947.20771-1-kraxel@redhat.com> References: <20171023091947.20771-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 23 Oct 2017 09:19:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/9] input: use hex in ps2 keycode trace events 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Hardware scancodes are all documented in hex, so use that in trace events to make it easier to understand. Signed-off-by: Daniel P. Berrange Reviewed-by: Eric Blake Message-id: 20171019142848.572-2-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- hw/input/trace-events | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/input/trace-events b/hw/input/trace-events index 6fcb3c063f..d04132d342 100644 --- a/hw/input/trace-events +++ b/hw/input/trace-events @@ -1,7 +1,7 @@ # See docs/devel/tracing.txt for syntax documentation. =20 # hw/input/ps2.c -ps2_put_keycode(void *opaque, int keycode) "%p keycode %d" +ps2_put_keycode(void *opaque, int keycode) "%p keycode 0x%02x" ps2_read_data(void *opaque) "%p" ps2_set_ledstate(void *s, int ledstate) "%p ledstate %d" ps2_reset_keyboard(void *s) "%p" --=20 2.9.3 From nobody Thu May 2 22:27:43 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508750519451749.7866073138166; Mon, 23 Oct 2017 02:21:59 -0700 (PDT) Received: from localhost ([::1]:37634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Yvh-0007Dw-Hd for importer@patchew.org; Mon, 23 Oct 2017 05:21:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Ytp-0005y5-4G for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6Ytl-0005Yf-Dn for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58058) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6Ytl-0005YI-7b for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A5DE2D0FAE for ; Mon, 23 Oct 2017 09:19:52 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id C28E97767D; Mon, 23 Oct 2017 09:19:49 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C0DAE4FD7C; Mon, 23 Oct 2017 11:19:47 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5A5DE2D0FAE Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 11:19:40 +0200 Message-Id: <20171023091947.20771-3-kraxel@redhat.com> In-Reply-To: <20171023091947.20771-1-kraxel@redhat.com> References: <20171023091947.20771-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 23 Oct 2017 09:19:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/9] ui: fix crash with sendkey and raw key numbers 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Previously we enforced that all key events are using QKeyCodes at time they are sent: commit af07e5ff02ae6d4258fc5331007811d0b1c4d35a Author: Daniel P. Berrange Date: Fri Sep 29 11:12:00 2017 +0100 ui: convert key events to QKeyCodes immediately This commit forget to fix the code for the legacy 'sendkey' command which still accepts key numbers from the user, which then need converting to QKeyCodes Signed-off-by: Daniel P. Berrange Reviewed-by: Eric Blake Message-id: 20171019142848.572-3-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- ui/input-legacy.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/input-legacy.c b/ui/input-legacy.c index 6bc3525499..c75aba1549 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -76,6 +76,11 @@ static KeyValue *copy_key_value(KeyValue *src) { KeyValue *dst =3D g_new(KeyValue, 1); memcpy(dst, src, sizeof(*src)); + if (dst->type =3D=3D KEY_VALUE_KIND_NUMBER) { + QKeyCode code =3D qemu_input_key_number_to_qcode(dst->u.number.dat= a); + dst->type =3D KEY_VALUE_KIND_QCODE; + dst->u.qcode.data =3D code; + } return dst; } =20 --=20 2.9.3 From nobody Thu May 2 22:27:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508750820455181.15580170144176; Mon, 23 Oct 2017 02:27:00 -0700 (PDT) Received: from localhost ([::1]:37659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Z0Y-00039G-L2 for importer@patchew.org; Mon, 23 Oct 2017 05:26:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Ytp-0005y2-3v for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6Ytl-0005YW-42 for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57956) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6Ytk-0005Y9-Ta for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04D582D0FB1 for ; Mon, 23 Oct 2017 09:19:52 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4E9C5DA67; Mon, 23 Oct 2017 09:19:49 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C801E4FD7D; Mon, 23 Oct 2017 11:19:47 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 04D582D0FB1 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 11:19:41 +0200 Message-Id: <20171023091947.20771-4-kraxel@redhat.com> In-Reply-To: <20171023091947.20771-1-kraxel@redhat.com> References: <20171023091947.20771-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 23 Oct 2017 09:19:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/9] ui: use correct union field for key number 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The code converting key numbers to QKeyCode in the 'input-send-event' command mistakenly accessed the key->u.qcode union field instead of the key->u.number field. This is harmless because the fields use the same size datatype in both cases, but none the less it should be fixed to avoid confusion. Signed-off-by: Daniel P. Berrange Reviewed-by: Eric Blake Message-id: 20171019142848.572-4-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- ui/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/input.c b/ui/input.c index 290b47354a..4e821f8f2b 100644 --- a/ui/input.c +++ b/ui/input.c @@ -162,7 +162,7 @@ void qmp_input_send_event(bool has_device, const char *= device, if (evt->type =3D=3D INPUT_EVENT_KIND_KEY && evt->u.key.data->key->type =3D=3D KEY_VALUE_KIND_NUMBER) { KeyValue *key =3D evt->u.key.data->key; - QKeyCode code =3D qemu_input_key_number_to_qcode(key->u.qcode.= data); + QKeyCode code =3D qemu_input_key_number_to_qcode(key->u.number= .data); qemu_input_event_send_key_qcode(con, code, evt->u.key.data->do= wn); } else { qemu_input_event_send(con, evt); --=20 2.9.3 From nobody Thu May 2 22:27:43 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508750843133365.8640825753988; Mon, 23 Oct 2017 02:27:23 -0700 (PDT) Received: from localhost ([::1]:37660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Z0b-0003Cz-66 for importer@patchew.org; Mon, 23 Oct 2017 05:26:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Ytp-0005y4-3n for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6Ytm-0005Yx-Ib for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23514) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6Ytm-0005Yk-8z for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 604455D9E7 for ; Mon, 23 Oct 2017 09:19:53 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB2F979838; Mon, 23 Oct 2017 09:19:49 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D6A024FD7E; Mon, 23 Oct 2017 11:19:47 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 604455D9E7 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 11:19:42 +0200 Message-Id: <20171023091947.20771-5-kraxel@redhat.com> In-Reply-To: <20171023091947.20771-1-kraxel@redhat.com> References: <20171023091947.20771-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 23 Oct 2017 09:19:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/9] ps2: fix scancodes sent for Alt-Print key combination (aka SysRq) 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The 'Print' key is special in the AT set 1 / set 2 scancode definitions. An unmodified 'Print' key is supposed to send AT Set 1: e0 2a e0 37 (Down) e0 b7 e0 aa (Up) AT Set 2: e0 12 e0 7c (Down) e0 f0 7c e0 f0 12 (Up) which QEMU gets right. When pressed in combination with the 'Alt_L' or 'Alt= _R' keys (which signify SysRq), the scancodes are required to follow a different scheme. With Alt_L, the expected sequences are AT set 1: 38, 54 (Down) d4, b8 (Up) AT set 2: 11, 84 (Down) f0 84, f0 11 (Up) And with Alt_R AT set 1: e0 38, 54 (Down) d4, e0 b8 (Up) AT set 2: e0 11, 84 (Down) f0 84, f0 e0 11 (Up) It is actually slightly more complicated than that, because (according resu= lts of 'showkey -s', keyboards will in fact first release the currently pressed modifier before sending the sequence above (which effectively re-presses & then releases the modifier) and finally re-press the original modifier afterwards. IOW, with Alt_L we need to send AT set 1: b8, 38, 54 (Down) d4, b8, 38 (Up) AT set 2: f0 11, 11, 84 (Down) f0 84, f0 11, 11 (Up) And with Alt_R AT set 1: e0 b8, e0 38, 54 (Down) d4, e0 b8, e0 38 (Up) AT set 2: e0 f0 11, e0 11, 84 (Down) f0 84, e0 f0 11, e0 11 (Up) The AT set 3 scancodes have no special handling for Alt-Print. Rather than fixing the handling of the 'print' key in the ps2 driver to con= sider the Alt modifiers, way back, a patch was commited that defined an extra 'sy= srq' key name: commit f2289cb6924afc97b2a75d21bfc9217024d11741 Author: balrog Date: Wed Jun 4 10:14:16 2008 +0000 Add sysrq to key names known by "sendkey". Adding sysrq keycode to the table enabling running sysrq debugging in the guest via the monitor sendkey command, like: (qemu) sendkey alt-sysrq-t Tested on x86-64 target and Linux guest. Signed-off-by: Ryan Harper With this patch QEMU would send AT set 1: 38, 54 (Down) d4, b8 (Up) AT set 2: 11, 84 (Down) f0 84, f0 11 (Up) but this doesn't match what actual real keyboards send, as it is not releas= ing the original modifier & pressing it again afterwards. In addition the origi= nal problem remains, and a new problem was added: - The sequence 'alt-print-t' is still broken, acting as if 'print-t' was requested - The sequence 'sysrq-t' is broken, injecting an undefine scancode sequen= ce tot he guest os (bare 0x54) To deal with this mess we make these changes to the ps2 code, so that we tr= ack the state of modifier keys (Alt, Shift, Ctrl - both left & right). Then we = can vary what scancodes are sent for Q_KEY_CODE_PRINT according to the Alt key modifier state Interestingly, it appears that of operating systems I've checked (Linux, Fr= eeBSD and OpenSolaris), none of them actually bother to validate the full sequenc= es for a unmodified 'Print' key. They all just ignore the leading "e0 2a" and trigger based off "e0 37" alone. The latter two byte sequence is what keybo= ards send with 'Print' is combined with 'Shift' or 'Ctrl' modifiers. Signed-off-by: Daniel P. Berrange Message-id: 20171019142848.572-5-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 137 ++++++++++++++++++++++++++++++++++++++++++----= ---- hw/input/trace-events | 1 + 2 files changed, 118 insertions(+), 20 deletions(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index dff3f1e024..1e6f6ae9b6 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -78,6 +78,14 @@ =20 #define PS2_QUEUE_SIZE 16 /* Buffer size required by PS/2 protocol */ =20 +/* Bits for 'modifiers' field in PS2KbdState */ +#define MOD_CTRL_L (1 << 0) +#define MOD_SHIFT_L (1 << 1) +#define MOD_ALT_L (1 << 2) +#define MOD_CTRL_R (1 << 3) +#define MOD_SHIFT_R (1 << 4) +#define MOD_ALT_R (1 << 5) + typedef struct { /* Keep the data array 256 bytes long, which compatibility with older qemu versions. */ @@ -99,6 +107,7 @@ typedef struct { int scancode_set; /* 1=3DXT, 2=3DAT, 3=3DPS/2 */ int ledstate; bool need_high_bit; + unsigned int modifiers; /* bitmask of MOD_* constants above */ } PS2KbdState; =20 typedef struct { @@ -545,6 +554,26 @@ static uint8_t translate_table[256] =3D { 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, }; =20 +static unsigned int ps2_modifier_bit(QKeyCode key) +{ + switch (key) { + case Q_KEY_CODE_CTRL: + return MOD_CTRL_L; + case Q_KEY_CODE_CTRL_R: + return MOD_CTRL_R; + case Q_KEY_CODE_SHIFT: + return MOD_SHIFT_L; + case Q_KEY_CODE_SHIFT_R: + return MOD_SHIFT_R; + case Q_KEY_CODE_ALT: + return MOD_ALT_L; + case Q_KEY_CODE_ALT_R: + return MOD_ALT_R; + default: + return 0; + } +} + static void ps2_reset_queue(PS2State *s) { PS2Queue *q =3D &s->queue; @@ -596,11 +625,20 @@ static void ps2_keyboard_event(DeviceState *dev, Qemu= Console *src, InputKeyEvent *key =3D evt->u.key.data; int qcode; uint16_t keycode; + int mod; =20 qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); assert(evt->type =3D=3D INPUT_EVENT_KIND_KEY); qcode =3D qemu_input_key_value_to_qcode(key->key); =20 + mod =3D ps2_modifier_bit(qcode); + trace_ps2_keyboard_event(s, qcode, key->down, mod, s->modifiers); + if (key->down) { + s->modifiers |=3D mod; + } else { + s->modifiers &=3D ~mod; + } + if (s->scancode_set =3D=3D 1) { if (qcode =3D=3D Q_KEY_CODE_PAUSE) { if (key->down) { @@ -612,16 +650,42 @@ static void ps2_keyboard_event(DeviceState *dev, Qemu= Console *src, ps2_put_keycode(s, 0xc5); } } else if (qcode =3D=3D Q_KEY_CODE_PRINT) { - if (key->down) { - ps2_put_keycode(s, 0xe0); - ps2_put_keycode(s, 0x2a); - ps2_put_keycode(s, 0xe0); - ps2_put_keycode(s, 0x37); + if (s->modifiers & MOD_ALT_L) { + if (key->down) { + ps2_put_keycode(s, 0xb8); + ps2_put_keycode(s, 0x38); + ps2_put_keycode(s, 0x54); + } else { + ps2_put_keycode(s, 0xd4); + ps2_put_keycode(s, 0xb8); + ps2_put_keycode(s, 0x38); + } + } else if (s->modifiers & MOD_ALT_R) { + if (key->down) { + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0xb8); + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0x38); + ps2_put_keycode(s, 0x54); + } else { + ps2_put_keycode(s, 0xd4); + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0xb8); + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0x38); + } } else { - ps2_put_keycode(s, 0xe0); - ps2_put_keycode(s, 0xb7); - ps2_put_keycode(s, 0xe0); - ps2_put_keycode(s, 0xaa); + if (key->down) { + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0x2a); + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0x37); + } else { + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0xb7); + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0xaa); + } } } else { keycode =3D qcode_to_keycode_set1[qcode]; @@ -651,18 +715,50 @@ static void ps2_keyboard_event(DeviceState *dev, Qemu= Console *src, ps2_put_keycode(s, 0x77); } } else if (qcode =3D=3D Q_KEY_CODE_PRINT) { - if (key->down) { - ps2_put_keycode(s, 0xe0); - ps2_put_keycode(s, 0x12); - ps2_put_keycode(s, 0xe0); - ps2_put_keycode(s, 0x7c); + if (s->modifiers & MOD_ALT_L) { + if (key->down) { + ps2_put_keycode(s, 0xf0); + ps2_put_keycode(s, 0x11); + ps2_put_keycode(s, 0x11); + ps2_put_keycode(s, 0x84); + } else { + ps2_put_keycode(s, 0xf0); + ps2_put_keycode(s, 0x84); + ps2_put_keycode(s, 0xf0); + ps2_put_keycode(s, 0x11); + ps2_put_keycode(s, 0x11); + } + } else if (s->modifiers & MOD_ALT_R) { + if (key->down) { + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0xf0); + ps2_put_keycode(s, 0x11); + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0x11); + ps2_put_keycode(s, 0x84); + } else { + ps2_put_keycode(s, 0xf0); + ps2_put_keycode(s, 0x84); + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0xf0); + ps2_put_keycode(s, 0x11); + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0x11); + } } else { - ps2_put_keycode(s, 0xe0); - ps2_put_keycode(s, 0xf0); - ps2_put_keycode(s, 0x7c); - ps2_put_keycode(s, 0xe0); - ps2_put_keycode(s, 0xf0); - ps2_put_keycode(s, 0x12); + if (key->down) { + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0x12); + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0x7c); + } else { + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0xf0); + ps2_put_keycode(s, 0x7c); + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0xf0); + ps2_put_keycode(s, 0x12); + } } } else { keycode =3D qcode_to_keycode_set2[qcode]; @@ -1125,6 +1221,7 @@ static void ps2_kbd_reset(void *opaque) s->scan_enabled =3D 0; s->translate =3D 0; s->scancode_set =3D 2; + s->modifiers =3D 0; } =20 static void ps2_mouse_reset(void *opaque) diff --git a/hw/input/trace-events b/hw/input/trace-events index d04132d342..88150ef7a6 100644 --- a/hw/input/trace-events +++ b/hw/input/trace-events @@ -2,6 +2,7 @@ =20 # hw/input/ps2.c ps2_put_keycode(void *opaque, int keycode) "%p keycode 0x%02x" +ps2_keyboard_event(void *opaque, int qcode, int down, unsigned int modifie= r, unsigned int modifiers) "%p qcode %d down %d modifier 0x%x modifiers 0x%= x" ps2_read_data(void *opaque) "%p" ps2_set_ledstate(void *s, int ledstate) "%p ledstate %d" ps2_reset_keyboard(void *s) "%p" --=20 2.9.3 From nobody Thu May 2 22:27:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508750533735429.0108223546338; Mon, 23 Oct 2017 02:22:13 -0700 (PDT) Received: from localhost ([::1]:37636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Yvm-0007IR-AU for importer@patchew.org; Mon, 23 Oct 2017 05:21:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Ytr-0005yx-3o for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:20:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6Ytq-0005ak-5r for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39496) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6Ytp-0005aE-Qf for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EED8A85A05 for ; Mon, 23 Oct 2017 09:19:56 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id C981A60C12; Mon, 23 Oct 2017 09:19:53 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DD9DA3F104; Mon, 23 Oct 2017 11:19:47 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EED8A85A05 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 11:19:43 +0200 Message-Id: <20171023091947.20771-6-kraxel@redhat.com> In-Reply-To: <20171023091947.20771-1-kraxel@redhat.com> References: <20171023091947.20771-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 23 Oct 2017 09:19:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/9] ps2: fix scancodes sent for Shift/Ctrl+Print key combination 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The 'Print' key is special in the AT set 1 / set 2 scancode definitions. An unmodified 'Print' key is supposed to send AT Set 1: e0 2a e0 37 (Down) e0 b7 e0 aa (Up) AT Set 2: e0 12 e0 7c (Down) e0 f0 7c e0 f0 12 (Up) which QEMU gets right. When combined with Shift/Ctrl (both left and right variants), the leading two bytes should be dropped, resulting in AT Set 1: e0 37 (Down) e0 b7 (Up) AT Set 2: e0 7c (Down) e0 f0 7c (Up) This difference is pretty benign, since of all the operating systems I have checked (Linux, FreeBSD and OpenStack), none bother to check the leading two bytes anyway. This change none the less makes the ps2 device better follow = real hardware behaviour. Signed-off-by: Daniel P. Berrange Message-id: 20171019142848.572-6-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 1e6f6ae9b6..c35b410e4d 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -674,6 +674,15 @@ static void ps2_keyboard_event(DeviceState *dev, QemuC= onsole *src, ps2_put_keycode(s, 0xe0); ps2_put_keycode(s, 0x38); } + } else if (s->modifiers & (MOD_SHIFT_L | MOD_CTRL_L | + MOD_SHIFT_R | MOD_CTRL_R)) { + if (key->down) { + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0x37); + } else { + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0xb7); + } } else { if (key->down) { ps2_put_keycode(s, 0xe0); @@ -745,6 +754,16 @@ static void ps2_keyboard_event(DeviceState *dev, QemuC= onsole *src, ps2_put_keycode(s, 0xe0); ps2_put_keycode(s, 0x11); } + } else if (s->modifiers & (MOD_SHIFT_L | MOD_CTRL_L | + MOD_SHIFT_R | MOD_CTRL_R)) { + if (key->down) { + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0x7c); + } else { + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0xf0); + ps2_put_keycode(s, 0x7c); + } } else { if (key->down) { ps2_put_keycode(s, 0xe0); --=20 2.9.3 From nobody Thu May 2 22:27:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508750682171161.2402608886607; Mon, 23 Oct 2017 02:24:42 -0700 (PDT) Received: from localhost ([::1]:37645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6YyK-00015C-7q for importer@patchew.org; Mon, 23 Oct 2017 05:24:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Ytr-0005yy-4L for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6Ytq-0005af-5l for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55918) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6Ytp-0005aI-Uz for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:58 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15D915F7BE for ; Mon, 23 Oct 2017 09:19:57 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66A4179834; Mon, 23 Oct 2017 09:19:56 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E496140549; Mon, 23 Oct 2017 11:19:47 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 15D915F7BE Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 11:19:44 +0200 Message-Id: <20171023091947.20771-7-kraxel@redhat.com> In-Reply-To: <20171023091947.20771-1-kraxel@redhat.com> References: <20171023091947.20771-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 23 Oct 2017 09:19:57 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/9] ps2: fix scancodess sent for Pause key in AT set 1 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The ps2 device was previously fixed to send the special Pause/Print scancode sequences in: commit 8c10e0baf0260b59a4e984744462a18016662e3e Author: Herv=C3=A9 Poussineau Date: Thu Sep 15 22:06:26 2016 +0200 ps2: use QEMU qcodes instead of scancodes The sequence used for Pause had a small typo in the AT set 1, with a 0xe1 accidentally changed to 0x91. This is not immediately visible with Linux guests since they run the ps2 device with AT set 2 scancodes. Signed-off-by: Daniel P. Berrange Message-id: 20171019142848.572-7-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index c35b410e4d..133cc2aa64 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -645,7 +645,7 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, ps2_put_keycode(s, 0xe1); ps2_put_keycode(s, 0x1d); ps2_put_keycode(s, 0x45); - ps2_put_keycode(s, 0x91); + ps2_put_keycode(s, 0xe1); ps2_put_keycode(s, 0x9d); ps2_put_keycode(s, 0xc5); } --=20 2.9.3 From nobody Thu May 2 22:27:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508750716075280.58852343382694; Mon, 23 Oct 2017 02:25:16 -0700 (PDT) Received: from localhost ([::1]:37647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Yys-0001Zn-77 for importer@patchew.org; Mon, 23 Oct 2017 05:25:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Ytp-0005y7-F4 for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6Yto-0005ZV-0C for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33316) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6Ytn-0005Z6-Ny for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD3617CB8D for ; Mon, 23 Oct 2017 09:19:54 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF49F795B0; Mon, 23 Oct 2017 09:19:53 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EBA5E40563; Mon, 23 Oct 2017 11:19:47 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CD3617CB8D Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 11:19:45 +0200 Message-Id: <20171023091947.20771-8-kraxel@redhat.com> In-Reply-To: <20171023091947.20771-1-kraxel@redhat.com> References: <20171023091947.20771-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 23 Oct 2017 09:19:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/9] ps2: fix scancodes sent for Ctrl+Pause key combination 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The 'Pause' key is special in the AT set 1 / set 2 scancode definitions. An unmodified 'Pause' key is supposed to send AT Set 1: e1 1d 45 91 9d c5 (Down) (Up) AT Set 2: e1 14 77 e1 f0 14 f0 77 (Down) (Up) which QEMU gets right. When combined with Ctrl (both left and right variant= s), a different sequence is expected AT Set 1: e0 46 e0 c6 (Down) (Up) AT Set 2: e0 7e e0 f0 73 (Down) (Up) Signed-off-by: Daniel P. Berrange Message-id: 20171019142848.572-8-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 51 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 133cc2aa64..f388a23c8e 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -641,13 +641,22 @@ static void ps2_keyboard_event(DeviceState *dev, Qemu= Console *src, =20 if (s->scancode_set =3D=3D 1) { if (qcode =3D=3D Q_KEY_CODE_PAUSE) { - if (key->down) { - ps2_put_keycode(s, 0xe1); - ps2_put_keycode(s, 0x1d); - ps2_put_keycode(s, 0x45); - ps2_put_keycode(s, 0xe1); - ps2_put_keycode(s, 0x9d); - ps2_put_keycode(s, 0xc5); + if (s->modifiers & (MOD_CTRL_L | MOD_CTRL_R)) { + if (key->down) { + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0x46); + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0xc6); + } + } else { + if (key->down) { + ps2_put_keycode(s, 0xe1); + ps2_put_keycode(s, 0x1d); + ps2_put_keycode(s, 0x45); + ps2_put_keycode(s, 0xe1); + ps2_put_keycode(s, 0x9d); + ps2_put_keycode(s, 0xc5); + } } } else if (qcode =3D=3D Q_KEY_CODE_PRINT) { if (s->modifiers & MOD_ALT_L) { @@ -713,15 +722,25 @@ static void ps2_keyboard_event(DeviceState *dev, Qemu= Console *src, } } else if (s->scancode_set =3D=3D 2) { if (qcode =3D=3D Q_KEY_CODE_PAUSE) { - if (key->down) { - ps2_put_keycode(s, 0xe1); - ps2_put_keycode(s, 0x14); - ps2_put_keycode(s, 0x77); - ps2_put_keycode(s, 0xe1); - ps2_put_keycode(s, 0xf0); - ps2_put_keycode(s, 0x14); - ps2_put_keycode(s, 0xf0); - ps2_put_keycode(s, 0x77); + if (s->modifiers & (MOD_CTRL_L | MOD_CTRL_R)) { + if (key->down) { + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0x7e); + ps2_put_keycode(s, 0xe0); + ps2_put_keycode(s, 0xf0); + ps2_put_keycode(s, 0x7e); + } + } else { + if (key->down) { + ps2_put_keycode(s, 0xe1); + ps2_put_keycode(s, 0x14); + ps2_put_keycode(s, 0x77); + ps2_put_keycode(s, 0xe1); + ps2_put_keycode(s, 0xf0); + ps2_put_keycode(s, 0x14); + ps2_put_keycode(s, 0xf0); + ps2_put_keycode(s, 0x77); + } } } else if (qcode =3D=3D Q_KEY_CODE_PRINT) { if (s->modifiers & MOD_ALT_L) { --=20 2.9.3 From nobody Thu May 2 22:27:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508750526199940.7624663311011; Mon, 23 Oct 2017 02:22:06 -0700 (PDT) Received: from localhost ([::1]:37635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Yvj-0007Fj-Ma for importer@patchew.org; Mon, 23 Oct 2017 05:21:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Ytp-0005y8-JN for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6Ytn-0005ZD-J2 for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37860) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6Ytn-0005Z2-AO for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F006B651 for ; Mon, 23 Oct 2017 09:19:54 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id D19EF5DA66; Mon, 23 Oct 2017 09:19:53 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id F3A2840572; Mon, 23 Oct 2017 11:19:47 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6F006B651 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 11:19:46 +0200 Message-Id: <20171023091947.20771-9-kraxel@redhat.com> In-Reply-To: <20171023091947.20771-1-kraxel@redhat.com> References: <20171023091947.20771-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 23 Oct 2017 09:19:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 8/9] ui: normalize the 'sysrq' key into the 'print' key 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 , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The 'sysrq' key was mistakenly added to QEMU to deal with incorrect handling of the 'print' key in the ps2 device: commit f2289cb6924afc97b2a75d21bfc9217024d11741 Author: balrog Date: Wed Jun 4 10:14:16 2008 +0000 Add sysrq to key names known by "sendkey". Adding sysrq keycode to the table enabling running sysrq debugging in the guest via the monitor sendkey command, like: (qemu) sendkey alt-sysrq-t Tested on x86-64 target and Linux guest. Signed-off-by: Ryan Harper The ps2 device is now fixed wrt modifiers and the 'print' key. Further the handling of the 'sysrq' key has some problems of its own, documented in the previous commit. To cleanup this mess, we convert any use of 'sysrq' into 'print' prior to dispatching the event to device models. Signed-off-by: Daniel P. Berrange Message-id: 20171019142848.572-9-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- ui/input.c | 14 ++++++++++++++ qapi/ui.json | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/ui/input.c b/ui/input.c index 4e821f8f2b..3e2d324278 100644 --- a/ui/input.c +++ b/ui/input.c @@ -353,6 +353,20 @@ void qemu_input_event_send(QemuConsole *src, InputEven= t *evt) assert(!(evt->type =3D=3D INPUT_EVENT_KIND_KEY && evt->u.key.data->key->type =3D=3D KEY_VALUE_KIND_NUMBER)); =20 + + /* + * 'sysrq' was mistakenly added to hack around the fact that + * the ps2 driver was not generating correct scancodes sequences + * when 'alt+print' was pressed. This flaw is now fixed and the + * 'sysrq' key serves no further purpose. We normalize it to + * 'print', so that downstream receivers of the event don't + * neeed to deal with this mistake + */ + if (evt->type =3D=3D INPUT_EVENT_KIND_KEY && + evt->u.key.data->key->u.qcode.data =3D=3D Q_KEY_CODE_SYSRQ) { + evt->u.key.data->key->u.qcode.data =3D Q_KEY_CODE_PRINT; + } + if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { return; } diff --git a/qapi/ui.json b/qapi/ui.json index e5d6610b4a..07b468f625 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -748,6 +748,13 @@ # @ac_bookmarks: since 2.10 # altgr, altgr_r: dropped in 2.10 # +# 'sysrq' was mistakenly added to hack around the fact that +# the ps2 driver was not generating correct scancodes sequences +# when 'alt+print' was pressed. This flaw is now fixed and the +# 'sysrq' key serves no further purpose. Any further use of +# 'sysrq' will be transparently changed to 'print', so they +# are effectively synonyms. +# # Since: 1.3.0 # ## --=20 2.9.3 From nobody Thu May 2 22:27:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508750556787848.1699983126222; Mon, 23 Oct 2017 02:22:36 -0700 (PDT) Received: from localhost ([::1]:37637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6YwI-0007n5-Jp for importer@patchew.org; Mon, 23 Oct 2017 05:22:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Ytp-0005y6-4W for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6Ytn-0005ZI-Jk for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33292) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e6Ytn-0005Z4-DJ for qemu-devel@nongnu.org; Mon, 23 Oct 2017 05:19:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 822F47CB87 for ; Mon, 23 Oct 2017 09:19:54 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-195.ams2.redhat.com [10.36.117.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D60E795B2; Mon, 23 Oct 2017 09:19:54 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0692F40574; Mon, 23 Oct 2017 11:19:48 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 822F47CB87 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 23 Oct 2017 11:19:47 +0200 Message-Id: <20171023091947.20771-10-kraxel@redhat.com> In-Reply-To: <20171023091947.20771-1-kraxel@redhat.com> References: <20171023091947.20771-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 23 Oct 2017 09:19:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 9/9] ui: pull in latest keycodemapdb 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Latest keycodemapdb has a fix for Sun keyboard Pause mapping and backcompat fix for QEMU's treatment of 0xb7 as an alternative to 0x54 for triggering Print/SysRq Signed-off-by: Daniel P. Berrange Message-id: 20171019142848.572-10-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- ui/keycodemapdb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/keycodemapdb b/ui/keycodemapdb index 56ce5650d2..10739aa260 160000 --- a/ui/keycodemapdb +++ b/ui/keycodemapdb @@ -1 +1 @@ -Subproject commit 56ce5650d2c6ea216b4580df44b9a6dd3bc92c3b +Subproject commit 10739aa26051a5d49d88132604539d3ed085e72e --=20 2.9.3