From nobody Sun May 19 13:00:10 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678811201; cv=none; d=zohomail.com; s=zohoarc; b=cDrixs16lJ9sS7ZjSOZuL5MtUNb6xTuXuIL2pHIqH2ExsjxxS/9QXWBQZS7t1z+TyZ53aDzT2vWWtx3aM2EtIzbsh0b7OCCCd+9KaApi8/2hzpVpZID7Omv8JWMI/gvAqqkvEMTogyDN5YmdVCH9hmOCOoc004o0htWbbEIOkqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678811201; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YEhKNNUpu43nt0FhEIjxrA8c7Ezo/43mhsjavc4XYZU=; b=JNXWV2PvkWLFk/pZazR2UJkwUFrbkzsqM9LnEWvB74OqVx1gbe08NhKknS4sMHZ60HHPiRjz0xZOKskpdhJozoGLEY2/V4Y/vihzHZh15+4DmfJB5/BnOE6mEz4+sQJWjS+KZ7TjRD5s61/WE7C+GJ9Gn9AqZTVzApDd3nhS+FM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678811201079685.0324629454341; Tue, 14 Mar 2023 09:26:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pc7TH-0004wI-K3; Tue, 14 Mar 2023 12:25:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pc7TG-0004vr-7t for qemu-devel@nongnu.org; Tue, 14 Mar 2023 12:25:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pc7TE-0007Ol-No for qemu-devel@nongnu.org; Tue, 14 Mar 2023 12:25:53 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-367-HJVhwIRUNyGVCVlkUm0Ffg-1; Tue, 14 Mar 2023 12:25:47 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2B96C81B081; Tue, 14 Mar 2023 16:25:46 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 393CC4042AC4; Tue, 14 Mar 2023 16:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678811151; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YEhKNNUpu43nt0FhEIjxrA8c7Ezo/43mhsjavc4XYZU=; b=Pn8G7OxAQVcyhd43Lg+IjiX8jeA0uBh0rSh1Yo+Xc0wpRZxL+ezs/UmmNeKni1SO8fpLGc 4WXAEcnp9SD44dy/JlAn48WHLnqxVa7Ko5nQ6hkoDTEdGp0n+kyNftFe8D+/XtSVWQoor/ rSXHRdHn2NT6ZczDH/i/h5LeFh3dfsg= X-MC-Unique: HJVhwIRUNyGVCVlkUm0Ffg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Lieven , Hanna Reitz , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Gerd Hoffmann , Ronnie Sahlberg , qemu-block@nongnu.org, libvir-list@redhat.com, Paolo Bonzini , Kevin Wolf , Markus Armbruster , Eric Blake , Willem van de Velde Subject: [PULL 1/3] Add qemu qcode support for keys F13 to F24 Date: Tue, 14 Mar 2023 16:25:38 +0000 Message-Id: <20230314162540.385954-2-berrange@redhat.com> In-Reply-To: <20230314162540.385954-1-berrange@redhat.com> References: <20230314162540.385954-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678811202074100001 From: Willem van de Velde To be able to use the function keys F13 to F24 these should be defined in d= e keycodemapdb and added to the qapi. The keycodemapdb is updated in its own repository, this patch enables the u= se of those keys within qemu. Signed-off-by: Willem van de Velde Signed-off-by: Daniel P. Berrang=C3=A9 --- qapi/ui.json | 15 ++++++++++++++- ui/keycodemapdb | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/qapi/ui.json b/qapi/ui.json index 0abba3e930..98322342f7 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -886,6 +886,19 @@ # @lang1: since 6.1 # @lang2: since 6.1 # +# @f13: since 8.0 +# @f14: since 8.0 +# @f15: since 8.0 +# @f16: since 8.0 +# @f17: since 8.0 +# @f18: since 8.0 +# @f19: since 8.0 +# @f20: since 8.0 +# @f21: since 8.0 +# @f22: since 8.0 +# @f23: since 8.0 +# @f24: since 8.0 +# # '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 @@ -918,7 +931,7 @@ 'volumeup', 'volumedown', 'mediaselect', 'mail', 'calculator', 'computer', 'ac_home', 'ac_back', 'ac_forward', 'ac_refresh', 'ac_bookmark= s', - 'lang1', 'lang2' ] } + 'lang1', 'lang2','f13','f14','f15','f16','f17','f18','f19','f2= 0','f21','f22','f23','f24' ] } =20 ## # @KeyValueKind: diff --git a/ui/keycodemapdb b/ui/keycodemapdb index d21009b1c9..f5772a62ec 160000 --- a/ui/keycodemapdb +++ b/ui/keycodemapdb @@ -1 +1 @@ -Subproject commit d21009b1c9f94b740ea66be8e48a1d8ad8124023 +Subproject commit f5772a62ec52591ff6870b7e8ef32482371f22c6 --=20 2.39.2 From nobody Sun May 19 13:00:10 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678811221; cv=none; d=zohomail.com; s=zohoarc; b=mcketb6pDtJS3ZbRJ8Le6cpe+isMyW3mPtuNo/5wYUR2vbQr1lzcTpJQvo2+a7rqY4JJUXo9sS+jrw3MVmQEdTd5gUGqZGQvexgA2ejKfYprKXGsAejMHUh/T4u+03+8IZwDfpLgefLWZeRmeWa0ZneidmC9vyYdwWZx534lGbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678811221; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ih/6w4H6hHD/iCx/AvfJuJXmZZOwNOu437gWviSPGp0=; b=kEk5zKDl7bsAL7GQuxD+v3GvtWIC3FbYJ6ka2HV9rl4l/lrUlll5SPZZtq86U4hNxJzR+TsUzo77uBdwzYGwjI+dhfRiURUtRUBiVvbRynnIXpYpl5WdH6lelEOePpSfxygou6FpCJ0UHNs9CRJQWp04crC8h99hc/cCqzVWlhg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678811221356110.28282644814055; Tue, 14 Mar 2023 09:27:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pc7TK-0004xO-Py; Tue, 14 Mar 2023 12:25:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pc7TH-0004wH-GX for qemu-devel@nongnu.org; Tue, 14 Mar 2023 12:25:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pc7TF-0007Ot-3j for qemu-devel@nongnu.org; Tue, 14 Mar 2023 12:25:55 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-330-69AN3MJ7P3qeJkknzwWHrw-1; Tue, 14 Mar 2023 12:25:49 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6CC41857A99; Tue, 14 Mar 2023 16:25:48 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 616C14042AC2; Tue, 14 Mar 2023 16:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678811152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ih/6w4H6hHD/iCx/AvfJuJXmZZOwNOu437gWviSPGp0=; b=NoTTLH1iddF+trJfc+xEPkozKwu3Xb7FUXT+qZdfc9BHP6JHEihihpNSlSSvW11K21hYmC 96DzhD1k/h0AIWWdTOdR7mbbW5FsvcyU7M4EYB4vNWidzaFAEvOanFksBg4zX02sVg8XTv 4NR+idRjTVQLs8dd7qbjIUkG4TxWEr4= X-MC-Unique: 69AN3MJ7P3qeJkknzwWHrw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Lieven , Hanna Reitz , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Gerd Hoffmann , Ronnie Sahlberg , qemu-block@nongnu.org, libvir-list@redhat.com, Paolo Bonzini , Kevin Wolf , Markus Armbruster , Eric Blake , Ross Lagerwall Subject: [PULL 2/3] ps2: Don't send key release event for Lang1, Lang2 keys Date: Tue, 14 Mar 2023 16:25:39 +0000 Message-Id: <20230314162540.385954-3-berrange@redhat.com> In-Reply-To: <20230314162540.385954-1-berrange@redhat.com> References: <20230314162540.385954-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678811222091100003 From: Ross Lagerwall The scancodes for the Lang1 and Lang2 keys (i.e. Hangeul, Hanja) are special since they already have the 0x80 bit set which is commonly used to indicate a key release in AT set 1. Reportedly, real hardware does not send a key release scancode. So, skip sending a release for these keys. This ensures that Windows behaves correctly and interprets it as a single keypress rather than two consecutive keypresses. Signed-off-by: Ross Lagerwall Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/input/ps2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 3253ab6a92..45af76a837 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -402,6 +402,9 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, ps2_put_keycode(s, 0xaa); } } + } else if ((qcode =3D=3D Q_KEY_CODE_LANG1 || qcode =3D=3D Q_KEY_CO= DE_LANG2) + && !key->down) { + /* Ignore release for these keys */ } else { if (qcode < qemu_input_map_qcode_to_atset1_len) { keycode =3D qemu_input_map_qcode_to_atset1[qcode]; @@ -497,6 +500,9 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, ps2_put_keycode(s, 0x12); } } + } else if ((qcode =3D=3D Q_KEY_CODE_LANG1 || qcode =3D=3D Q_KEY_CO= DE_LANG2) && + !key->down) { + /* Ignore release for these keys */ } else { if (qcode < qemu_input_map_qcode_to_atset2_len) { keycode =3D qemu_input_map_qcode_to_atset2[qcode]; --=20 2.39.2 From nobody Sun May 19 13:00:10 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678811200; cv=none; d=zohomail.com; s=zohoarc; b=W2Z+jL/Ttlf5RwYhUfy0r+BQ5yw3tCS4Jm4JrJlyfTOTCxIIe2M0IhrBXN1k+5d3e5XQlTtc6fbzPo4ZtDwxXE5yLqII1OD/wc7Wt/n2b3V07tfila2lKAcJPXFmODJ02evNMbOp9myfSWB1KqmHUlTcnrW+ChDv0gKv5rr13sA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678811200; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=urFW4nSraIsPDPq4iZZOOIlcOzIvdO91+DoMI1iB4bE=; b=iyHTkZmqHiqCxYwuTG45lALLBao6DxxyFJHpmK/zdS51SkNUzAIP6Au/oJH1EKDEghNGdHF/8kBa0WOUj4UL5xdTYxf0Y3zXniHCA0bnMA3lAP3ySSm9WNE6YaWUY7wKwJk5vIzHXqXcF5rd1EfihOYRz4rpOH3ZC1aqGeCyqqI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678811200669923.64344088065; Tue, 14 Mar 2023 09:26:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pc7TM-0004y1-CK; Tue, 14 Mar 2023 12:26:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pc7TJ-0004wr-VI for qemu-devel@nongnu.org; Tue, 14 Mar 2023 12:25:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pc7TI-0007PS-4U for qemu-devel@nongnu.org; Tue, 14 Mar 2023 12:25:57 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-120-7fVx76jEPnCwVRnutSII5Q-1; Tue, 14 Mar 2023 12:25:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C48CC803D50; Tue, 14 Mar 2023 16:25:50 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id A36824042AC2; Tue, 14 Mar 2023 16:25:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678811155; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=urFW4nSraIsPDPq4iZZOOIlcOzIvdO91+DoMI1iB4bE=; b=QIESFnnKJ/6hyxFmw726Vp8KiPqYsft5WVUIDpiUNyEC99nf0cOk3TdUnMTIbcNaPhY/h/ yI+ztAU1qZkI7msSdkoiVRcI2x7HFMzk68wwiqPE4c3PM4XTyPdLSBZz1a0/zVg9qVW3ZI RImSjUK5MeuAzZTp+5Fv5AzpLu9wRkQ= X-MC-Unique: 7fVx76jEPnCwVRnutSII5Q-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Lieven , Hanna Reitz , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Gerd Hoffmann , Ronnie Sahlberg , qemu-block@nongnu.org, libvir-list@redhat.com, Paolo Bonzini , Kevin Wolf , Markus Armbruster , Eric Blake , Matheus Tavares Bernardino , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 3/3] io/channel-tls: plug memory leakage on GSource Date: Tue, 14 Mar 2023 16:25:40 +0000 Message-Id: <20230314162540.385954-4-berrange@redhat.com> In-Reply-To: <20230314162540.385954-1-berrange@redhat.com> References: <20230314162540.385954-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678811202092100003 From: Matheus Tavares Bernardino This leakage can be seen through test-io-channel-tls: $ ../configure --target-list=3Daarch64-softmmu --enable-sanitizers $ make ./tests/unit/test-io-channel-tls $ ./tests/unit/test-io-channel-tls Indirect leak of 104 byte(s) in 1 object(s) allocated from: #0 0x7f81d1725808 in __interceptor_malloc ../../../../src/libsanitizer/= asan/asan_malloc_linux.cc:144 #1 0x7f81d135ae98 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0= x57e98) #2 0x55616c5d4c1b in object_new_with_propv ../qom/object.c:795 #3 0x55616c5d4a83 in object_new_with_props ../qom/object.c:768 #4 0x55616c5c5415 in test_tls_creds_create ../tests/unit/test-io-channe= l-tls.c:70 #5 0x55616c5c5a6b in test_io_channel_tls ../tests/unit/test-io-channel-= tls.c:158 #6 0x7f81d137d58d (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x7a58d) Indirect leak of 32 byte(s) in 1 object(s) allocated from: #0 0x7f81d1725a06 in __interceptor_calloc ../../../../src/libsanitizer/= asan/asan_malloc_linux.cc:153 #1 0x7f81d1472a20 in gnutls_dh_params_init (/lib/x86_64-linux-gnu/libgn= utls.so.30+0x46a20) #2 0x55616c6485ff in qcrypto_tls_creds_x509_load ../crypto/tlscredsx509= .c:634 #3 0x55616c648ba2 in qcrypto_tls_creds_x509_complete ../crypto/tlscreds= x509.c:694 #4 0x55616c5e1fea in user_creatable_complete ../qom/object_interfaces.c= :28 #5 0x55616c5d4c8c in object_new_with_propv ../qom/object.c:807 #6 0x55616c5d4a83 in object_new_with_props ../qom/object.c:768 #7 0x55616c5c5415 in test_tls_creds_create ../tests/unit/test-io-channe= l-tls.c:70 #8 0x55616c5c5a6b in test_io_channel_tls ../tests/unit/test-io-channel-= tls.c:158 #9 0x7f81d137d58d (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x7a58d) ... SUMMARY: AddressSanitizer: 49143 byte(s) leaked in 184 allocation(s). The docs for `g_source_add_child_source(source, child_source)` says "source will hold a reference on child_source while child_source is attached to it." Therefore, we should unreference the child source at `qio_channel_tls_read_watch()` after attaching it to `source`. With this change, ./tests/unit/test-io-channel-tls shows no leakages. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Matheus Tavares Bernardino Signed-off-by: Daniel P. Berrang=C3=A9 --- io/channel-tls.c | 1 + 1 file changed, 1 insertion(+) diff --git a/io/channel-tls.c b/io/channel-tls.c index 8052945ba0..5a7a3d48d6 100644 --- a/io/channel-tls.c +++ b/io/channel-tls.c @@ -446,6 +446,7 @@ qio_channel_tls_read_watch(QIOChannelTLS *tioc, GSource= *source) object_ref(OBJECT(tioc)); =20 g_source_add_child_source(source, child); + g_source_unref(child); } =20 static GSource *qio_channel_tls_create_watch(QIOChannel *ioc, --=20 2.39.2