From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628171919031804.1282686667605; Thu, 5 Aug 2021 06:58:39 -0700 (PDT) Received: from localhost ([::1]:43486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBdtN-0006EE-UG for importer@patchew.org; Thu, 05 Aug 2021 09:58:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdsO-0004gR-7v for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:57:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43444) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdsM-00008c-Mw for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:57:36 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-137-IlYdH8fMONGiZFlSc8MjoQ-1; Thu, 05 Aug 2021 09:57:32 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 83782801AC0 for ; Thu, 5 Aug 2021 13:57:31 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CDB05C1A1; Thu, 5 Aug 2021 13:57:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171853; 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=tLQ60TpbJE+zchmjajoumonlNRDrN6jigUuEHNUzb9c=; b=djN1FreXB1/Ccm/3gLyfdT6icjlZJy/hLUQIAS1ELcSlYAelvGEb1zlkQQ7F70+3MVMDfs fdJXQjdShAuNpOb5VE/yHJOQg5o3N08i2Mt2bJXZysk56tTP0EpoYkR8oKCEK732Z4Z7t1 /49czvdovpQrd87xk4BxuUmY4QuOoHE= X-MC-Unique: IlYdH8fMONGiZFlSc8MjoQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 01/18] ui/vdagent: fix leak on error path Date: Thu, 5 Aug 2021 17:56:58 +0400 Message-Id: <20210805135715.857938-2-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628171919935100001 From: Marc-Andr=C3=A9 Lureau "info" was leaked when more than 10 entries. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/ui/clipboard.h | 2 ++ ui/vdagent.c | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index b45b984c9f..eb789a285a 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -190,4 +190,6 @@ void qemu_clipboard_set_data(QemuClipboardPeer *peer, const void *data, bool update); =20 +G_DEFINE_AUTOPTR_CLEANUP_FUNC(QemuClipboardInfo, qemu_clipboard_info_unref) + #endif /* QEMU_CLIPBOARD_H */ diff --git a/ui/vdagent.c b/ui/vdagent.c index a253a8fe63..f6ef8d1993 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -438,7 +438,7 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev *= vd, VDAgentMessage *msg) uint8_t s =3D VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD; uint32_t size =3D msg->size; void *data =3D msg->data; - QemuClipboardInfo *info; + g_autoptr(QemuClipboardInfo) info =3D NULL; QemuClipboardType type; =20 if (have_selection(vd)) { @@ -477,7 +477,6 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev *= vd, VDAgentMessage *msg) size -=3D sizeof(uint32_t); } qemu_clipboard_update(info); - qemu_clipboard_info_unref(info); break; case VD_AGENT_CLIPBOARD_REQUEST: if (size < sizeof(uint32_t)) { @@ -523,7 +522,6 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev *= vd, VDAgentMessage *msg) /* set empty clipboard info */ info =3D qemu_clipboard_info_new(NULL, s); qemu_clipboard_update(info); - qemu_clipboard_info_unref(info); } break; } --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172181231119.40508030146077; Thu, 5 Aug 2021 07:03:01 -0700 (PDT) Received: from localhost ([::1]:55426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBdxc-0005xZ-7Y for importer@patchew.org; Thu, 05 Aug 2021 10:03:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdsZ-00059j-R0 for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:57:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdsY-0000I8-F5 for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:57:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-120-VxZTrd3aMXmqzvCYYG7ARA-1; Thu, 05 Aug 2021 09:57:44 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DA874107ACF5 for ; Thu, 5 Aug 2021 13:57:43 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 832CB1036D27; Thu, 5 Aug 2021 13:57:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171865; 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=cVjLzHO2nIi8KZy1mMtpuvGp6gSulIYAEN+AKOrF24Y=; b=HopwwBQaMBr1HKq2dNjQ0LnYma90bNqovm/7IK/voj/3Sbi+7xzR86hW72C615Om4Od3nr HINaPOVzEeIfuxYm2uBUL9HO0vZc6WNQc7yNvkTxa6dGa4VjMRNsGCzHMYio/erlb8wggB OcnnC00OgC5bOfR89x8zTcNRM0Zw60w= X-MC-Unique: VxZTrd3aMXmqzvCYYG7ARA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 02/18] ui/vdagent: remove copy-pasta comment Date: Thu, 5 Aug 2021 17:56:59 +0400 Message-Id: <20210805135715.857938-3-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172200847100003 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/vdagent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index f6ef8d1993..5ae5734c81 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -516,7 +516,7 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev *= vd, VDAgentMessage *msg) qemu_clipboard_set_data(&vd->cbpeer, vd->cbinfo[s], type, size, data, true); break; - case VD_AGENT_CLIPBOARD_RELEASE: /* data */ + case VD_AGENT_CLIPBOARD_RELEASE: if (vd->cbinfo[s] && vd->cbinfo[s]->owner =3D=3D &vd->cbpeer) { /* set empty clipboard info */ --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628171984224794.2589561294617; Thu, 5 Aug 2021 06:59:44 -0700 (PDT) Received: from localhost ([::1]:46414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBduR-0008CZ-5q for importer@patchew.org; Thu, 05 Aug 2021 09:59:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdsm-0005gw-82 for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdsk-0000PO-Qz for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-505-ML0DJPA6NI6XaHe5bP14GQ-1; Thu, 05 Aug 2021 09:57:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30E8793921 for ; Thu, 5 Aug 2021 13:57:56 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 499CC60CC9; Thu, 5 Aug 2021 13:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171878; 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=bykDuWmowo5cwOmADbmeEKqhIej2kqyYevtwCdn4GsY=; b=du+IzmP52TdwDZVGH74rGqJ+JgH7d0EMBAvSHkIG1Clnm8q0QuksKjHJKsgUUh6xnj6YCy +a56yi+GAK7s9EdIzQ3ZYFjtuForLznoFjk5zRF5TGRrNXwyvifL+n0j/JOsakwWm8rfxS v1IJqJJMsaMGWiSNMOZzgEENUMGxF7M= X-MC-Unique: ML0DJPA6NI6XaHe5bP14GQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 03/18] ui/gtk-clipboard: use existing macros Date: Thu, 5 Aug 2021 17:57:00 +0400 Message-Id: <20210805135715.857938-4-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628171985203100001 From: Marc-Andr=C3=A9 Lureau Hardcoding strings is error prone, use dedicated macros instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/gtk-clipboard.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index bff28d2030..5e817ae55c 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -177,11 +177,11 @@ void gd_clipboard_init(GtkDisplayState *gd) qemu_clipboard_peer_register(&gd->cbpeer); =20 gd->gtkcb[QEMU_CLIPBOARD_SELECTION_CLIPBOARD] =3D - gtk_clipboard_get(gdk_atom_intern("CLIPBOARD", FALSE)); + gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); gd->gtkcb[QEMU_CLIPBOARD_SELECTION_PRIMARY] =3D - gtk_clipboard_get(gdk_atom_intern("PRIMARY", FALSE)); + gtk_clipboard_get(GDK_SELECTION_PRIMARY); gd->gtkcb[QEMU_CLIPBOARD_SELECTION_SECONDARY] =3D - gtk_clipboard_get(gdk_atom_intern("SECONDARY", FALSE)); + gtk_clipboard_get(GDK_SELECTION_SECONDARY); =20 g_signal_connect(gd->gtkcb[QEMU_CLIPBOARD_SELECTION_CLIPBOARD], "owner-change", G_CALLBACK(gd_owner_change), gd); --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172096719458.29770604528153; Thu, 5 Aug 2021 07:01:36 -0700 (PDT) Received: from localhost ([::1]:51766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBdwF-0003RC-LI for importer@patchew.org; Thu, 05 Aug 2021 10:01:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdsz-0006Jm-C1 for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24652) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdsy-0000XD-0C for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-28-hOd7HgK1OiamXC-hww6FUg-1; Thu, 05 Aug 2021 09:58:10 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3249693921 for ; Thu, 5 Aug 2021 13:58:09 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA128421F; Thu, 5 Aug 2021 13:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171891; 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=h8DWW4GTGc5bGckpzifXOx+F24qr9GjY3WY4ez/Gmhc=; b=O6kbaVXgTbxwz7ojx3Zh1oQprVxzO0SguchrD6nhMkjNtgeeIOzh/i3IOZG1kAN10hqc26 N7EKBsVirPVjnu7jJrbWuMHd6Yevo9vw69WD6PG3zGwEBqfBlP5bYgf/0PoSZPkILxXEZw IzSYvWggztAZ4mBrldT+20NHeNh+8Y0= X-MC-Unique: hOd7HgK1OiamXC-hww6FUg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 04/18] ui/gtk-clipboard: fix clipboard enum typo Date: Thu, 5 Aug 2021 17:57:01 +0400 Message-Id: <20210805135715.857938-5-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172111654100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/gtk-clipboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 5e817ae55c..2c78de9500 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -155,7 +155,7 @@ static void gd_owner_change(GtkClipboard *clipboard, =20 =20 switch (event->owner_change.reason) { - case GDK_SETTING_ACTION_NEW: + case GDK_OWNER_CHANGE_NEW_OWNER: info =3D qemu_clipboard_info_new(&gd->cbpeer, s); if (gtk_clipboard_wait_is_text_available(clipboard)) { info->types[QEMU_CLIPBOARD_TYPE_TEXT].available =3D true; --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172033432337.99717501302894; Thu, 5 Aug 2021 07:00:33 -0700 (PDT) Received: from localhost ([::1]:48286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBdvE-00012Z-7v for importer@patchew.org; Thu, 05 Aug 2021 10:00:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdtC-0006fU-To for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47602) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdtA-0000ds-Rg for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:26 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-387-sRyZLl5bOK23fk48IHXMMQ-1; Thu, 05 Aug 2021 09:58:22 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDA14190D344 for ; Thu, 5 Aug 2021 13:58:21 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9780D4A66; Thu, 5 Aug 2021 13:58:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171904; 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=uxVivlhdggH8hSzuvkWSXHFxbgrHJy6pB7yNHHuxKRs=; b=XBE8hgnKwgBiM0wG0+FY6+6Pli/Z/0dc/lKHQgI4bZHw0fzuF6Aq0yANSsvmnqv2jaZNL6 q/3wGHyi5HfAIiy+pKzoxuCXl0J62V1qzSs7bt7hS6WSx4c5pcFv9FZJXrg3XYpuug8RdH 8G1EvJ4My4IbFW2GEJR9p7NdS0R7uYE= X-MC-Unique: sRyZLl5bOK23fk48IHXMMQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 05/18] ui/clipboard: add helper to retrieve current clipboard Date: Thu, 5 Aug 2021 17:57:02 +0400 Message-Id: <20210805135715.857938-6-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172036885100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/clipboard.h | 9 +++++++++ ui/clipboard.c | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index eb789a285a..e9fcb15c66 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -109,6 +109,15 @@ void qemu_clipboard_peer_register(QemuClipboardPeer *p= eer); */ void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer); =20 +/** + * qemu_clipboard_info + * + * @selection: clipboard selection. + * + * Return the current clipboard data & owner informations. + */ +QemuClipboardInfo *qemu_clipboard_info(QemuClipboardSelection selection); + /** * qemu_clipboard_info_new * diff --git a/ui/clipboard.c b/ui/clipboard.c index 3525b30178..56c14509fe 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -4,6 +4,8 @@ static NotifierList clipboard_notifiers =3D NOTIFIER_LIST_INITIALIZER(clipboard_notifiers); =20 +static QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT]; + void qemu_clipboard_peer_register(QemuClipboardPeer *peer) { notifier_list_add(&clipboard_notifiers, &peer->update); @@ -16,7 +18,20 @@ void qemu_clipboard_peer_unregister(QemuClipboardPeer *p= eer) =20 void qemu_clipboard_update(QemuClipboardInfo *info) { + g_autoptr(QemuClipboardInfo) old =3D NULL; + assert(info->selection < QEMU_CLIPBOARD_SELECTION__COUNT); + notifier_list_notify(&clipboard_notifiers, info); + + old =3D cbinfo[info->selection]; + cbinfo[info->selection] =3D qemu_clipboard_info_ref(info); +} + +QemuClipboardInfo *qemu_clipboard_info(QemuClipboardSelection selection) +{ + assert(selection < QEMU_CLIPBOARD_SELECTION__COUNT); + + return cbinfo[selection]; } =20 QemuClipboardInfo *qemu_clipboard_info_new(QemuClipboardPeer *owner, --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172196177860.4072197530875; Thu, 5 Aug 2021 07:03:16 -0700 (PDT) Received: from localhost ([::1]:56796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBdxq-0006rb-S5 for importer@patchew.org; Thu, 05 Aug 2021 10:03:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdtN-0007Gn-VH for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43428) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdtM-0000mB-HI for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:37 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-139-tAsN4qJyMBGaOlEZhSuBdQ-1; Thu, 05 Aug 2021 09:58:34 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7DEB87D547 for ; Thu, 5 Aug 2021 13:58:33 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B85C1B480; Thu, 5 Aug 2021 13:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171915; 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=0KW1urW5a0nq+nx8fRKcQ+RjmdwVONRbmelArIaLdLE=; b=BM/DdUUgoP5PlW012WLk5VpvX8OVj+5xdGcrqb86vOJYZOdkTSWBbQxZisdPFDTNFfdL6h leMfkWpNrqXrcLq3pm6qARpSGfl3Ks7BB3Yj/2RYdImEBy3/rCNosWSAD1n6Drsuk603Q7 W8RXxIouf9LL+UekcY7cURbfKPj0kbg= X-MC-Unique: tAsN4qJyMBGaOlEZhSuBdQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 06/18] ui/clipboard: add qemu_clipboard_peer_owns() helper Date: Thu, 5 Aug 2021 17:57:03 +0400 Message-Id: <20210805135715.857938-7-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172215521100003 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/clipboard.h | 11 +++++++++++ ui/clipboard.c | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index e9fcb15c66..25e0b470c8 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -109,6 +109,17 @@ void qemu_clipboard_peer_register(QemuClipboardPeer *p= eer); */ void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer); =20 +/** + * qemu_clipboard_peer_owns + * + * @peer: peer information. + * @selection: clipboard selection. + * + * Return TRUE if the peer owns the clipboard. + */ +bool qemu_clipboard_peer_owns(QemuClipboardPeer *peer, + QemuClipboardSelection selection); + /** * qemu_clipboard_info * diff --git a/ui/clipboard.c b/ui/clipboard.c index 56c14509fe..490c3220f4 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -16,6 +16,14 @@ void qemu_clipboard_peer_unregister(QemuClipboardPeer *p= eer) notifier_remove(&peer->update); } =20 +bool qemu_clipboard_peer_owns(QemuClipboardPeer *peer, + QemuClipboardSelection selection) +{ + QemuClipboardInfo *info =3D qemu_clipboard_info(selection); + + return info && info->owner =3D=3D peer; +} + void qemu_clipboard_update(QemuClipboardInfo *info) { g_autoptr(QemuClipboardInfo) old =3D NULL; --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172276519519.5046022097357; Thu, 5 Aug 2021 07:04:36 -0700 (PDT) Received: from localhost ([::1]:34672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBdz9-0002fF-5N for importer@patchew.org; Thu, 05 Aug 2021 10:04:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdtb-00081k-AZ for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdtZ-0000vL-UW for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-305-rq76LxByPMWf-qNhZDl0mA-1; Thu, 05 Aug 2021 09:58:46 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0C2FA801A92 for ; Thu, 5 Aug 2021 13:58:45 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5440C5C1A1; Thu, 5 Aug 2021 13:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171929; 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=WW5wdVySbxe4U5sNpZVkGS0YAStLxYhrNo0e5lZzn8U=; b=GzaXN2NGVgwim71C028t86pmZXLOXT6tG4XE9FZ2xZmL6JQMFCffgNXSzYyDdowGRHqhLU F757oTc4sK2J87jPJyx1/xABilWD4VBbcB20vNRToUf1i5b5rqEHuwVaN7DGAcaw8AGQvG +6uPuVkqs9V46EXVB3nCr3Mtfc65uk8= X-MC-Unique: rq76LxByPMWf-qNhZDl0mA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 07/18] ui/clipboard: add qemu_clipboard_peer_release() helper Date: Thu, 5 Aug 2021 17:57:04 +0400 Message-Id: <20210805135715.857938-8-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172293215100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/clipboard.h | 11 +++++++++++ ui/clipboard.c | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index 25e0b470c8..6298986b15 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -120,6 +120,17 @@ void qemu_clipboard_peer_unregister(QemuClipboardPeer = *peer); bool qemu_clipboard_peer_owns(QemuClipboardPeer *peer, QemuClipboardSelection selection); =20 +/** + * qemu_clipboard_peer_release + * + * @peer: peer information. + * @selection: clipboard selection. + * + * If the peer owns the clipboard, release it. + */ +void qemu_clipboard_peer_release(QemuClipboardPeer *peer, + QemuClipboardSelection selection); + /** * qemu_clipboard_info * diff --git a/ui/clipboard.c b/ui/clipboard.c index 490c3220f4..c277247a7f 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -24,6 +24,18 @@ bool qemu_clipboard_peer_owns(QemuClipboardPeer *peer, return info && info->owner =3D=3D peer; } =20 +void qemu_clipboard_peer_release(QemuClipboardPeer *peer, + QemuClipboardSelection selection) +{ + g_autoptr(QemuClipboardInfo) info =3D NULL; + + if (qemu_clipboard_peer_owns(peer, selection)) { + /* set empty clipboard info */ + info =3D qemu_clipboard_info_new(NULL, selection); + qemu_clipboard_update(info); + } +} + void qemu_clipboard_update(QemuClipboardInfo *info) { g_autoptr(QemuClipboardInfo) old =3D NULL; --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172291832465.262701816967; Thu, 5 Aug 2021 07:04:51 -0700 (PDT) Received: from localhost ([::1]:35736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBdzO-0003ML-Qh for importer@patchew.org; Thu, 05 Aug 2021 10:04:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdtd-00084I-Re for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57209) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdtc-0000xI-J3 for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-503-x3fBWx9RM0-rEZ0DPqYZVQ-1; Thu, 05 Aug 2021 09:58:50 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2DB7100F765 for ; Thu, 5 Aug 2021 13:58:49 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id D337D5C1A1; Thu, 5 Aug 2021 13:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171931; 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=mPyYKL/DZc3ctEY3u5t4wqtS6o1OMGBZLL/jFHYywY8=; b=VVshkTubu7zW49uNM385SXjC1ZkPWyZEFPvG7DzF3qSvr115ANPjvwlouxpY7AkOe7owma gRNaKLgGAUOeAaS6XIJ3ZevzJnVj4zFc9vXmFgDdcPtGx/tRdT1hZI0yhJKDyYH16Z2YJ1 H0MLojVZU5ZeU+spttSq0sVl0LmcvU0= X-MC-Unique: x3fBWx9RM0-rEZ0DPqYZVQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 08/18] ui/clipboard: release owned grabs on unregister Date: Thu, 5 Aug 2021 17:57:05 +0400 Message-Id: <20210805135715.857938-9-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172304232100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/clipboard.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/clipboard.c b/ui/clipboard.c index c277247a7f..d7b008d62a 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -13,6 +13,12 @@ void qemu_clipboard_peer_register(QemuClipboardPeer *pee= r) =20 void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer) { + int i; + + for (i =3D 0; i < QEMU_CLIPBOARD_SELECTION__COUNT; i++) { + qemu_clipboard_peer_release(peer, i); + } + notifier_remove(&peer->update); } =20 --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172393937886.9908468250213; Thu, 5 Aug 2021 07:06:33 -0700 (PDT) Received: from localhost ([::1]:42100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBe12-0007iV-Rp for importer@patchew.org; Thu, 05 Aug 2021 10:06:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdtk-0008AV-1u for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53044) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdth-00010W-3G for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:58:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-203-WWEdrQ7hO0ywktTiW7h-xA-1; Thu, 05 Aug 2021 09:58:55 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 741A0190D345 for ; Thu, 5 Aug 2021 13:58:54 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C7B85C1D0; Thu, 5 Aug 2021 13:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171936; 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=THZGEmL1ON3sOCgaZq2CNcN8xwiiSAihcDMZ4EzEkSY=; b=S7fFu3HJqm+1qwu0euCh7Jg3b8KX53eCcdlXf4VtKOZkSKsrZRMTAYEuRnp8CfTLyGjtdl s8YYPNmnEkuntMlhBDRHSb34Xc3ozMfJsCYLHLS32xVUDx3U7V5xJOntmQCPNtSWebhHi4 vpWEM/C47w/O1Y9b5qH7mKigkSiS1yU= X-MC-Unique: WWEdrQ7hO0ywktTiW7h-xA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 09/18] ui/vdagent: disconnect handlers and reset state on finalize Date: Thu, 5 Aug 2021 17:57:06 +0400 Message-Id: <20210805135715.857938-10-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172394765100001 From: Marc-Andr=C3=A9 Lureau Avoid handlers being called with dangling pointers when the object is freed. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- ui/vdagent.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 5ae5734c81..1a29016e07 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -721,22 +721,26 @@ static void vdagent_chr_accept_input(Chardev *chr) vdagent_send_buf(vd); } =20 +static void vdagent_disconnect(VDAgentChardev *vd) +{ + vdagent_reset_bufs(vd); + vd->caps =3D 0; + if (vd->mouse_hs) { + qemu_input_handler_deactivate(vd->mouse_hs); + } + if (vd->cbpeer.update.notify) { + qemu_clipboard_peer_unregister(&vd->cbpeer); + memset(&vd->cbpeer, 0, sizeof(vd->cbpeer)); + } +} + static void vdagent_chr_set_fe_open(struct Chardev *chr, int fe_open) { VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(chr); =20 if (!fe_open) { trace_vdagent_close(); - /* reset state */ - vdagent_reset_bufs(vd); - vd->caps =3D 0; - if (vd->mouse_hs) { - qemu_input_handler_deactivate(vd->mouse_hs); - } - if (vd->cbpeer.update.notify) { - qemu_clipboard_peer_unregister(&vd->cbpeer); - memset(&vd->cbpeer, 0, sizeof(vd->cbpeer)); - } + vdagent_disconnect(vd); return; } =20 @@ -781,6 +785,7 @@ static void vdagent_chr_fini(Object *obj) { VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(obj); =20 + vdagent_disconnect(vd); buffer_free(&vd->outbuf); } =20 --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172416266449.280007976134; Thu, 5 Aug 2021 07:06:56 -0700 (PDT) Received: from localhost ([::1]:43432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBe1P-00008y-8m for importer@patchew.org; Thu, 05 Aug 2021 10:06:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdtu-0008JV-Pl for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24154) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdtt-00017z-En for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:10 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-476-FqRilLQMMtWWHH_t56uoVg-1; Thu, 05 Aug 2021 09:59:07 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10E4B100F766 for ; Thu, 5 Aug 2021 13:59:07 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABEB85C1A1; Thu, 5 Aug 2021 13:58:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171948; 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=TUmFx9j8+LWbFJAKqUl0016kVaEt4yxP1wppqlyAezw=; b=Vs7qVQrrKJD0KSAUMWT8l5+XMqIaQGBo7Rd066BbkwPRgcaOax97cJxZ0sdpHFmN1j1PLv 5dJsJNfBDLY7/FEFhpP28NB1YzzUEEBJHyJ1UaU0hZpkKzTpz2KdE0aDGGWCZbjT6YybPX OD0wn2zWCiuvl+gF6IMZ5DeWuMY7YKc= X-MC-Unique: FqRilLQMMtWWHH_t56uoVg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 10/18] ui/vdagent: reset outbuf on disconnect Date: Thu, 5 Aug 2021 17:57:07 +0400 Message-Id: <20210805135715.857938-11-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172417179100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/vdagent.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/vdagent.c b/ui/vdagent.c index 1a29016e07..3770c58b6c 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -723,6 +723,7 @@ static void vdagent_chr_accept_input(Chardev *chr) =20 static void vdagent_disconnect(VDAgentChardev *vd) { + buffer_reset(&vd->outbuf); vdagent_reset_bufs(vd); vd->caps =3D 0; if (vd->mouse_hs) { --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172521951547.6508646046625; Thu, 5 Aug 2021 07:08:41 -0700 (PDT) Received: from localhost ([::1]:51758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBe36-0005hJ-Sk for importer@patchew.org; Thu, 05 Aug 2021 10:08:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdtz-0008Uk-Vj for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32024) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdty-0001Av-7F for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-566-JRHuIj0BNU26wzsU_wxk8g-1; Thu, 05 Aug 2021 09:59:12 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D298A87D546 for ; Thu, 5 Aug 2021 13:59:11 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 990845C1A1; Thu, 5 Aug 2021 13:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171953; 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=MiiLtG9jTgAfsEsTqsGDvXGbSys/7B0mP5opXs/AAH4=; b=PYu57wq2GFeR8DjV0nDWEY6ummpmNVf3O2lhwQBm/N3Jhz1ZeJTyaZ9+8aFmnZWIa53kbY LIonnyM7wG21rZZmnrd3474rFNJhnxHfv7eDVJJyXrvJbTuVRwmW6hwap8BK/+M5bRt66k 2IRqJovNQnzdTitGWSt8v3tRvuqL1cg= X-MC-Unique: JRHuIj0BNU26wzsU_wxk8g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 11/18] ui/vdagent: split clipboard recv message handling Date: Thu, 5 Aug 2021 17:57:08 +0400 Message-Id: <20210805135715.857938-12-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172522596100002 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/vdagent.c | 157 +++++++++++++++++++++++++++++---------------------- 1 file changed, 89 insertions(+), 68 deletions(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 3770c58b6c..362064213c 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -433,13 +433,94 @@ static void vdagent_clipboard_request(QemuClipboardIn= fo *info, vdagent_send_msg(vd, msg); } =20 +static void vdagent_clipboard_recv_grab(VDAgentChardev *vd, uint8_t s, uin= t32_t size, void *data) +{ + g_autoptr(QemuClipboardInfo) info =3D NULL; + + trace_vdagent_cb_grab_selection(GET_NAME(sel_name, s)); + info =3D qemu_clipboard_info_new(&vd->cbpeer, s); + if (size > sizeof(uint32_t) * 10) { + /* + * spice has 6 types as of 2021. Limiting to 10 entries + * so we we have some wiggle room. + */ + return; + } + while (size >=3D sizeof(uint32_t)) { + trace_vdagent_cb_grab_type(GET_NAME(type_name, *(uint32_t *)data)); + switch (*(uint32_t *)data) { + case VD_AGENT_CLIPBOARD_UTF8_TEXT: + info->types[QEMU_CLIPBOARD_TYPE_TEXT].available =3D true; + break; + default: + break; + } + data +=3D sizeof(uint32_t); + size -=3D sizeof(uint32_t); + } + qemu_clipboard_update(info); +} + +static void vdagent_clipboard_recv_request(VDAgentChardev *vd, uint8_t s, = uint32_t size, void *data) +{ + QemuClipboardType type; + + if (size < sizeof(uint32_t)) { + return; + } + switch (*(uint32_t *)data) { + case VD_AGENT_CLIPBOARD_UTF8_TEXT: + type =3D QEMU_CLIPBOARD_TYPE_TEXT; + break; + default: + return; + } + if (vd->cbinfo[s] && vd->cbinfo[s]->types[type].available && + vd->cbinfo[s]->owner !=3D &vd->cbpeer) { + if (vd->cbinfo[s]->types[type].data) { + vdagent_send_clipboard_data(vd, vd->cbinfo[s], type); + } else { + vd->cbpending[s] |=3D (1 << type); + qemu_clipboard_request(vd->cbinfo[s], type); + } + } +} + +static void vdagent_clipboard_recv_data(VDAgentChardev *vd, uint8_t s, uin= t32_t size, void *data) +{ + QemuClipboardType type; + + if (size < sizeof(uint32_t)) { + return; + } + switch (*(uint32_t *)data) { + case VD_AGENT_CLIPBOARD_UTF8_TEXT: + type =3D QEMU_CLIPBOARD_TYPE_TEXT; + break; + default: + return; + } + data +=3D 4; + size -=3D 4; + qemu_clipboard_set_data(&vd->cbpeer, vd->cbinfo[s], type, size, data, = true); +} + +static void vdagent_clipboard_recv_release(VDAgentChardev *vd, uint8_t s) +{ + g_autoptr(QemuClipboardInfo) info =3D NULL; + + if (vd->cbinfo[s] && vd->cbinfo[s]->owner =3D=3D &vd->cbpeer) { + /* set empty clipboard info */ + info =3D qemu_clipboard_info_new(NULL, s); + qemu_clipboard_update(info); + } +} + static void vdagent_chr_recv_clipboard(VDAgentChardev *vd, VDAgentMessage = *msg) { uint8_t s =3D VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD; uint32_t size =3D msg->size; void *data =3D msg->data; - g_autoptr(QemuClipboardInfo) info =3D NULL; - QemuClipboardType type; =20 if (have_selection(vd)) { if (size < 4) { @@ -455,75 +536,15 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev= *vd, VDAgentMessage *msg) =20 switch (msg->type) { case VD_AGENT_CLIPBOARD_GRAB: - trace_vdagent_cb_grab_selection(GET_NAME(sel_name, s)); - info =3D qemu_clipboard_info_new(&vd->cbpeer, s); - if (size > sizeof(uint32_t) * 10) { - /* - * spice has 6 types as of 2021. Limiting to 10 entries - * so we we have some wiggle room. - */ - return; - } - while (size >=3D sizeof(uint32_t)) { - trace_vdagent_cb_grab_type(GET_NAME(type_name, *(uint32_t *)da= ta)); - switch (*(uint32_t *)data) { - case VD_AGENT_CLIPBOARD_UTF8_TEXT: - info->types[QEMU_CLIPBOARD_TYPE_TEXT].available =3D true; - break; - default: - break; - } - data +=3D sizeof(uint32_t); - size -=3D sizeof(uint32_t); - } - qemu_clipboard_update(info); - break; + return vdagent_clipboard_recv_grab(vd, s, size, data); case VD_AGENT_CLIPBOARD_REQUEST: - if (size < sizeof(uint32_t)) { - return; - } - switch (*(uint32_t *)data) { - case VD_AGENT_CLIPBOARD_UTF8_TEXT: - type =3D QEMU_CLIPBOARD_TYPE_TEXT; - break; - default: - return; - } - if (vd->cbinfo[s] && - vd->cbinfo[s]->types[type].available && - vd->cbinfo[s]->owner !=3D &vd->cbpeer) { - if (vd->cbinfo[s]->types[type].data) { - vdagent_send_clipboard_data(vd, vd->cbinfo[s], type); - } else { - vd->cbpending[s] |=3D (1 << type); - qemu_clipboard_request(vd->cbinfo[s], type); - } - } - break; + return vdagent_clipboard_recv_request(vd, s, size, data); case VD_AGENT_CLIPBOARD: /* data */ - if (size < sizeof(uint32_t)) { - return; - } - switch (*(uint32_t *)data) { - case VD_AGENT_CLIPBOARD_UTF8_TEXT: - type =3D QEMU_CLIPBOARD_TYPE_TEXT; - break; - default: - return; - } - data +=3D 4; - size -=3D 4; - qemu_clipboard_set_data(&vd->cbpeer, vd->cbinfo[s], type, - size, data, true); - break; + return vdagent_clipboard_recv_data(vd, s, size, data); case VD_AGENT_CLIPBOARD_RELEASE: - if (vd->cbinfo[s] && - vd->cbinfo[s]->owner =3D=3D &vd->cbpeer) { - /* set empty clipboard info */ - info =3D qemu_clipboard_info_new(NULL, s); - qemu_clipboard_update(info); - } - break; + return vdagent_clipboard_recv_release(vd, s); + default: + g_assert_not_reached(); } } =20 --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172619695711.8452709727916; Thu, 5 Aug 2021 07:10:19 -0700 (PDT) Received: from localhost ([::1]:58790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBe4g-0001zq-D6 for importer@patchew.org; Thu, 05 Aug 2021 10:10:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdu5-0000Le-Fe for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdu3-0001Gj-O1 for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-fhTlB75dMSqKDxlJjk_vyg-1; Thu, 05 Aug 2021 09:59:17 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1B647107ACF5 for ; Thu, 5 Aug 2021 13:59:17 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8E275FC23; Thu, 5 Aug 2021 13:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171959; 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=WMVDg75DWKVnjKZIFpMUjBxoinJz9SFq0ycXf1oBTLM=; b=ThteJx2xj2YwOhdZDlgDNk6zeVwXJPkvPlVjt0nMuxl6ZE4uA0pQufH/TSy+VaW1oSMoBI RBq5gMmfiAx9mFIDz/RThRVEXDV9uUVRffcaDnv9AgkgmADbJB+i/hm3Igrnc4BhivVqmV V2+JH0zXbVu887QvWjmFEkU59E0O7o0= X-MC-Unique: fhTlB75dMSqKDxlJjk_vyg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 12/18] ui/vdagent: use qemu_clipboard_peer_release helper Date: Thu, 5 Aug 2021 17:57:09 +0400 Message-Id: <20210805135715.857938-13-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172621932100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/vdagent.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 362064213c..99ba34646f 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -507,13 +507,7 @@ static void vdagent_clipboard_recv_data(VDAgentChardev= *vd, uint8_t s, uint32_t =20 static void vdagent_clipboard_recv_release(VDAgentChardev *vd, uint8_t s) { - g_autoptr(QemuClipboardInfo) info =3D NULL; - - if (vd->cbinfo[s] && vd->cbinfo[s]->owner =3D=3D &vd->cbpeer) { - /* set empty clipboard info */ - info =3D qemu_clipboard_info_new(NULL, s); - qemu_clipboard_update(info); - } + qemu_clipboard_peer_release(&vd->cbpeer, s); } =20 static void vdagent_chr_recv_clipboard(VDAgentChardev *vd, VDAgentMessage = *msg) --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172722323775.1593252213196; Thu, 5 Aug 2021 07:12:02 -0700 (PDT) Received: from localhost ([::1]:37516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBe6L-0006hT-9z for importer@patchew.org; Thu, 05 Aug 2021 10:12:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBduH-0000Xp-GP for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBduF-0001OH-C7 for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:33 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-311-ZC8QlEsDMNqiMIAJo-sYNg-1; Thu, 05 Aug 2021 09:59:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90C8F1006C81 for ; Thu, 5 Aug 2021 13:59:28 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DA4160CA1; Thu, 5 Aug 2021 13:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171970; 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=u0HmpFRry6Bd7EerLtz8WUvb4FhCEsupdSo4hWspZzI=; b=SujlH0kR9VBPKFegyFIS9d1AYy46XKA1E8Z9SrVG6CejBczGFCJ5XZRIOx/PUOZNeRzv9G KE0F9bl+rIzfAQ+QipOOpKuLSXmT+/vW1y0mkXEx93J5Hzo4uMTks1uo5ZNWQGEjpy8NMB ubwnteDxN+y+2BlRP0rbTdGFtpDcxuQ= X-MC-Unique: ZC8QlEsDMNqiMIAJo-sYNg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 13/18] ui/vdagent: use qemu_clipboard_info helper Date: Thu, 5 Aug 2021 17:57:10 +0400 Message-Id: <20210805135715.857938-14-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172724363100001 From: Marc-Andr=C3=A9 Lureau The clipboard unit now tracks the current clipboard grab, no need to duplicate this work. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/vdagent.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 99ba34646f..cd07937a4b 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -47,7 +47,6 @@ struct VDAgentChardev { =20 /* clipboard */ QemuClipboardPeer cbpeer; - QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT]; uint32_t cbpending[QEMU_CLIPBOARD_SELECTION__COUNT]; }; typedef struct VDAgentChardev VDAgentChardev; @@ -384,9 +383,7 @@ static void vdagent_clipboard_notify(Notifier *notifier= , void *data) QemuClipboardType type; bool self_update =3D info->owner =3D=3D &vd->cbpeer; =20 - if (info !=3D vd->cbinfo[s]) { - qemu_clipboard_info_unref(vd->cbinfo[s]); - vd->cbinfo[s] =3D qemu_clipboard_info_ref(info); + if (info !=3D qemu_clipboard_info(s)) { vd->cbpending[s] =3D 0; if (!self_update) { vdagent_send_clipboard_grab(vd, info); @@ -464,6 +461,7 @@ static void vdagent_clipboard_recv_grab(VDAgentChardev = *vd, uint8_t s, uint32_t static void vdagent_clipboard_recv_request(VDAgentChardev *vd, uint8_t s, = uint32_t size, void *data) { QemuClipboardType type; + QemuClipboardInfo *info; =20 if (size < sizeof(uint32_t)) { return; @@ -475,13 +473,14 @@ static void vdagent_clipboard_recv_request(VDAgentCha= rdev *vd, uint8_t s, uint32 default: return; } - if (vd->cbinfo[s] && vd->cbinfo[s]->types[type].available && - vd->cbinfo[s]->owner !=3D &vd->cbpeer) { - if (vd->cbinfo[s]->types[type].data) { - vdagent_send_clipboard_data(vd, vd->cbinfo[s], type); + + info =3D qemu_clipboard_info(s); + if (info && info->types[type].available && info->owner !=3D &vd->cbpee= r) { + if (info->types[type].data) { + vdagent_send_clipboard_data(vd, info, type); } else { vd->cbpending[s] |=3D (1 << type); - qemu_clipboard_request(vd->cbinfo[s], type); + qemu_clipboard_request(info, type); } } } @@ -502,7 +501,11 @@ static void vdagent_clipboard_recv_data(VDAgentChardev= *vd, uint8_t s, uint32_t } data +=3D 4; size -=3D 4; - qemu_clipboard_set_data(&vd->cbpeer, vd->cbinfo[s], type, size, data, = true); + + if (qemu_clipboard_peer_owns(&vd->cbpeer, s)) { + qemu_clipboard_set_data(&vd->cbpeer, qemu_clipboard_info(s), + type, size, data, true); + } } =20 static void vdagent_clipboard_recv_release(VDAgentChardev *vd, uint8_t s) --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172832742696.469057184758; Thu, 5 Aug 2021 07:13:52 -0700 (PDT) Received: from localhost ([::1]:43808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBe87-0002Wv-MZ for importer@patchew.org; Thu, 05 Aug 2021 10:13:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBduT-00012P-Iz for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55800) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBduS-0001W3-42 for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-232-gdiDAGNMOoC-2tuVaj6gvA-1; Thu, 05 Aug 2021 09:59:42 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A61787D542 for ; Thu, 5 Aug 2021 13:59:41 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF7E57A8D7; Thu, 5 Aug 2021 13:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171983; 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=JrKLxsCMInCEFmk5wNc4Ylgnbo3tU8MazJOHi5RMFHc=; b=N99H0NbCJgZu33SrQWhpp/kz5plGtmY+SlzaiM+OT8f8k6a6vs50q6L0gnYL9yNNKYSr0b Q9eFTlA3cV4SkM3toGQ3n/2aHeI3jhlQk/itRvI24YttqDlyvFVLT40NaIiH3BancCr3YX ExSEEocyIORozSz3L0lSCnOQROnPqHM= X-MC-Unique: gdiDAGNMOoC-2tuVaj6gvA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 14/18] ui/vdagent: send empty clipboard when unhandled Date: Thu, 5 Aug 2021 17:57:11 +0400 Message-Id: <20210805135715.857938-15-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172834321100001 From: Marc-Andr=C3=A9 Lureau Rather than leaving the agent timing out or hanging, reply to it with an empty result. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/vdagent.c | 12 ++++++++++++ ui/trace-events | 1 + 2 files changed, 13 insertions(+) diff --git a/ui/vdagent.c b/ui/vdagent.c index cd07937a4b..cd49da1ffa 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -375,6 +375,16 @@ static void vdagent_send_clipboard_data(VDAgentChardev= *vd, vdagent_send_msg(vd, msg); } =20 +static void vdagent_send_empty_clipboard_data(VDAgentChardev *vd, + QemuClipboardSelection selec= tion, + QemuClipboardType type) +{ + g_autoptr(QemuClipboardInfo) info =3D qemu_clipboard_info_new(&vd->cbp= eer, selection); + + trace_vdagent_send_empty_clipboard(); + vdagent_send_clipboard_data(vd, info, type); +} + static void vdagent_clipboard_notify(Notifier *notifier, void *data) { VDAgentChardev *vd =3D container_of(notifier, VDAgentChardev, cbpeer.u= pdate); @@ -482,6 +492,8 @@ static void vdagent_clipboard_recv_request(VDAgentChard= ev *vd, uint8_t s, uint32 vd->cbpending[s] |=3D (1 << type); qemu_clipboard_request(info, type); } + } else { + vdagent_send_empty_clipboard_data(vd, s, type); } } =20 diff --git a/ui/trace-events b/ui/trace-events index 1b5f87bc09..b9c0dd0fa1 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -129,6 +129,7 @@ xkeymap_keymap(const char *name) "keymap '%s'" vdagent_open(void) "" vdagent_close(void) "" vdagent_send(const char *name) "msg %s" +vdagent_send_empty_clipboard(void) "" vdagent_recv_chunk(uint32_t size) "size %d" vdagent_recv_msg(const char *name, uint32_t size) "msg %s, size %d" vdagent_peer_cap(const char *name) "cap %s" --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172948084549.5694743817584; Thu, 5 Aug 2021 07:15:48 -0700 (PDT) Received: from localhost ([::1]:50268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBe9z-0006q8-1K for importer@patchew.org; Thu, 05 Aug 2021 10:15:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBduh-0001KU-8h for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39241) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBduf-0001fc-4G for qemu-devel@nongnu.org; Thu, 05 Aug 2021 09:59:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-574-O5qD08SDOnSJEmTf7fsfYA-1; Thu, 05 Aug 2021 09:59:55 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77553801B3C for ; Thu, 5 Aug 2021 13:59:54 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86C591036D35; Thu, 5 Aug 2021 13:59:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628171996; 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=dP9wEBMcHp0NdUWHH/dgCfJlRkLqMnuvtYz2A9UWO6E=; b=Q/H/7PU832eFHQs2IwyLvFOObqqaYdJlBwrHvXITMWefrMVA6w6jJ3lh8PbNIpoh0FRD1M yCShlfp6W0EgLjgu7pECPTQcF7AWOGqsyu0GRvZgvhqnzFoLzqeCN/x8F2CZ1Qwg2Z4vD+ 8mdnVGbzDTkheS51YF1Eb/J7eDy8N/M= X-MC-Unique: O5qD08SDOnSJEmTf7fsfYA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 15/18] ui/gtk-clipboard: use qemu_clipboard_info helper Date: Thu, 5 Aug 2021 17:57:12 +0400 Message-Id: <20210805135715.857938-16-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172949333100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/gtk.h | 1 - ui/gtk-clipboard.c | 14 ++++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 80d6bbd9b5..7835ef1a71 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -143,7 +143,6 @@ struct GtkDisplayState { bool external_pause_update; =20 QemuClipboardPeer cbpeer; - QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT]; uint32_t cbpending[QEMU_CLIPBOARD_SELECTION__COUNT]; GtkClipboard *gtkcb[QEMU_CLIPBOARD_SELECTION__COUNT]; bool cbowner[QEMU_CLIPBOARD_SELECTION__COUNT]; diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 2c78de9500..4e4b3c52bb 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -45,24 +45,24 @@ static void gd_clipboard_get_data(GtkClipboard *cli= pboard, GtkDisplayState *gd =3D data; QemuClipboardSelection s =3D gd_find_selection(gd, clipboard); QemuClipboardType type =3D QEMU_CLIPBOARD_TYPE_TEXT; - QemuClipboardInfo *info =3D qemu_clipboard_info_ref(gd->cbinfo[s]); + g_autoptr(QemuClipboardInfo) info =3D NULL; + + info =3D qemu_clipboard_info_ref(qemu_clipboard_info(s)); =20 qemu_clipboard_request(info, type); - while (info =3D=3D gd->cbinfo[s] && + while (info =3D=3D qemu_clipboard_info(s) && info->types[type].available && info->types[type].data =3D=3D NULL) { main_loop_wait(false); } =20 - if (info =3D=3D gd->cbinfo[s] && gd->cbowner[s]) { + if (info =3D=3D qemu_clipboard_info(s) && gd->cbowner[s]) { gtk_selection_data_set_text(selection_data, info->types[type].data, info->types[type].size); } else { /* clipboard owner changed while waiting for the data */ } - - qemu_clipboard_info_unref(info); } =20 static void gd_clipboard_clear(GtkClipboard *clipboard, @@ -81,9 +81,7 @@ static void gd_clipboard_notify(Notifier *notifier, void = *data) QemuClipboardSelection s =3D info->selection; bool self_update =3D info->owner =3D=3D &gd->cbpeer; =20 - if (info !=3D gd->cbinfo[s]) { - qemu_clipboard_info_unref(gd->cbinfo[s]); - gd->cbinfo[s] =3D qemu_clipboard_info_ref(info); + if (info !=3D qemu_clipboard_info(s)) { gd->cbpending[s] =3D 0; if (!self_update) { GtkTargetList *list; --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172512177880.5693734053161; Thu, 5 Aug 2021 07:08:32 -0700 (PDT) Received: from localhost ([::1]:50750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBe2w-00051B-SN for importer@patchew.org; Thu, 05 Aug 2021 10:08:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdvN-0002kw-Be for qemu-devel@nongnu.org; Thu, 05 Aug 2021 10:00:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50393) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdvK-00028t-NE for qemu-devel@nongnu.org; Thu, 05 Aug 2021 10:00:41 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-228-5uZPLeJMPseX-jpItgixmw-1; Thu, 05 Aug 2021 10:00:36 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36F14875047 for ; Thu, 5 Aug 2021 14:00:36 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F0281981C; Thu, 5 Aug 2021 13:59:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628172038; 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=ITxgO14Xj7S8+2UEORYEt/tjpK+R7WaEXrnMywJK8SI=; b=HpOtlqPSwGTKYMOKt5BlhwQZKkxjcT24RWpM+qzW9Cmt8JR/CL14qJKZOZDMkJoUtiORSv FU7Jg6LQHECkqa3tbrtmjYQmtnDsbtSF4eB01Caph0FEJ6ai+cz6eXixCvrHynVIaCBkF0 dmbX8MOtfrlF2onf+XOS8tyhWNdNUgo= X-MC-Unique: 5uZPLeJMPseX-jpItgixmw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 16/18] ui/vdagent: send release when no clipboard owner Date: Thu, 5 Aug 2021 17:57:13 +0400 Message-Id: <20210805135715.857938-17-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172513958100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/vdagent.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index cd49da1ffa..7d8cb963ff 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -345,6 +345,24 @@ static void vdagent_send_clipboard_grab(VDAgentChardev= *vd, vdagent_send_msg(vd, msg); } =20 +static void vdagent_send_clipboard_release(VDAgentChardev *vd, + QemuClipboardInfo *info) +{ + g_autofree VDAgentMessage *msg =3D g_malloc0(sizeof(VDAgentMessage) + + sizeof(uint32_t)); + + if (have_selection(vd)) { + uint8_t *s =3D msg->data; + *s =3D info->selection; + msg->size +=3D sizeof(uint32_t); + } else if (info->selection !=3D QEMU_CLIPBOARD_SELECTION_CLIPBOARD) { + return; + } + + msg->type =3D VD_AGENT_CLIPBOARD_RELEASE; + vdagent_send_msg(vd, msg); +} + static void vdagent_send_clipboard_data(VDAgentChardev *vd, QemuClipboardInfo *info, QemuClipboardType type) @@ -396,7 +414,11 @@ static void vdagent_clipboard_notify(Notifier *notifie= r, void *data) if (info !=3D qemu_clipboard_info(s)) { vd->cbpending[s] =3D 0; if (!self_update) { - vdagent_send_clipboard_grab(vd, info); + if (info->owner) { + vdagent_send_clipboard_grab(vd, info); + } else { + vdagent_send_clipboard_release(vd, info); + } } return; } --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172276720445.99931049517534; Thu, 5 Aug 2021 07:04:36 -0700 (PDT) Received: from localhost ([::1]:34688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBdz9-0002fm-JZ for importer@patchew.org; Thu, 05 Aug 2021 10:04:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdvT-0002pn-4e for qemu-devel@nongnu.org; Thu, 05 Aug 2021 10:00:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdvQ-0002CP-84 for qemu-devel@nongnu.org; Thu, 05 Aug 2021 10:00:46 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-25-1TCS9fGOMx6SeiJlfmoZ1g-1; Thu, 05 Aug 2021 10:00:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 649B8C73BE for ; Thu, 5 Aug 2021 14:00:41 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 593B91036D27; Thu, 5 Aug 2021 14:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628172043; 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=Jo5ZCM8xI7GoWnJD1j0kh6lkCtRBIRVAHytoh1MC2zw=; b=GmMv4sgt9bw1efNfDLXTTGFd7JH9f/vScEwD904cbjdT7uPZW7aCrGiVtGA1i2iSOZEN8I MWkl0GPhiBLjPXT3RihfMHOg0noYlEMDPQuhUSkxFiw2oe7jcfkI/0EOBR95EfzE78feyc IvnY2L66KpitJ18OKcyF7XEEJg9sWbY= X-MC-Unique: 1TCS9fGOMx6SeiJlfmoZ1g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 17/18] ui/gtk-clipboard: emit release clipboard events Date: Thu, 5 Aug 2021 17:57:14 +0400 Message-Id: <20210805135715.857938-18-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172293719100003 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/gtk-clipboard.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 4e4b3c52bb..35b7a2c228 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -163,6 +163,8 @@ static void gd_owner_change(GtkClipboard *clipboard, qemu_clipboard_info_unref(info); break; default: + qemu_clipboard_peer_release(&gd->cbpeer, s); + gd->cbowner[s] =3D false; break; } } --=20 2.32.0.264.g75ae10bc75 From nobody Sat May 18 07:48:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628172394865370.3294653366477; Thu, 5 Aug 2021 07:06:34 -0700 (PDT) Received: from localhost ([::1]:42182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBe13-0007lw-Oc for importer@patchew.org; Thu, 05 Aug 2021 10:06:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdvY-0002vl-Pw for qemu-devel@nongnu.org; Thu, 05 Aug 2021 10:00:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBdvV-0002Hy-Rc for qemu-devel@nongnu.org; Thu, 05 Aug 2021 10:00:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-563-vU7y6UADPKa6N7HgSvFe4w-1; Thu, 05 Aug 2021 10:00:47 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 625BD100CA89 for ; Thu, 5 Aug 2021 14:00:46 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CA181000186; Thu, 5 Aug 2021 14:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628172048; 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=to95uZafGFonwXR9uWkFz4LxEZMdZ3CnyRt1L1hyKXM=; b=DGYbThRt90097lEp3ssSyBAWkGpT2Q1tYIw7rZEKa7i53NpgbZa7FSGcFU1uQrDNRBjcsC rbUgBQPccZWdvbuiOQqRdEAOgPJskkoAuWN9w0aqTSpAjzEfxEx9z6oGtbShtC7/3Q7eXd rGREy9IrSPNejy45SbjmzwielO8pWtU= X-MC-Unique: vU7y6UADPKa6N7HgSvFe4w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v3 18/18] ui/vdagent: add a migration blocker Date: Thu, 5 Aug 2021 17:57:15 +0400 Message-Id: <20210805135715.857938-19-marcandre.lureau@redhat.com> In-Reply-To: <20210805135715.857938-1-marcandre.lureau@redhat.com> References: <20210805135715.857938-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1628172397011100001 From: Marc-Andr=C3=A9 Lureau The current implementation lacks migration support. After migration, vdagent support will be broken (even after a restart of the daemons). Let's try to fix it in 6.2. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/vdagent.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ui/vdagent.c b/ui/vdagent.c index 7d8cb963ff..603a2a7bd2 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -6,6 +6,7 @@ #include "qemu/option.h" #include "qemu/units.h" #include "hw/qdev-core.h" +#include "migration/blocker.h" #include "ui/clipboard.h" #include "ui/console.h" #include "ui/input.h" @@ -23,6 +24,9 @@ struct VDAgentChardev { Chardev parent; =20 + /* TODO: migration isn't yet supported */ + Error *migration_blocker; + /* config */ bool mouse; bool clipboard; @@ -599,6 +603,10 @@ static void vdagent_chr_open(Chardev *chr, return; #endif =20 + if (migrate_add_blocker(vd->migration_blocker, errp) !=3D 0) { + return; + } + vd->mouse =3D VDAGENT_MOUSE_DEFAULT; if (cfg->has_mouse) { vd->mouse =3D cfg->mouse; @@ -832,6 +840,8 @@ static void vdagent_chr_init(Object *obj) VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(obj); =20 buffer_init(&vd->outbuf, "vdagent-outbuf"); + error_setg(&vd->migration_blocker, + "The vdagent chardev doesn't yet support migration"); } =20 static void vdagent_chr_fini(Object *obj) @@ -840,6 +850,7 @@ static void vdagent_chr_fini(Object *obj) =20 vdagent_disconnect(vd); buffer_free(&vd->outbuf); + error_free(vd->migration_blocker); } =20 static const TypeInfo vdagent_chr_type_info =3D { --=20 2.32.0.264.g75ae10bc75