From nobody Thu Apr  3 20:57:23 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=smartx.com
ARC-Seal: i=1; a=rsa-sha256; t=1742528457; cv=none;
	d=zohomail.com; s=zohoarc;
	b=Eg+7CNTbuH3yFsE//jtsB1BPQ/poibbrUBz4rzLLnV6PnZomgp1CzvC+PTnc6w7zBUZ0lFnsBOBn8b7DONeGQagytd7vGZUkb93fFtuAMUVtG41n4a2nv/3De69r7ZdiYnjBS2XW4GHYw9VRIoyiFnebUtPxNx1IvwbV/ldbLwk=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1742528457;
 h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To;
	bh=n1hCtd9dYunSUjFNV0cjKUZjR/xU72XhqBS5IQVPKFA=;
	b=KJMgGaCUOf25pJdWU45PhOSQOfy/Izk43Yd5LASGDd8gKEoLTUxbRxhqk+etg8VMpq1LiRCsMle8JE4haTQuYMfwwl2xURzRrY6o2PqPi1nplqdu2kgSImFrY9wc5gsWe4W5J2OWuRuwbOj9H7tQwuHZCiDnvxpJ8ojrQ8w2ihs=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail header.from=<yong.huang@smartx.com> (p=none dis=none)
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1742528457263622.1124951911814;
 Thu, 20 Mar 2025 20:40:57 -0700 (PDT)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tvTFB-000344-2R; Thu, 20 Mar 2025 23:40:25 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yong.huang@smartx.com>)
 id 1tvTEz-0002uo-CF
 for qemu-devel@nongnu.org; Thu, 20 Mar 2025 23:40:14 -0400
Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <yong.huang@smartx.com>)
 id 1tvTEw-0007zR-58
 for qemu-devel@nongnu.org; Thu, 20 Mar 2025 23:40:12 -0400
Received: by mail-pl1-x631.google.com with SMTP id
 d9443c01a7336-2243803b776so7205ad.0
 for <qemu-devel@nongnu.org>; Thu, 20 Mar 2025 20:40:09 -0700 (PDT)
Received: from Hyman-Dev-Euler.zelin.local ([103.85.74.93])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-227811b8075sm6079725ad.128.2025.03.20.20.40.06
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 20 Mar 2025 20:40:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1742528408; x=1743133208;
 darn=nongnu.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=n1hCtd9dYunSUjFNV0cjKUZjR/xU72XhqBS5IQVPKFA=;
 b=Fl/eYsvF71/vcJRCbfJmcJBMjUeJ1MgFV90xSOdUtSGvVv88FXtH6/qDphnDUUwgyo
 e0HtlSVy4RRFePD3nof7GXSVWHluQMWJV3H//exDEI181VdCHtFOEjIQHT+/bKQSZ6R1
 Z6Ouyph4gTlNAkV27B2jZrwMjALCWLeLIM6B15RDJjxCAZixFHaoceSLaCXz4E3HSBYO
 S/or4DUn5aQ9ENotU1jKKfgm9xqQAiYxiirazkdiNh1Y2WeOKQrwg3dshlT0PCMmziR6
 3a5+fhkRmfsxcOf3CdkBb4Wk5uIR9BgX3WAN2dU5RsVStT8jN25IuY/xjLSsiWQ8IAAN
 QfCw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742528408; x=1743133208;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=n1hCtd9dYunSUjFNV0cjKUZjR/xU72XhqBS5IQVPKFA=;
 b=qkhpKcCZ0tgPm6LlkHCJ0o7PbHjTBPlJOMUia8mNAb5jwKzFrQyqnQVcsdmy+0TVeb
 VKEmQuPPpjZyGv/3ioOw8sZyPkV/94ZBgD1T0fq5y6+EZbWbFfBV28NOb5Sl7pY71l0h
 sOyC78kCQf486Ij9s1uJ5d9Or27pAFsA2WZPALfLV5DKShK3vQSWPRGKVIx2wfcHVYPs
 xlRdxP30FhCxuFKX/fi4CRYp2yJP3DKFy7fTupVUitAgLI7SX4BJb1XyBInMuxBrDMId
 /r0Hau40ivun1VeYU/kB+Llnnc2yOebRY22ESEBMnV1yOG6fLU1o94OXeAW54KHUuL1j
 gtsw==
