All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe de Dinechin <cdupontd@redhat.com>
To: "\"Daniel P. Berrangé\"" <berrange@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>, qemu-devel@nongnu.org
Subject: Re: vnc clipboard support
Date: Mon, 1 Feb 2021 18:28:38 +0100	[thread overview]
Message-ID: <D704948F-96C7-441F-BCA3-F848ABFD8087@redhat.com> (raw)
In-Reply-To: <20210201165634.GM4131462@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 8664 bytes --]



> On 1 Feb 2021, at 17:56, Daniel P. Berrangé <berrange@redhat.com> wrote:
> 
> On Mon, Feb 01, 2021 at 05:31:52PM +0100, Christophe de Dinechin wrote:
>> 
>> 
>>> On 1 Feb 2021, at 16:51, Daniel P. Berrangé <berrange@redhat.com> wrote:
>>> 
>>> On Mon, Feb 01, 2021 at 04:27:43PM +0100, Christophe de Dinechin wrote:
>>>> 
>>>> 
>>>>> On 29 Jan 2021, at 15:32, Daniel P. Berrangé <berrange@redhat.com> wrote:
>>>>> 
>>>>> On Fri, Jan 29, 2021 at 03:19:45PM +0100, Christophe de Dinechin wrote:
>>>>>> 
>>>>>> 
>>>>>>> On 29 Jan 2021, at 12:08, Daniel P. Berrangé <berrange@redhat.com> wrote:
>>>>>>> 
>>>>>>> On Fri, Jan 29, 2021 at 11:50:10AM +0100, Christophe de Dinechin wrote:
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On 29 Jan 2021, at 09:03, Gerd Hoffmann <kraxel@redhat.com> wrote:
>>>>>>>>> 
>>>>>>>>> Hi,
>>>>>>>>> 
>>>>>>>>>>> (1) Have some guest agent (spice does it that way).
>>>>>>>>>>> Advantage: more flexible, allows more features.
>>>>>>>>>>> Disadvantage: requires agent in the guest.
>>>>>>>>>> 
>>>>>>>>>> What about running the option to relay data to a VNC server in the
>>>>>>>>>> guest if there is one running? In other words, using an existing
>>>>>>>>>> VNC server as an agent, with the option of having a stripped-down,
>>>>>>>>>> clipboard only VNC server as a later optimization.
>>>>>>>>> 
>>>>>>>>> Well, if you run Xvnc in the guest anyway why use the qemu vnc server
>>>>>>>>> in the first place?
>>>>>>>> 
>>>>>>>> I assume that if you use the qemu VNC, it's because you you don't want to
>>>>>>>> run Xvnc on some external network, or care about accessing the guest
>>>>>>>> before Xvnc can be launched. There can be many reasons.
>>>>>>>> 
>>>>>>>> Again, I want to make it clear that my suggestion is _not_ simply to access
>>>>>>>> the existing Xvnc as is, but rather to stick with some VNC server code to handle
>>>>>>>> the clipboard if / when possible.
>>>>>>>> 
>>>>>>>> Let me try to imagine a scenario, where I'll use a macOS guest intentionally
>>>>>>>> to clarify what I was thinking about.
>>>>>>>> 
>>>>>>>> - During early boot, there is no in-guest VNC server, so to address that,
>>>>>>>> you connect to the qemu VNC. At this stage, all screen refresh is handled
>>>>>>>> by the qemu VNC, and the best you can do if you want to support any
>>>>>>>> kind of copy-paste is to convert it to virtual keystrokes. The same would
>>>>>>>> be true for Linux on a text console.
>>>>>>>> 
>>>>>>>> - Then comes up you macOS guest, and it still has no VNC port open,
>>>>>>>> so you are stuck with qemu-vnc doing all the work. But now you can
>>>>>>>> enable screen sharing, and that launches the Apple-maintained macOS
>>>>>>>> VNC server.
>>>>>>>> 
>>>>>>>> - Let's assume for illustration that this listens on some private network
>>>>>>>> that qemu can access, but that is not visible externally. In this case,
>>>>>>>> you could not VNC to the guest, but you can still VNC to qemu.
>>>>>>>> 
>>>>>>>> - What I'm suggesting is that qemu-vnc could then switch to simply
>>>>>>>> relaying VNC traffic to that in-guest server. You'd get the smart update
>>>>>>>> algorithm that Apple has put in place to deal with transparency and the
>>>>>>>> like, as well as a level of guest OS integration that would otherwise be
>>>>>>>> much harder to replicate.
>>>>>>> 
>>>>>>> IMHO that's an awful lot of complexity to add to the system
>>>>>>> that isn't especially useful and this opens up new attack
>>>>>>> vectors for the guest to exploit the host.
>>>>>>> 
>>>>>>> If people have VNC/RDP/whatever configured inside their guest
>>>>>>> OS, then there's really little to no reason for them to want
>>>>>>> to connect to the QEMU VNC server, as viewing initial bootup
>>>>>>> phase is not required in normal case. The only time such
>>>>>>> people will need to use the QEMU VNC server is if the guest
>>>>>>> OS has broken in some way before it fully booted and thus failed
>>>>>>> to start the guest VNC server. There is no guest VNC server
>>>>>>> to hand off to in this scenario.
>>>>>> 
>>>>>> It's a matter of what you want to do with that qemu vnc.
>>>>>> 
>>>>>> If it's only a backup when there's nothing in the guest to help,
>>>>>> then maybe trying to support copy-paste is not a good idea.
>>>>>> 
>>>>>> If it's a standard go-to access point for connecting to your
>>>>>> guest, then making it smart is hard, but useful.
>>>>>> 
>>>>>>> 
>>>>>>> The value of the QEMU host side VNC server is that it works
>>>>>>> for all possible guest OS, no matter whether they are running
>>>>>>> normally or broken, regardless of what the guest admin has
>>>>>>> configured in terms of guest level remote desktop.
>>>>>> 
>>>>>> Understood.
>>>>>> 
>>>>>> The downside is that there are things it can't do. It cannot correctly
>>>>>> determine the keyboard map, because that's controlled in software
>>>>>> in the guest.
>>>>> 
>>>>> There is no need for the remote desktop server to care about the
>>>>> keymap. The remote client takes scancodes and passes them to the
>>>>> server, which then passes them to the guest.
>>>> 
>>>> Aren't we talking about pasting clipboard data here?
>>>> I assume that clipboard data is not encoded as scancodes.
>>> 
>>> The suggestion was that clipboard be sent by injecting key presses
>>> to the guest, so that is scancode based.
>> 
>> But the VNC clipboard protocol is not scancode based. So where
>> would the clipboard->scancode conversion happen?
> 
> If using keyboard injection there's not really much point in
> using the VNC clipboard protocol at all. It just complicates
> life since now we have to configure QEMU with a keymap so that
> it can turn text back into scancodes. We went through alot of
> effort precisely to *stop* telling QEMU about keymaps, so that
> is not an viable option.

