[Spice-devel] Issues with Clipboard Grab/Release Callbacks

Nick Couchman vnick at apache.org
Mon Jun 20 13:59:23 UTC 2022


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)

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)

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

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.

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.

Thanks,
Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20220620/9f4ce959/attachment.htm>


More information about the Spice-devel mailing list