X-Gm-Message-State: AOJu0YzzGmdoAUCo7u+Jxox+6P09vayhGhyB7Mj+r5j93LRzckkLOkOP
 XfjWgXYLWrAOaeMFGE0GGMVBCj4UePcQxINzevACIjiqjaA+phd9tHG5839qLZWXYUKGzmDmF+6
 OjiyjE7+d
X-Gm-Gg: ASbGncvUGua/usken5myItIFIZSA9rryko1NQDC/zb86Y7sJTcJ6mpZ8LdlO6cD04JA
 llR0r+tjuq0/cRFK/WePPJGEB3PpiC9RXwO9NKjQuezu+8ZwzWT+zJBVsu99ijedwg9TYXAnakM
 acM+d5iKsHlkWIh8tp9d69OhHSFX++wFn4ITaa4I9OM/Ht4CdZZg3naD7XXO08VPVoBYFlMJaI2
 T4nZ9g+NNHwPj++cPiK1DqqZ+9dTb8sqvoG9MowC9sBQHs/EzLk2i34YOFoKf+egPD5AyadZKaF
 PH5N0i8/9ni5BDAml3/cmXDMLVAgDKWnxrxh9V7vxYqR7vb4G/bK0mFhy9B66sSoeg==
X-Google-Smtp-Source: 
 AGHT+IFd/u6L10FCROZawOIVPLR6+iJiVVLG8HGp7aNxQ2g/y+SvD/LyhCYWUcNELXIWhBZcYbbfow==
X-Received: by 2002:a17:902:d4c5:b0:216:644f:bc0e with SMTP id
 d9443c01a7336-22780d83716mr30101705ad.24.1742528408057;
 Thu, 20 Mar 2025 20:40:08 -0700 (PDT)
From: yong.huang@smartx.com
To: qemu-devel@nongnu.org
Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>,
 Hyman Huang <yong.huang@smartx.com>, dengpc12@chinatelecom.cn
Subject: [RFC 1/3] vdagent: Wrap vdagent_register_to_qemu_clipboard function
Date: Fri, 21 Mar 2025 11:38:11 +0800
Message-Id: 
 <3a43d9d9816bc883e4e5a5b4999d6a7f03433a5e.1742527956.git.yong.huang@smartx.com>
X-Mailer: git-send-email 2.27.0
In-Reply-To: <cover.1742527956.git.yong.huang@smartx.com>
References: <cover.1742527956.git.yong.huang@smartx.com>
MIME-Version: 1.0
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=2607:f8b0:4864:20::631;
 envelope-from=yong.huang@smartx.com; helo=mail-pl1-x631.google.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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>,
 <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>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org
X-ZohoMail-DKIM: pass (identity @smartx-com.20230601.gappssmtp.com)
X-ZM-MESSAGEID: 1742528458701019000
Content-Type: text/plain; charset="utf-8"

From: Hyman Huang <yong.huang@smartx.com>

For direct use in the upcoming commit, wrap the vdagent
registry logic as vdagent_register_to_qemu_clipboard.

Meanwhile, add a trace event for vdagent_recv_caps.

Signed-off-by: Hyman Huang <yong.huang@smartx.com>
---
 ui/trace-events |  1 +
 ui/vdagent.c    | 23 ++++++++++++++++-------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/ui/trace-events b/ui/trace-events
index 3da0d5e280..427a8383cb 100644
--- a/ui/trace-events
+++ b/ui/trace-events
@@ -140,6 +140,7 @@ 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_recv_caps(uint32_t caps) "received caps %u"
 vdagent_peer_cap(const char *name) "cap %s"
 vdagent_cb_grab_selection(const char *name) "selection %s"
 vdagent_cb_grab_discard(const char *name, int cur, int recv) "selection %s=
, cur:%d recv:%d"
diff --git a/ui/vdagent.c b/ui/vdagent.c
index 724eff972f..7a1cf674d0 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -694,6 +694,18 @@ static void vdagent_chr_open(Chardev *chr,
     *be_opened =3D true;
 }