How do you get rid of keymaps for local input in qemu?

> 
> IOW, if we want to use keyboard injection to fake the clipboard
> then the VNC Clients should just implemnet this natively and
> use the VNC keyboard protocol messages instead, so scancode
> conversion is client side. It is still painful, because text
> to scancode is inherantly a lossy conversion, but it is better
> than doing it on the QEMU code.

How many brands of VNC clients are there?

What happens if qemu receives clipboard messages from an old client?

Do you plan some new VNC capability to tell the client "I want scancodes"?

What would prevent a client from sending dangerous scancodes,
like Control C or Alt TAB?

How would you prevent the user from typing something in the middle?

How do you rate-limit intelligently to avoid overflowing the guest keyboard buffers?


> 
>> Also, any idea how to copy from the guest in that case?
> 
> If using keyboard injection the clipboard will be unidirectional
> only.
> 
> Bi-directional clipboard needs a guest agent.

OK.

What is the use case for single-directional text-only clipboard?

> 
>> 
>>> 
>>> If you're not doing it using key press injection, then keymapping
>>> and scancodes are irrelevant.
>> 
>> Indeed, but that requires some guest agent, and Gerd seems to
>> not like that idea.
>> 
>> BTW, isolating the clipboard sharing protocol from VNC is an
>> old idea, see https://wiki.xenproject.org/wiki/Clipboard_sharing_protocol <https://wiki.xenproject.org/wiki/Clipboard_sharing_protocol><https://wiki.xenproject.org/wiki/Clipboard_sharing_protocol <https://wiki.xenproject.org/wiki/Clipboard_sharing_protocol>>.
> 
> That's not really isolating it from VNC - that's describing a guest
> agent the host QEMU can use to support its built-in VNC server.
> Confusingly this suggested guest agent happens to use a subset of
> the VNC protocol for transferring clipboard data between QEMU and
> the guest OS. This part is rather crazy since the VNC clipboard
> protocol is incredibly simplistic. Any new guest agent should
> learn from the mistakes of VNC and SPICE wrt clipboard.

Well, to me, the trick is that you got a VNC server in qemu that
receives VNC clipboard data. The question is how you transfer
that to the guest. Indeed, the protocol is simplistic, but you still
need a new data path, e.g. a character device that your in-guest
agent listens to, a bit like the SPICE agent. So the picture becomes:

Normal VNC
Client --> (guest network) --> In-guest VNC server

QEMU VNC:
Client --> (host network) --> qemu-VNC server --> char device --> in-guest VNC clipboard server

Only the data path changes, but the protocol can remain
essentially the same.


[-- Attachment #2: Type: text/html, Size: 30877 bytes --]

  reply	other threads:[~2021-02-01 17:33 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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
     [not found] <CWLP265MB5209050A121EB63FE07F9BD5A8689@CWLP265MB5209.GBRP265.PROD.OUTLOOK.COM>
2023-04-30 16:20 ` VNC " Philipp Hahn

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=D704948F-96C7-441F-BCA3-F848ABFD8087@redhat.com \
    --to=cdupontd@redhat.com \
    --cc=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.