Re: [spice-gtk] gtk-session: do not request guest's clipboard data unnecessarily

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

 



Hi,

On Thu, Jan 03, 2019 at 09:57:40AM +0100, Jakub Janku wrote: > Hi,
> 
> 
> On Wed, Jan 2, 2019, 5:31 PM Victor Toso <victortoso@xxxxxxxxxx wrote:
> 
> > Hi,
> >
> > Thanks for taking a look!
> >
> > On Sun, Dec 30, 2018 at 10:23:02PM +0100, Jakub Janku wrote:
> > > Hi,
> > >
> > > On Wed, Dec 19, 2018 at 3:30 PM Victor Toso <victortoso@xxxxxxxxxx>
> > wrote:
> > > >
> > > > From: Victor Toso <me@xxxxxxxxxxxxxx>
> > > >
> > > > If SpiceGtkSession is holding the keyboard, that's huge indication
> > > > that we should not be requesting clipboard data yet. The proper time
> > > > to request it is when another application in the client machine is
> > > > asking for it, which means the user would switch to another
> > > > application to paste the guest's clipboard data.
> > > >
> >
> > > I'm having a rather hard time understanding this commit message.
> > > I read it the following way:
> > > "spice-gtk should not request clipboard data from vdagent, while
> > > spice-gtk holds the keyboard focus"
> > > However, what the patch actually does is that it makes sure that
> > > spice-gtk doesn't send clipboard grab to vdagent, while spice-gtk
> > > holds the keyboard focus.
> > >
> > > These 2 things seem rather unrelated. What am I missing?
> >
> > Client request for grab will make agent to look into clipboard
> > data in the guest which would lead to VD_AGENT_CLIPBOARD_REQUEST
> > being sent from agent to client.
> 
> Exactly! So it's the agent requesting the CLIENT's data. But in
> the commit message, you state "do not request GUEST's clipboard
> data unnecessarily".  Or isn't it?

Sorry, I got confused while replying earlier. I hope it is better
on v2

    https://lists.freedesktop.org/archives/spice-devel/2019-January/046857.html

> > I can reproduce the client requesting guest's clipboard data on
> > X11/KDE multiple times while the user is just copy-paste between
> > applications in the guest. The idea of this patch was to avoid
> > those requests till the keyboard focus is lost, which means that
> > user is trying to paste guest's clipboard data into another
> > application in the client's OS.
> >
> > Let me know if it isn't clear!
> >
> 
> Makes sense to me to try to avoid such requests. But why are
> those requests causing the issues described?

See:
    https://gitlab.freedesktop.org/spice/win32/vd_agent/issues/6#note_85246

Problem is the possible race in the state of grab.

The situation that I see this happening is caused due too many
requests to clipboard data of the guest. One fix is to avoid
doing that; Another is to improve the checks on both, client and
agent.

As mentioned earlier, we should only allow a client->agent data
request if another application in the client is asking for it.

There is probably different ways to get into a bad state but this
patch (well, v2) helps the use cases I've been trying.

Cheers,

> > > Cheers,
> > > Jakub
> >
> > Thanks again,
> > Victor
> >
> >
> > > >
> > > > Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
> > > > Tested-by: James Harvey @jamespharvey20
> > > > ---
> > > >  src/spice-gtk-session.c | 4 +++-
> > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> > > > index 1ccae07..0d3438c 100644
> > > > --- a/src/spice-gtk-session.c
> > > > +++ b/src/spice-gtk-session.c
> > > > @@ -645,9 +645,11 @@ static void clipboard_owner_change(GtkClipboard
> >       *clipboard,
> > > >          if (gtk_clipboard_get_owner(clipboard) == G_OBJECT(self))
> > > >              break;
> > > >
> > > > +
> > > >          s->clipboard_by_guest[selection] = FALSE;
> > > >          s->clip_hasdata[selection] = TRUE;
> > > > -        if (s->auto_clipboard_enable && !read_only(self))
> > > > +        if (s->auto_clipboard_enable && !read_only(self) &&
> > > > +            !spice_gtk_session_get_keyboard_has_focus(self))
> > > >              gtk_clipboard_request_targets(clipboard,
> > clipboard_get_targets,
> > > >                                            get_weak_ref(self));
> > > >          break;
> > > > --
> > > > 2.19.2
> > > >
> > > > _______________________________________________
> > > > Spice-devel mailing list
> > > > Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> > > > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> >

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[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]