Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1571394/?format=api
{ "id": 1571394, "url": "http://patchwork.ozlabs.org/api/patches/1571394/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20211221065855.142578-5-marcandre.lureau@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20211221065855.142578-5-marcandre.lureau@redhat.com>", "list_archive_url": null, "date": "2021-12-21T06:58:23", "name": "[PULL,v2,04/36] ui/vdagent: add serial capability support", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "d1dbc53d2aba3bb15c43083407bc025cd38a356f", "submitter": { "id": 66774, "url": "http://patchwork.ozlabs.org/api/people/66774/?format=api", "name": "Marc-André Lureau", "email": "marcandre.lureau@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20211221065855.142578-5-marcandre.lureau@redhat.com/mbox/", "series": [ { "id": 277865, "url": "http://patchwork.ozlabs.org/api/series/277865/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=277865", "date": "2021-12-21T06:58:19", "name": "[PULL,v2,01/36] ui/vdagent: add CHECK_SPICE_PROTOCOL_VERSION", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/277865/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1571394/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1571394/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "bilbo.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=So5P9Ted;\n\tdkim-atps=neutral", "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=<UNKNOWN>)", "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby bilbo.ozlabs.org (Postfix) with ESMTPS id 4JJ6pG5DJYz9s3q\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Dec 2021 18:02:13 +1100 (AEDT)", "from localhost ([::1]:55154 helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1mzZA1-0002Vf-Sv\n\tfor incoming@patchwork.ozlabs.org; Tue, 21 Dec 2021 02:02:09 -0500", "from eggs.gnu.org ([209.51.188.92]:58202)\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <marcandre.lureau@redhat.com>)\n id 1mzZ8T-0002To-UC\n for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:00:33 -0500", "from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55520)\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <marcandre.lureau@redhat.com>)\n id 1mzZ8R-0001kG-SN\n for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:00:33 -0500", "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-48-suZsMAncMyqYMzNHyb2DCw-1; Tue, 21 Dec 2021 02:00:26 -0500", "from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com\n [10.5.11.15])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 947161853020;\n Tue, 21 Dec 2021 07:00:25 +0000 (UTC)", "from localhost (unknown [10.39.208.37])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 3E91077451;\n Tue, 21 Dec 2021 07:00:00 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1640070031;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=BdzU92WGn1A58ygWK4ITnPJIjSHful7PtBJGOw21P0U=;\n b=So5P9TedgbDfjFOsKmvk2MMd4VVbgM8WkCvbA24hV7xESUTqYSFlpEKNrrg63+UOlFGBpc\n Y3EJ+av8kmec5kMnBvBi7rB5GL+jbnNGIZqWkU9bj3NtZsFS3ZFeDgZ1by0rxojWoWSWX/\n FSazkGP7PQjNLOk5mobNNfwvjWmLyw8=", "X-MC-Unique": "suZsMAncMyqYMzNHyb2DCw-1", "From": "marcandre.lureau@redhat.com", "To": "qemu-devel@nongnu.org", "Subject": "[PULL v2 04/36] ui/vdagent: add serial capability support", "Date": "Tue, 21 Dec 2021 10:58:23 +0400", "Message-Id": "<20211221065855.142578-5-marcandre.lureau@redhat.com>", "In-Reply-To": "<20211221065855.142578-1-marcandre.lureau@redhat.com>", "References": "<20211221065855.142578-1-marcandre.lureau@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.15", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=170.10.133.124;\n envelope-from=marcandre.lureau@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com", "X-Spam_score_int": "-29", "X-Spam_score": "-3.0", "X-Spam_bar": "---", "X-Spam_report": "(-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,\n SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no", "X-Spam_action": "no action", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "peter.maydell@linaro.org, richard.henderson@linaro.org, =?utf-8?q?Marc-A?=\n\t=?utf-8?q?ndr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "From: Marc-André Lureau <marcandre.lureau@redhat.com>\n\nThe Spice agent implements a simple serial mechanism to avoid clipboard\nraces between client & guest. See:\nhttps://gitlab.freedesktop.org/spice/spice-protocol/-/commit/045a6978d6dbbf7046affc5c321fa8177c8cce56\n\nSigned-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>\nAcked-by: Gerd Hoffmann <kraxel@redhat.com>\n---\n include/ui/clipboard.h | 4 ++++\n ui/vdagent.c | 39 ++++++++++++++++++++++++++++++++++++++-\n ui/trace-events | 1 +\n 3 files changed, 43 insertions(+), 1 deletion(-)", "diff": "diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h\nindex d82cf314811c..e590b453c8b7 100644\n--- a/include/ui/clipboard.h\n+++ b/include/ui/clipboard.h\n@@ -102,6 +102,8 @@ struct QemuClipboardNotify {\n * @owner: clipboard owner.\n * @selection: clipboard selection.\n * @types: clipboard data array (one entry per type).\n+ * @has_serial: whether @serial is available.\n+ * @serial: the grab serial counter.\n *\n * Clipboard content data and metadata.\n */\n@@ -109,6 +111,8 @@ struct QemuClipboardInfo {\n uint32_t refcount;\n QemuClipboardPeer *owner;\n QemuClipboardSelection selection;\n+ bool has_serial;\n+ uint32_t serial;\n struct {\n bool available;\n bool requested;\ndiff --git a/ui/vdagent.c b/ui/vdagent.c\nindex de827aad27ab..b4fdae69177f 100644\n--- a/ui/vdagent.c\n+++ b/ui/vdagent.c\n@@ -59,6 +59,7 @@ struct VDAgentChardev {\n \n /* clipboard */\n QemuClipboardPeer cbpeer;\n+ uint32_t last_serial[QEMU_CLIPBOARD_SELECTION__COUNT];\n uint32_t cbpending[QEMU_CLIPBOARD_SELECTION__COUNT];\n };\n typedef struct VDAgentChardev VDAgentChardev;\n@@ -203,6 +204,9 @@ static void vdagent_send_caps(VDAgentChardev *vd)\n if (vd->clipboard) {\n caps->caps[0] |= (1 << VD_AGENT_CAP_CLIPBOARD_BY_DEMAND);\n caps->caps[0] |= (1 << VD_AGENT_CAP_CLIPBOARD_SELECTION);\n+#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 1)\n+ caps->caps[0] |= (1 << VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL);\n+#endif\n }\n \n vdagent_send_msg(vd, msg);\n@@ -333,7 +337,8 @@ static void vdagent_send_clipboard_grab(VDAgentChardev *vd,\n {\n g_autofree VDAgentMessage *msg =\n g_malloc0(sizeof(VDAgentMessage) +\n- sizeof(uint32_t) * (QEMU_CLIPBOARD_TYPE__COUNT + 1));\n+ sizeof(uint32_t) * (QEMU_CLIPBOARD_TYPE__COUNT + 1) +\n+ sizeof(uint32_t));\n uint8_t *s = msg->data;\n uint32_t *data = (uint32_t *)msg->data;\n uint32_t q, type;\n@@ -346,6 +351,19 @@ static void vdagent_send_clipboard_grab(VDAgentChardev *vd,\n return;\n }\n \n+#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 1)\n+ if (vd->caps & (1 << VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL)) {\n+ if (!info->has_serial) {\n+ /* client should win */\n+ info->serial = vd->last_serial[info->selection]++;\n+ info->has_serial = true;\n+ }\n+ *data = info->serial;\n+ data++;\n+ msg->size += sizeof(uint32_t);\n+ }\n+#endif\n+\n for (q = 0; q < QEMU_CLIPBOARD_TYPE__COUNT; q++) {\n type = type_qemu_to_vdagent(q);\n if (type != VD_AGENT_CLIPBOARD_NONE && info->types[q].available) {\n@@ -494,6 +512,24 @@ static void vdagent_clipboard_recv_grab(VDAgentChardev *vd, uint8_t s, uint32_t\n \n trace_vdagent_cb_grab_selection(GET_NAME(sel_name, s));\n info = qemu_clipboard_info_new(&vd->cbpeer, s);\n+#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 1)\n+ if (vd->caps & (1 << VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL)) {\n+ if (size < sizeof(uint32_t)) {\n+ /* this shouldn't happen! */\n+ return;\n+ }\n+\n+ info->has_serial = true;\n+ info->serial = *(uint32_t *)data;\n+ if (info->serial < vd->last_serial[s]) {\n+ /* discard lower-ordering guest grab */\n+ return;\n+ }\n+ vd->last_serial[s] = info->serial;\n+ data += sizeof(uint32_t);\n+ size -= sizeof(uint32_t);\n+ }\n+#endif\n if (size > sizeof(uint32_t) * 10) {\n /*\n * spice has 6 types as of 2021. Limiting to 10 entries\n@@ -671,6 +707,7 @@ static void vdagent_chr_recv_caps(VDAgentChardev *vd, VDAgentMessage *msg)\n qemu_input_handler_activate(vd->mouse_hs);\n }\n if (have_clipboard(vd) && vd->cbpeer.notifier.notify == NULL) {\n+ memset(vd->last_serial, 0, sizeof(vd->last_serial));\n vd->cbpeer.name = \"vdagent\";\n vd->cbpeer.notifier.notify = vdagent_clipboard_notify;\n vd->cbpeer.request = vdagent_clipboard_request;\ndiff --git a/ui/trace-events b/ui/trace-events\nindex b9c0dd0fa11d..e832c3e3659d 100644\n--- a/ui/trace-events\n+++ b/ui/trace-events\n@@ -135,3 +135,4 @@ vdagent_recv_msg(const char *name, uint32_t size) \"msg %s, size %d\"\n vdagent_peer_cap(const char *name) \"cap %s\"\n vdagent_cb_grab_selection(const char *name) \"selection %s\"\n vdagent_cb_grab_type(const char *name) \"type %s\"\n+vdagent_cb_serial_discard(uint32_t current, uint32_t received) \"current=%u, received=%u\"\n", "prefixes": [ "PULL", "v2", "04/36" ] }