=20
+static void vdagent_register_to_qemu_clipboard(VDAgentChardev *vd)
+{
+    if (vd->cbpeer.notifier.notify =3D=3D NULL) {
+        qemu_clipboard_reset_serial();
+
+        vd->cbpeer.name =3D "vdagent";
+        vd->cbpeer.notifier.notify =3D vdagent_clipboard_notify;
+        vd->cbpeer.request =3D vdagent_clipboard_request;
+        qemu_clipboard_peer_register(&vd->cbpeer);
+    }
+}
+
 static void vdagent_chr_recv_caps(VDAgentChardev *vd, VDAgentMessage *msg)
 {
     VDAgentAnnounceCapabilities *caps =3D (void *)msg->data;
@@ -711,6 +723,8 @@ static void vdagent_chr_recv_caps(VDAgentChardev *vd, V=
DAgentMessage *msg)
     }
=20
     vd->caps =3D caps->caps[0];
+    trace_vdagent_recv_caps(vd->caps);
+
     if (caps->request) {
         vdagent_send_caps(vd, false);
     }
@@ -720,13 +734,8 @@ static void vdagent_chr_recv_caps(VDAgentChardev *vd, =
VDAgentMessage *msg)
=20
     memset(vd->last_serial, 0, sizeof(vd->last_serial));
=20
-    if (have_clipboard(vd) && vd->cbpeer.notifier.notify =3D=3D NULL) {
-        qemu_clipboard_reset_serial();
-
-        vd->cbpeer.name =3D "vdagent";
-        vd->cbpeer.notifier.notify =3D vdagent_clipboard_notify;
-        vd->cbpeer.request =3D vdagent_clipboard_request;
-        qemu_clipboard_peer_register(&vd->cbpeer);
+    if (have_clipboard(vd)) {
+        vdagent_register_to_qemu_clipboard(vd);
     }
 }
=20
--=20
2.27.0
From nobody Thu Apr  3 20:57:23 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=smartx.com
ARC-Seal: i=1; a=rsa-sha256; t=1742528461; cv=none;
	d=zohomail.com; s=zohoarc;
	b=eMB3NpDILk45OIRJkQ3QYZ4znwXYQq2sqgTcPGk4ieW200OxfsugaEc5X4ZJr8Q3fu7nGYsz931Hhi3SPdAylN1LS3KoAlny2G7qZ8wRKb4vrYgZ6s1kDmRSGDXIPdLgnDJ4GBqq9wb4gJNvTn9HNRMBaEtn8MvjfZ9FaQ8LrQw=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1742528461;
 h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To;
	bh=NfKOJTQOYbrs0vGr3dO1ve34x5rJ0Tkuk4SBJVbV9Z4=;
	b=aMmAlQrQwt1U2H/x+SW0F4Vz+kNlwbRsvVl5tZEi9IPw08Rc3szrd83LhS5C3jB6nYjDKMSZQ45S0nFbHKiTD2TFNpYvgemTyQPuvNVPhOg4Nlfkk9fI3Mw9hSmiIwS1EKu+Z0++kldypfEjG/WwH2Om3NFp8q0I8BV9XB/GuBM=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail header.from=<yong.huang@smartx.com> (p=none dis=none)
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1742528461056716.1623552366457;
 Thu, 20 Mar 2025 20:41:01 -0700 (PDT)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tvTFA-00033s-Vu; Thu, 20 Mar 2025 23:40:25 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yong.huang@smartx.com>)
 id 1tvTF2-0002zB-RW
 for qemu-devel@nongnu.org; Thu, 20 Mar 2025 23:40:16 -0400
Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <yong.huang@smartx.com>)
 id 1tvTEy-0007zq-1h
 for qemu-devel@nongnu.org; Thu, 20 Mar 2025 23:40:16 -0400
Received: by mail-pl1-x62b.google.com with SMTP id
 d9443c01a7336-223f4c06e9fso25560765ad.1
 for <qemu-devel@nongnu.org>; Thu, 20 Mar 2025 20:40:11 -0700 (PDT)
