qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Hahn <hahn@univention.de>
To: "octaveflon@outlook.fr" <octaveflon@outlook.fr>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: VNC clipboard support
Date: Sun, 30 Apr 2023 18:20:13 +0200	[thread overview]
Message-ID: <a4ce2f4b-f0fd-6a57-a3d0-aa0ed2f54e5f@univention.de> (raw)
In-Reply-To: <CWLP265MB5209050A121EB63FE07F9BD5A8689@CWLP265MB5209.GBRP265.PROD.OUTLOOK.COM>

Hello,

Am 29.04.23 um 17:29 schrieb octaveflon@outlook.fr:
> I'm trying to use the copy/paste with VNC.
> 
> I'm launching qemu with:
> 
> $ qemu-system-x86_64 -hda debiandisk.img vnc :1
> 
> I'm using tightvncviewer which has support for copy/paste.
> 
> I try to copy text between guest and host.
> 
> It doesn't work. Neither from host to guest or guest to host.
> 
> As far as I know, there is clipboard support in VNC (ui/vnc-clipboard.c 
> and so on).
> With wireshark, I can see that tightvncviewer send clipboard requests.
> 
> Am I missing some configuration?

Clipboard via VNC to QEMU does not work: Basically the VNC protocol was 
originally used for remote-access to X11 application. There you work on 
a high-level were XKeySyms are used and where clipboard data can be 
exchanged.

In contrast with QEMU you work on a much lower level as you do hardware 
emulation: The operating system inside your QEMU process expects 
low-level hardware events like a USB or PS2 keyboard key Up / Down events.
As the VNC protocol only exchanges "XKeySyms" QEMU has to translate them 
back to those low-level USB/PS2 events expected by the OS.
This back-translation is not unique: For example most full-sized 
keyboards have the number block, so there are 2 keys to enter a digit.

Therefore QEMU added the "extended key event"-extension, which adds the 
low-level "KeyCode" in addition to the "XKeySym" to the VNC protocol: 
When you press a key in your VNC browser the X-Server luckily also gets 
the low-level "KeyCode", but the original VNC protocol did not include 
that information on the protocol level. By including that information 
QEMU no longer has to "fake" it and simply pass that information to the 
inside OS.

Even when your clipboards only contains text (it could also have a 
bitmap picture or some other rich data), you are basically back in the 
situation where you have to translate each character to one (or 
multiple) key-press/release events, again with the same issue mention 
above: You do not have the KeyCode and someone has to fake them.

Therefore it will not work: Albeit some VNC browsers or libraries 
implement that approach, but their result is unreliable, especially if 
the keyboard layout on your client computer does not match the keyboard 
layout configured in QEMU for the backward translation does not match 
the keyboard layout of your operating system running inside of QEMU.

If you want to know more, read this still excellent blog-post from 
Daniel Berrangé:
- 
https://www.berrange.com/posts/2010/07/04/more-than-you-or-i-ever-wanted-to-know-about-virtual-keyboard-handling/
- 
https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#qemu-extended-key-event-message

Philipp


       reply	other threads:[~2023-04-30 16:21 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CWLP265MB5209050A121EB63FE07F9BD5A8689@CWLP265MB5209.GBRP265.PROD.OUTLOOK.COM>
2023-04-30 16:20 ` Philipp Hahn [this message]
2021-01-28 17:12 vnc clipboard support Gerd Hoffmann
2021-01-28 17:35 ` Daniel P. Berrangé
2021-01-29  7:59   ` Gerd Hoffmann
2021-01-28 17:38 ` Christophe de Dinechin
2021-01-29  8:03   ` Gerd Hoffmann
2021-01-29 10:50     ` Christophe de Dinechin
2021-01-29 11:08       ` Daniel P. Berrangé
2021-01-29 14:19         ` Christophe de Dinechin
2021-01-29 14:32           ` Daniel P. Berrangé
2021-02-01 15:27             ` Christophe de Dinechin
2021-02-01 15:51               ` Daniel P. Berrangé
2021-02-01 16:31                 ` Christophe de Dinechin
2021-02-01 16:56                   ` Daniel P. Berrangé
2021-02-01 17:28                     ` Christophe de Dinechin
2021-02-01 17:40                       ` Daniel P. Berrangé
2021-02-01 18:45                         ` BALATON Zoltan
2021-02-02 11:31                           ` Gerd Hoffmann
2021-02-02 12:31                             ` BALATON Zoltan
2021-02-02 12:38                               ` Daniel P. Berrangé
2021-02-02 13:35                                 ` Gerd Hoffmann
2021-02-02 16:36                                   ` Gerd Hoffmann
2021-02-02 21:00                                     ` Marc-André Lureau
2021-02-03  9:40                                       ` Gerd Hoffmann
2021-02-02 11:10                         ` Gerd Hoffmann
2021-02-02 11:17                           ` Daniel P. Berrangé
2021-02-02 11:44                             ` Gerd Hoffmann
2021-01-29 15:04           ` Gerd Hoffmann
2021-02-01 17:07             ` Christophe de Dinechin
2021-01-29 11:49       ` Gerd Hoffmann
2021-01-29 13:28         ` Christophe de Dinechin
2021-01-28 17:57 ` Laszlo Ersek
2021-01-29  8:09   ` Gerd Hoffmann
2021-01-29 10:02   ` Daniel P. Berrangé
2021-01-28 20:18 ` Marc-André Lureau
2021-01-28 20:47   ` BALATON Zoltan
2021-01-29  7:59   ` Christophe de Dinechin
2021-01-29  8:27   ` Gerd Hoffmann
2021-01-29  8:34     ` Marc-André Lureau
2021-01-29 10:33       ` Gerd Hoffmann
2021-01-29 11:10       ` Daniel P. Berrangé
2021-01-29 11:24   ` Daniel P. Berrangé
2021-01-29 11:58     ` Marc-André Lureau
2021-01-29 12:21       ` Daniel P. Berrangé
2021-01-29 12:02   ` Gerd Hoffmann
2021-01-29 12:10     ` Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a4ce2f4b-f0fd-6a57-a3d0-aa0ed2f54e5f@univention.de \
    --to=hahn@univention.de \
    --cc=octaveflon@outlook.fr \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).