diff mbox series

[RFC,2/4] vdagent: refactor vdagent_chr_recv_caps function

Message ID 20221230092758.281805-3-dengpc12@chinatelecom.cn (mailing list archive)
State New, archived
Headers show
Series vdagent: support live migration | expand

Commit Message

dengpc12@chinatelecom.cn Dec. 30, 2022, 9:27 a.m. UTC
From: "dengpc12@chinatelecom.cn" <dengpc12@chinatelecom.cn>

Abstract vdagent registry logic into
vdagent_register_to_qemu_clipboard.

Note that trace log of vdagent_recv_caps also be added.

Signed-off-by: dengpc12@chinatelecom.cn <dengpc12@chinatelecom.cn>
Signed-off-by: liuym16@chinatelecom.cn <liuym16@chinatelecom.cn>
---
 ui/trace-events |  1 +
 ui/vdagent.c    | 20 +++++++++++++-------
 2 files changed, 14 insertions(+), 7 deletions(-)

Comments

Marc-André Lureau Jan. 2, 2023, 11:31 a.m. UTC | #1
On Fri, Dec 30, 2022 at 6:49 PM <dengpc12@chinatelecom.cn> wrote:
>
> From: "dengpc12@chinatelecom.cn" <dengpc12@chinatelecom.cn>
>
> Abstract vdagent registry logic into
> vdagent_register_to_qemu_clipboard.
>
> Note that trace log of vdagent_recv_caps also be added.
>
> Signed-off-by: dengpc12@chinatelecom.cn <dengpc12@chinatelecom.cn>
> Signed-off-by: liuym16@chinatelecom.cn <liuym16@chinatelecom.cn>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  ui/trace-events |  1 +
>  ui/vdagent.c    | 20 +++++++++++++-------
>  2 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/ui/trace-events b/ui/trace-events
> index 977577fbba..5e50b60da5 100644
> --- a/ui/trace-events
> +++ b/ui/trace-events
> @@ -143,6 +143,7 @@ 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"
>  vdagent_cb_grab_type(const char *name) "type %s"
>  vdagent_cb_serial_discard(uint32_t current, uint32_t received) "current=%u, received=%u"
> +vdagent_recv_caps(uint32_t caps) "received caps %u"
>
>  # dbus.c
>  dbus_registered_listener(const char *bus_name) "peer %s"
> diff --git a/ui/vdagent.c b/ui/vdagent.c
> index 645383b4ec..38061d5b38 100644
> --- a/ui/vdagent.c
> +++ b/ui/vdagent.c
> @@ -696,6 +696,16 @@ static void vdagent_chr_open(Chardev *chr,
>      *be_opened = true;
>  }
>
> +static void vdagent_register_to_qemu_clipboard(VDAgentChardev *vd)
> +{
> +    if (have_clipboard(vd) && vd->cbpeer.notifier.notify == NULL) {
> +        vd->cbpeer.name = "vdagent";
> +        vd->cbpeer.notifier.notify = vdagent_clipboard_notify;
> +        vd->cbpeer.request = vdagent_clipboard_request;
> +        qemu_clipboard_peer_register(&vd->cbpeer);
> +    }
> +}
> +
>  static void vdagent_chr_recv_caps(VDAgentChardev *vd, VDAgentMessage *msg)
>  {
>      VDAgentAnnounceCapabilities *caps = (void *)msg->data;
> @@ -720,14 +730,10 @@ static void vdagent_chr_recv_caps(VDAgentChardev *vd, VDAgentMessage *msg)
>          qemu_input_handler_activate(vd->mouse_hs);
>      }
>
> -    memset(vd->last_serial, 0, sizeof(vd->last_serial));
> +    trace_vdagent_recv_caps(vd->caps);
>
> -    if (have_clipboard(vd) && vd->cbpeer.notifier.notify == NULL) {
> -        vd->cbpeer.name = "vdagent";
> -        vd->cbpeer.notifier.notify = vdagent_clipboard_notify;
> -        vd->cbpeer.request = vdagent_clipboard_request;
> -        qemu_clipboard_peer_register(&vd->cbpeer);
> -    }
> +    memset(vd->last_serial, 0, sizeof(vd->last_serial));
> +    vdagent_register_to_qemu_clipboard(vd);
>  }
>
>  static void vdagent_chr_recv_msg(VDAgentChardev *vd, VDAgentMessage *msg)
> --
> 2.27.0
>
>
diff mbox series

Patch

diff --git a/ui/trace-events b/ui/trace-events
index 977577fbba..5e50b60da5 100644
--- a/ui/trace-events
+++ b/ui/trace-events
@@ -143,6 +143,7 @@  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"
 vdagent_cb_grab_type(const char *name) "type %s"
 vdagent_cb_serial_discard(uint32_t current, uint32_t received) "current=%u, received=%u"
+vdagent_recv_caps(uint32_t caps) "received caps %u"
 
 # dbus.c
 dbus_registered_listener(const char *bus_name) "peer %s"
diff --git a/ui/vdagent.c b/ui/vdagent.c
index 645383b4ec..38061d5b38 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -696,6 +696,16 @@  static void vdagent_chr_open(Chardev *chr,
     *be_opened = true;
 }
 
+static void vdagent_register_to_qemu_clipboard(VDAgentChardev *vd)
+{
+    if (have_clipboard(vd) && vd->cbpeer.notifier.notify == NULL) {
+        vd->cbpeer.name = "vdagent";
+        vd->cbpeer.notifier.notify = vdagent_clipboard_notify;
+        vd->cbpeer.request = vdagent_clipboard_request;
+        qemu_clipboard_peer_register(&vd->cbpeer);
+    }
+}
+
 static void vdagent_chr_recv_caps(VDAgentChardev *vd, VDAgentMessage *msg)
 {
     VDAgentAnnounceCapabilities *caps = (void *)msg->data;
@@ -720,14 +730,10 @@  static void vdagent_chr_recv_caps(VDAgentChardev *vd, VDAgentMessage *msg)
         qemu_input_handler_activate(vd->mouse_hs);
     }
 
-    memset(vd->last_serial, 0, sizeof(vd->last_serial));
+    trace_vdagent_recv_caps(vd->caps);
 
-    if (have_clipboard(vd) && vd->cbpeer.notifier.notify == NULL) {
-        vd->cbpeer.name = "vdagent";
-        vd->cbpeer.notifier.notify = vdagent_clipboard_notify;
-        vd->cbpeer.request = vdagent_clipboard_request;
-        qemu_clipboard_peer_register(&vd->cbpeer);
-    }
+    memset(vd->last_serial, 0, sizeof(vd->last_serial));
+    vdagent_register_to_qemu_clipboard(vd);
 }
 
 static void vdagent_chr_recv_msg(VDAgentChardev *vd, VDAgentMessage *msg)