Received: from Hyman-Dev-Euler.zelin.local ([103.85.74.93])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-227811b8075sm6079725ad.128.2025.03.20.20.40.08
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 20 Mar 2025 20:40:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1742528410; x=1743133210;
 darn=nongnu.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=NfKOJTQOYbrs0vGr3dO1ve34x5rJ0Tkuk4SBJVbV9Z4=;
 b=YuFZzfPiVAuq3nypDmMn1tCo21Oz8ihyzFmbf/RxJoFPGdTshxazrYEmbHib6OFqbL
 S/eWiXDVkB50LbzxldGjfZDr1njc8vGtj5cMH0r+SKXcU9q3IHjWv9as4CKjHMghmtxY
 8Kp0Gbj5C8JIPW0vzsCgziURT6M+TrCdFSsCqGPPFne4GinfhR+IqilqYS3bbCsjTHBO
 YwjyvzBuOhrWwpSSKJl7kpgeK76QWkEVdsv0t2neWHVgTcFDVSjzHuYUH0w9FO3hib1w
 xkclTl7d68+6H8ZVavp/kaxhjQjiNusX/fap2WIaJXs1zybeRqCPEIlz9Bpg0QVTzpk1
 LBUQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742528410; x=1743133210;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=NfKOJTQOYbrs0vGr3dO1ve34x5rJ0Tkuk4SBJVbV9Z4=;
 b=t9XUE9AjKl4HQe7uCWd5ycSNIssdf1O4ecZvjSn5M3LCYhE84/N/jh/AMbRYWDcJhb
 +L8DdDtfXppIJP0FyRl+5Qw1Re30peHBz8Eb0xgunAWr+T8n7DD/2SkM0AAk0AT7f0qx
 /BImgYE/itGtg+4tdEICzp1pt5PcQaRdGzF7dSg54tNPvBPvi1isqKedlZYWNb7PY0Xv
 VhHHNGsBoRztfCfLSldO+zuapNtErQzv6/wX3nCT5hyjqCUC9qQiNMursOZ6aJ9t866k
 plG2b4Vz661hickzxGXW9c6noIEnw2ZuYsfMo07LGkQ9SE3xbO0IpjovPvAHIXUNtqpl
 juYw==
X-Gm-Message-State: AOJu0YylvOhSJmmLjYK8IR9oSXgAbbskkYNKraOo7Sdvq+ErueVcwmv1
 vBW31+IRMa8IDhRP3iglfkfiy+6ywpH9LjSiOy4Zk2Cfj1Tpfsaqlc79VwBVYPs57AeIJ6pA4H7
 PuWVYTaA6
X-Gm-Gg: ASbGncsGDUTItU45bmEVWJbJLfnfejfV5o7/0bXTJ+pvokax02Z7LADzx1OoT6S3pTA
 mkWjc33S4Lf8sXs0xnxG6s31i+NQA76ACGtGCFe77HEYgWvPQu6R2Pqt4OkV7N9pyp1mB+vWNhh
 L/uUTlqk0x4paK2Wm3k55BxWFmzOMlq/1SqsxpWy+fjQNj56DSbSuM6KXraA0Edm+nGqFyudsaG
 5RWEEbguHUsJF69S9nsGf16jNI9l+DPKXEhQuGYJ6wxeRiLJXYxc6KgOTTPqRE/g2i2SH0a9SOo
 rZEaiqs7njKBSfY1mZIc0uTqC70MffzFG9Algtug5DCebhXH6GMQnEzdCXTIAB+l0g==
X-Google-Smtp-Source: 
 AGHT+IGytROYCv3EdDQ2BN/8KuwRYYXcSxc2zq96F8D0vDp4poV6FcDQanb7BetzxrUahZaLTWq2OQ==
X-Received: by 2002:a17:902:d9d0:b0:21f:6d63:6f4f with SMTP id
 d9443c01a7336-2265e67fa37mr76457265ad.2.1742528409762;
 Thu, 20 Mar 2025 20:40:09 -0700 (PDT)
From: yong.huang@smartx.com
To: qemu-devel@nongnu.org
Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>,
 Hyman Huang <yong.huang@smartx.com>, dengpc12@chinatelecom.cn
Subject: [RFC 2/3] vdagent: Set up mouse and clipboard after live migration
Date: Fri, 21 Mar 2025 11:38:12 +0800
Message-Id: 
 <3c9498ef25fd8c5f705a4c6ee2dc46666c322ada.1742527956.git.yong.huang@smartx.com>
X-Mailer: git-send-email 2.27.0
In-Reply-To: <cover.1742527956.git.yong.huang@smartx.com>
References: <cover.1742527956.git.yong.huang@smartx.com>
MIME-Version: 1.0
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=2607:f8b0:4864:20::62b;
 envelope-from=yong.huang@smartx.com; helo=mail-pl1-x62b.google.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_NONE=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>,
 <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>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org
