Re: Issues with Clipboard Grab/Release Callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 20, 2022 at 2:46 PM Marc-André Lureau <marcandre.lureau@xxxxxxxxx> wrote:
Hi

On Mon, Jun 20, 2022 at 6:09 PM Nick Couchman <vnick@xxxxxxxxxx> wrote:
Hello, everyone,
I've posted here, before, with some questions during my journey of trying to add support for the SPICE protocol to the Guacamole project. The good news is that I've actually made measurable progress in the implementation - I can now connect to a SPICE server, and the basics work (mouse and keyboard - mostly anyway), so I'm moving on to the extra stuff - clipboard, audio, file transfer, etc.

In working on the clipboard integration, I'm currently running into an issue with a couple of the callback functions, specifically the clipboard grab/release functions, where the number of arguments seems to be mismatched. According to the documentation, these callbacks should be called with the following arguments:

gboolean
user_function (SpiceMainChannel *main,
               guint             selection,
               gpointer          types,
               guint             ntypes,
               gpointer          user_data)


types is actually guint32*, but that's not the problem here.

Okay, I'll update that.
 
 
void
user_function (SpiceMainChannel *main,
               guint             selection,
               gpointer          user_data)

I've implemented the callbacks with those arguments, as follows:

void guac_spice_clipboard_selection_grab_handler(SpiceMainChannel channel,
        guint selection, gpointer types, guint ntypes, guac_client* client)

void guac_spice_clipboard_selection_release_handler(SpiceMainChannel channel,
        guint selection, guac_client* client)

It looks correct. Can you point to your code connecting the signals with the handlers?

Sure - source code is here: https://github.com/necouchman/guacamole-server/tree/working/spice-basic

Here's the section in the src/protocol/spice/client.c file that registers the callbacks:

        /* Register clipboard handlers. */
        g_signal_connect(channel, SPICE_SIGNAL_MAIN_CLIPBOARD_SELECTION,
                G_CALLBACK(guac_spice_clipboard_selection_handler), client);
        g_signal_connect(channel, SPICE_SIGNAL_MAIN_CLIPBOARD_SELECTION_GRAB,
                G_CALLBACK(guac_spice_clipboard_selection_grab_handler), client);
        g_signal_connect(channel, SPICE_SIGNAL_MAIN_CLIPBOARD_SELECTION_RELEASE,
                G_CALLBACK(guac_spice_clipboard_selection_release_handler), client);
        g_signal_connect(channel, SPICE_SIGNAL_MAIN_CLIPBOARD_SELECTION_REQUEST,
                G_CALLBACK(guac_spice_clipboard_selection_request_handler), client);

link to the full function is here:
https://github.com/necouchman/guacamole-server/blob/5e073802a0656e65b1bc8e7e6051831bea0d9508/src/protocols/spice/client.c#L236-L375
 
 

and registered them appropriately. However, if I use them as implemented above, when the callbacks are triggered, the application segfaults when I try to access the "guac_client* client" data structure. I used GDB to try to help track this down, and I noticed that the value of "client" was 0x1, which looks less like a pointer to a memory location and more like the number 1.

So, I decided to add another argument to the callback functions, just before the client argument:

void guac_spice_clipboard_selection_grab_handler(SpiceMainChannel channel,
        guint selection, gpointer types, guint ntypes, guint extra, guac_client* client)

void guac_spice_clipboard_selection_release_handler(SpiceMainChannel channel,
        guint selection, guint extra, guac_client* client)

Strangely, this works - the client data structure can be referenced, there are no segfaults (yet), etc. So, I decided to print the values that are being passed for all of these parameters, and I get the following:

guacd[100252]: DEBUG: Notifying client of clipboard grab in the guest.
guacd[100252]: DEBUG: Arg: channel: 0x00000000
guacd[100252]: DEBUG: Arg: selection: 1275303536
guacd[100252]: DEBUG: Arg: types: 0x00000001
guacd[100252]: DEBUG: Arg: ntypes: 1276022924
guacd[100252]: DEBUG: Arg: extra: 1


Weird
 
I printed them in the format I thought they should be in based on what the arguments are supposed to be - I probably should have just done all hex. But, it seems like maybe the "extra" parameter being passed is in front of the channel, since the channel is showing up as all zeros?

I was trying to find the code where the callbacks are actually called - I'm guessing, since this is clipboard integration, it'll be in the vdagent code somewhere - but I was having trouble tracking that down.


The callbacks are not directly called, since those a GObject signals. The main channel will call g_signal_emit().


Okay.
 
 
If anyone has any ideas, I'd appreciate the insight into this - I'm puzzled by this apparent mismatch in the number of arguments. Also, if it matters, I'm running CentOS 8 Stream, using Xspice to provide a test SPICE server, and running spice-vdagentd/spice-vdagent within my X session. Yes, I know Xspice is unmaintained, but I just needed something simple and that I didn't have to spend a bunch of time building in order to give me a spice server to point at, and, so far, this has been pretty reliable. Also, at its core, it appears to use the same spice-qxl X driver that x11spice uses, just with a simple Python wrapper script for generating an X config file and starting the X server/display. So, I think it's still pretty "safe" for attempting to develop this Guacamole integration - if for some reason you believe me to be wrong about that, please let me know.

Your testing environment shouldn't be a problem, it's really your client-side code integration with spice-glib that looks broken.


That's what I was thinking, and maybe I'm just messing up something simple!

Thanks,
Nick

[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]