Bug 1600798

Summary: spice-vdagent clipboard ownership copy-and-paste problems
Product: Red Hat Enterprise Virtualization Manager Reporter: Charlton Harrison <charlton>
Component: spice-vdagent-winAssignee: Default Assignee for SPICE Bugs <rh-spice-bugs>
Status: CLOSED UPSTREAM QA Contact: meital avital <mavital>
Severity: high Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: cfergeau, dblechte, ladar, lsurette, rbalakri, srevivo, victortoso
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-07-13 08:23:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Attachments:
Description Flags
spice.log none

Description Charlton Harrison 2018-07-13 04:43:53 UTC
Description of problem:

I have a gentoo guest running inside KVM/qemu/virt-manager under a gentoo host. Everything works beautifully except copy-and-paste which only occasionally works. Even within the VM (not cross host<->guest) the copy-and-paste doesn't work. It seems to work the first time, but afterwards when I try to paste it doesn't work and also freezes xorg/terminals for 10 seconds. 

I am constantly seeing these in my messages log:

Jul 12 12:37:06 triton spice-vdagent[2378]: primary: received clipboard req while not owning guest clipboard
Jul 12 12:37:06 triton spice-vdagent[2378]: primary: received clipboard req while not owning guest clipboard
Jul 12 12:37:06 triton spice-vdagent[2378]: primary: received clipboard req while not owning guest clipboard
Jul 12 12:37:06 triton spice-vdagent[2378]: primary: received clipboard req while not owning guest clipboard
Jul 12 12:37:06 triton spice-vdagent[2378]: primary: received clipboard req while not owning guest clipboard
Jul 12 12:37:06 triton spice-vdagent[2378]: primary: received clipboard req while not owning guest clipboard
Jul 12 12:37:21 triton spice-vdagent[2378]: primary: selection requests pending on clipboard ownership change, clearing

While these seem to be very clear error messages I could google, it comes back with nothing helpful. Maybe I've configured something incorrectly because otherwise I can't see how this isn't a common issue. spice-vdagent and qemu-guest-agent are both running on the guest. Their /etc/conf.d files have not been changed from their defaults (ie all comments). virtio uinput has been compiled in the kernel as a module and is loaded when I check lsmod.

I can confirm that this also messes with copy-and-paste on the host system as well. 
I'm having problems selecting words/sections on the host. If I shut down the VM the problem goes away.

Bug is also documented on Gentoo forums at:
https://forums.gentoo.org/viewtopic-p-8221522.html

--

Version-Release number of selected component (if applicable):

spice 0.14.0-r1
spice-vdagent 0.17.0_p20180319-r1


How reproducible:

Carefully double-checked all setup instructions under Gentoo linux.
Guest is also latest Gentoo linux.
Double-checked permissions, group, and user setup.


Steps to Reproduce:
1. Using libvirt and virt-manager, under Gentoo linux, set up a Gentoo linux guest
2. Run spice-vdagent on guest.
3. Run qemu-guest-agent on guest


Actual results:
Copy and paste works the first time, but very sporadically afterwards.


Expected results:
Copy and paste to work as expected inside guest, host, and between the two.


Additional info:
Unable to find any information on Google regarding these error messages.

I personally suspect the problem might be permissions related, as looking at the code would seem to indicate that the Xorg clipboard owner is somehow incompatible with the user doing the copy-and-pasting.

Comment 1 Victor Toso 2018-07-13 08:23:43 UTC
Hi Charlton, thanks for taking time to report this bug here.

I've opened an upstream bug, we can discuss it further there [0]

[0] https://gitlab.freedesktop.org/spice/linux/vd_agent/issues/9

Comment 2 Ladar Levison 2018-07-19 10:26:31 UTC
I have also run into this issue. Cutting/copying/pasting inside my RHEL 6.10 guest is generating a large number of log entries. The operation itself seems to work once every 5 or so attempts. To make matters worse, this problem is causing certain apps (Eclipse and the clipit widget in particular), to freeze for 10 to 20 seconds at a time. 

As you can imagine, having your IDE freeze every few minutes is rather annoying. After trying many different things to fix the problem, I gave up. Since this caused me so much pain, I'm posting a workaround here, so that others may be spared some of my grief. 

Disabling spice clipboard supports, avoids the issue (albeit at the cost of guest/host clipboard sharing). To apply this workaround, libvirt users will need to edit the XML file with the guest configuration directly. With system hosted libvirt guests, the file will likely be /etc/libvirt/qemu/GuestName.xml ... note these files require elevated privileges to access directly ... once open, add a "<clipboard copypaste='no'/>" child node to the "<graphics>" node. This should result in the "<graphics>" section looking something like:

<graphics type='spice' autoport='yes' listen='127.0.0.1'>
  <listen type='address' address='127.0.0.1'/>
  <image compression='off'/>
  <clipboard copypaste='no'/>
</graphics>

For users running QEMU directly, you'll need to add "disable-copy-paste" to the "-spice" configuration. This will yield a command like option that looks something like:

 -spice port=5900,addr=127.0.0.1,disable-ticketing,image-compression=off,disable-copy-paste,seamless-migration=on

Should anyone try and fix this issue, my host is RHEL 7.5. The following are just some of the errors found inside my guest system logs. I will post a larger sample set as an attachment.

Jul 17 10:59:40 dark spice-vdagent[2711]: clipboard: received selection request event for target STRING, while not owning client clipboard
Jul 17 10:59:40 dark spice-vdagent[2711]: clipboard: received selection request event for target TARGETS, while not owning client clipboard
Jul 17 10:59:40 dark spice-vdagent[2711]: clipboard: received clipboard req while not owning guest clipboard
Jul 17 11:00:44 dark spice-vdagent[2711]: clipboard: selection requests pending on clipboard ownership change, clearing
Jul 17 11:00:44 dark spice-vdagent[2711]: clipboard: received clipboard req while not owning guest clipboard
Jul 17 11:01:47 dark spice-vdagent[2711]: clipboard: selection requests pending on clipboard ownership change, clearing
Jul 17 11:01:57 dark spice-vdagent[2711]: clipboard: received clipboard req while not owning guest clipboard
Jul 17 11:01:58 dark spice-vdagent[2711]: clipboard: selection requests pending on clipboard ownership change, clearing
Jul 17 11:02:00 dark spice-vdagent[2711]: clipboard: unexpected selection type text/uri-list

Comment 3 Ladar Levison 2018-07-19 10:28 UTC
Created attachment 1459973 [details]
spice.log