X-ZohoMail-DKIM: pass (identity @smartx-com.20230601.gappssmtp.com)
X-ZM-MESSAGEID: 1742528462513019000
Content-Type: text/plain; charset="utf-8"

From: Hyman Huang <yong.huang@smartx.com>

The struct VDAgentChardev's caps, last_serial, and cbpending
fields need to be migrated in order to allow live migration
for vdagent. And the clipboard and mouse should be configured
to correspond with the previously negotiated caps on the
destination.

Signed-off-by: Hyman Huang <yong.huang@smartx.com>
---
 ui/vdagent.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/ui/vdagent.c b/ui/vdagent.c
index 7a1cf674d0..4635e8fa56 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -7,6 +7,7 @@
 #include "qemu/units.h"
 #include "hw/qdev-core.h"
 #include "migration/blocker.h"
+#include "migration/vmstate.h"
 #include "ui/clipboard.h"
 #include "ui/console.h"
 #include "ui/input.h"
@@ -912,6 +913,72 @@ static void vdagent_chr_parse(QemuOpts *opts, ChardevB=
ackend *backend,
     cfg->clipboard =3D qemu_opt_get_bool(opts, "clipboard", VDAGENT_CLIPBO=
ARD_DEFAULT);
 }
=20
+static void vdagent_release_clipboard_all_types(VDAgentChardev *vd,
+                                                QemuClipboardSelection s)
+{
+    uint32_t type;
+
+    for (type =3D 0; type < QEMU_CLIPBOARD_TYPE__COUNT; type++) {
+        if (vd->cbpending[s] & (1 << type)) {
+            vd->cbpending[s] &=3D ~(1 << type);
+            g_autofree VDAgentMessage *msg =3D
+                g_malloc0(sizeof(VDAgentMessage) + sizeof(uint32_t));
+
+            uint8_t *selection =3D msg->data;
+            *selection =3D s;
+            msg->size +=3D sizeof(uint32_t);
+            msg->type =3D VD_AGENT_CLIPBOARD_RELEASE;
+
+            vdagent_send_msg(vd, msg);
+        }
+    }
+}
+
+static int vdagent_post_load(void *opaque, int version_id)
+{
+    VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(opaque);
+    QemuClipboardSelection s =3D QEMU_CLIPBOARD_SELECTION_CLIPBOARD;
+
+    if (vd->caps) {
+        if (have_mouse(vd)) {
+            vd->mouse_hs =3D
+                qemu_input_handler_register(&vd->mouse_dev,
+                                            &vdagent_mouse_handler);
+            if (vd->mouse_hs) {
+                qemu_input_handler_activate(vd->mouse_hs);
+            }
+        }
+
+        if (have_clipboard(vd)) {
+            vdagent_register_to_qemu_clipboard(vd);
+            if (have_selection(vd)) {
+                for (; s < QEMU_CLIPBOARD_SELECTION__COUNT; s++) {
+                    vdagent_release_clipboard_all_types(vd, s);
+                }
+            } else {
+                vdagent_release_clipboard_all_types(vd, s);
+            }
+        }
+    }
+
+    return 0;
+}
+
+static const VMStateDescription vmstate_vdagent =3D {
+    .name =3D "vdagent",
+    .version_id =3D 1,
+    .minimum_version_id =3D 1,
+    .post_load =3D vdagent_post_load,
+    .fields =3D (VMStateField[]){
+        VMSTATE_UINT32(caps, VDAgentChardev),
+        VMSTATE_UINT32_ARRAY(last_serial, VDAgentChardev,
+                QEMU_CLIPBOARD_SELECTION__COUNT),
+        VMSTATE_UINT32_ARRAY(cbpending, VDAgentChardev,
+                QEMU_CLIPBOARD_SELECTION__COUNT),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 /* ------------------------------------------------------------------ */
=20
 static void vdagent_chr_class_init(ObjectClass *oc, void *data)
@@ -930,6 +997,7 @@ static void vdagent_chr_init(Object *obj)
     VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(obj);
=20
     buffer_init(&vd->outbuf, "vdagent-outbuf");
+    vmstate_register(NULL, 0, &vmstate_vdagent, vd);
     error_setg(&vd->migration_blocker,
                "The vdagent chardev doesn't yet support migration");
 }
--=20
2.27.0
From nobody Thu Apr  3 20:57:23 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail(p=none dis=none)  header.from=smartx.com
ARC-Seal: i=1; a=rsa-sha256; t=1742528467; cv=none;
	d=zohomail.com; s=zohoarc;
	b=GNKA6cKFDomUCbYLfaBLT1hSxa5uWHUUpIuGgsd+6Ym1055PhmLwRfb8NoRvSTV6AroBUw3muE/kDblDG3Q/x4Uba0iFYhHnUPM30YNJf4HUeV/vDcAIBRBYTVR5dpzmBeBcpFFBtzCbmvLWQQvk8S9YSeyeaybDbWyeQrwIaJo=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1742528467;
 h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To;
	bh=/kByEk8Ezb+MN3eJtjKV8YMAmgK1UNNA7qz2bIqmhrE=;
	b=QfU9IO//hTg9GL2vCYSY0RUMrq88IRzJasZHd054FMVBgZXZEDVTuoPBRYkP8HB8QtCk7+eqwamnRGyso9U9K3CNmNO9a0ipzuECYBbpWsXC1ko1e2bvw6d637+e4JMip9PqbGlQwlKXPqT4Puj6KYqOBn8W4WkOSYraoDztXPE=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=fail header.from=<yong.huang@smartx.com> (p=none dis=none)
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1742528467371639.0057609501862;
 Thu, 20 Mar 2025 20:41:07 -0700 (PDT)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tvTF9-00032c-JO; Thu, 20 Mar 2025 23:40:23 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yong.huang@smartx.com>)
 id 1tvTF1-0002wy-Ct
 for qemu-devel@nongnu.org; Thu, 20 Mar 2025 23:40:16 -0400
Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <yong.huang@smartx.com>)
 id 1tvTEz-00080E-Dn
 for qemu-devel@nongnu.org; Thu, 20 Mar 2025 23:40:15 -0400
Received: by mail-pl1-x62b.google.com with SMTP id
 d9443c01a7336-2243803b776so7815ad.0
 for <qemu-devel@nongnu.org>; Thu, 20 Mar 2025 20:40:13 -0700 (PDT)
Received: from Hyman-Dev-Euler.zelin.local ([103.85.74.93])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-227811b8075sm6079725ad.128.2025.03.20.20.40.10
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 20 Mar 2025 20:40:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1742528411; x=1743133211;
 darn=nongnu.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=/kByEk8Ezb+MN3eJtjKV8YMAmgK1UNNA7qz2bIqmhrE=;
 b=kh4yb1YraM1Ab2zIjMUHdgay+bR+bcKe3mynm+m8z6OErgj9s1+zsKdsDUqdIuElFV
 lIV1yd11lyqjgPvgRqY1ocam8ejS4ErVI2UI59b5m5WLi4P1OTOAGWHr4jZrJYChncJv
 rB9DM//lrucraelTYwZxehv98S5eQBUzi07iPlyzTmYPl6x8Z/b3ZQUz/nzN6mug4CEq
 wAFMs+vuaI+bqsAAAK0KpIrH20l5qbjX6S/Yb2rCV4YACer54bQmWWexylRRO+0XuENx
 vzc5PTn16T/pDRbQCHSBW1mJpo31WEHSiyLDjM054mnK4aIsCp+H8vXJBr5BuKPoRxD6
 hvig==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742528411; x=1743133211;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=/kByEk8Ezb+MN3eJtjKV8YMAmgK1UNNA7qz2bIqmhrE=;
 b=gRkbKu86Vfm+/Cn6Ut8VWcfri6+VqLPWGkqSipI1XxG0Z4FwjjS7puwVu/qgCkfmwU
 tBmcEYoaZGqjm0PqstnW0fgxWzjL0IpPXmgV/P3YQR7o4CEJj3O2/B3GmeKQ3o+MHZFf
 FmgSbSaqvNpDqOB5SOh6ALzUOL3HysXd8NDYVCCnbBf2FUa2alkQM+W0wt1DBwzvyC0Q
 jErehQxaWrtHi/eYizmgVCANXnu6UPQbfmhdD7hUR9tCgpAIWQnNx62yLPkjdGZJXuPf
 nRBsRaFdbeaexHP3AisBKDfgJR+uMhUy59MHQEYNSr4Ic9t+kpE8yXMHerADlFYie2Ty
 6Zpg==
X-Gm-Message-State: AOJu0YwBMV+Qx87RtyYN3M9J3gQZteGcNVAY31952NanIRSA2kGPzr/g
 B0V8L4e2XsTLvF3PsEfjy5gi6sQ1JkmIlti0yra0x1yadb/9vq/ugMz+63of1hcHCDkGuX9N/a+
 F0UUbwDvl
X-Gm-Gg: ASbGncs1Otlk6dY+187cXFehntdfas/h8BjwGEhZyngk8IHnNMyl2y/n+F5Yh1mpJee
 2Eux0TBB2/ih2bXs/rpt3Fk2Yl6oMJjZSzEF7iUZZldzqDSDjkqsCRDFA4Vduxeh7H/WjwY/Lc1
 /ynr3LrqpDMToTZE53BM7nfl7y5pyc4FvmwUybxm4UCxS7L/WJJ/GMBT+JxiQWxBOMM8Ryfj5dI
 SlHLRPbjWC6CDpscwodRhK3Qg7oOERTuOabrQFYFMYoquHo1x8iYyIxDT4h4Vv9KDIhZ6yfZCU/
 kQS0oHLhh2oRcvGldi2pdVJgV+y0d796NERxUZoiGZy13MRnF/EwpsgND14HlE0kVQ==
X-Google-Smtp-Source: 
 AGHT+IHpvR62fNkaBd5UeLAcRxSKjSbM3zgDh2KyVM+gyDC0wpvpfyXMmxFS4OKH7tcxaGJdGTOvwg==
X-Received: by 2002:a17:903:2d2:b0:223:6744:bfb9 with SMTP id
 d9443c01a7336-22780e02a15mr34789405ad.41.1742528411534;
 Thu, 20 Mar 2025 20:40:11 -0700 (PDT)
From: yong.huang@smartx.com
To: qemu-devel@nongnu.org
Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>,
 Hyman Huang <yong.huang@smartx.com>, dengpc12@chinatelecom.cn
Subject: [RFC 3/3] vdagent: Drop blocker to support migration
Date: Fri, 21 Mar 2025 11:38:13 +0800
Message-Id: 
 <428847678b4d47b4469236da2d888db18cc4c31c.1742527956.git.yong.huang@smartx.com>
X-Mailer: git-send-email 2.27.0
In-Reply-To: <cover.1742527956.git.yong.huang@smartx.com>
References: <cover.1742527956.git.yong.huang@smartx.com>
MIME-Version: 1.0
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=2607:f8b0:4864:20::62b;
 envelope-from=yong.huang@smartx.com; helo=mail-pl1-x62b.google.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_NONE=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>,
 <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>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org
X-ZohoMail-DKIM: pass (identity @smartx-com.20230601.gappssmtp.com)
X-ZM-MESSAGEID: 1742528469186019000
Content-Type: text/plain; charset="utf-8"

From: Hyman Huang <yong.huang@smartx.com>

Signed-off-by: Hyman Huang <yong.huang@smartx.com>
---
 ui/vdagent.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/ui/vdagent.c b/ui/vdagent.c
index 4635e8fa56..36b0568135 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -6,7 +6,6 @@
 #include "qemu/option.h"
 #include "qemu/units.h"
 #include "hw/qdev-core.h"
-#include "migration/blocker.h"
 #include "migration/vmstate.h"
 #include "ui/clipboard.h"
 #include "ui/console.h"
@@ -33,9 +32,6 @@
 struct VDAgentChardev {
     Chardev parent;
=20
-    /* TODO: migration isn't yet supported */
-    Error *migration_blocker;
-
     /* config */
     bool mouse;
     bool clipboard;
@@ -673,10 +669,6 @@ 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;
@@ -998,15 +990,12 @@ static void vdagent_chr_init(Object *obj)
=20
     buffer_init(&vd->outbuf, "vdagent-outbuf");
     vmstate_register(NULL, 0, &vmstate_vdagent, vd);
-    error_setg(&vd->migration_blocker,
-               "The vdagent chardev doesn't yet support migration");
 }
=20
 static void vdagent_chr_fini(Object *obj)
 {
     VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(obj);
=20
-    migrate_del_blocker(&vd->migration_blocker);
     vdagent_disconnect(vd);
     if (vd->mouse_hs) {
         qemu_input_handler_unregister(vd->mouse_hs);
--=20
2.27.0