Bug 1755038

Summary: VM clipboard integration wipes clipboard contents randomly and frequently (X11 host)
Product: [Fedora] Fedora Reporter: Kamil Páral <kparal>
Component: spice-vdagentAssignee: Christophe Fergeau <cfergeau>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 30CC: alon, awilliam, bberg, cfergeau, fziglio, gmarr, hdegoede, jjanku, jonha87, marcandre.lureau, pasik, robatino, sandmann
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: RejectedBlocker
Fixed In Version: spice-vdagent-0.19.0-4.fc31 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-26 18:43:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
test_clipboard script none

Description Kamil Páral 2019-09-24 15:18:23 UTC
Description of problem:
My host system very frequently loses all clipboard contents whenever I have a virtual machine (through virt-manager) running (I don't need to be interacting with it, it can unfocused). I narrowed the problem to the following:

* Whenever you press ctrl+c or ctrl+x (i.e. write to the clipboard) on the host, there is a chance it gets wiped out (replaced with empty content). You might completely lose the content this way (if you do ctrl+x and the editor/app doesn't support "undo", the content is simply lost).
* This happens only with X11 host, not with Wayland host. Tested on F30 and F31 hosts.
* This happens only with F31 VM guest, not with F30 or F29.
* This happens extremely frequently with F31 GNOME guest, occasionally with F31 KDE guest, and never with F31 netinst environment (even though the clipboard integration does work in there). So it seems the desktop environment affects this problem somehow.
* Once you stop spice-vdagentd in the VM, the problem stops happening.

Of course this is a race condition, so some of my findings might not be true and happen differently on different hardware/software configuration.

I've created a script that periodically writes into system clipboard and exits once some external process changed it. I have attached the script. With GNOME VM, I can see the problem occurring almost immediately, mostly under 20 iterations:

$ ./test_clipboard 
......
Clipboard changed after 6 iterations!
Old text: A completely random string
New text: 


With KDE VM, I can see the problem usually under 200 iterations. At least with GNOME, I don't even need to log in, just reaching GDM is enough. If the script cannot detect the issue for a longer time, interacting with the machine or restarting spice-vdagentd seems to increase the likelihood considerably.

Please figure out what changed in F31 VM guests compared to F30 guests and fix clipboard handling. Losing clipboard contents randomly is very inconvenient.


Version-Release number of selected component (if applicable):
spice-vdagent-0.19.0-3.fc31.x86_64
mutter-3.34.0-3.fc31.x86_64
gnome-shell-3.34.0-2.fc31.x86_64


How reproducible:
always

Steps to Reproduce:
1. use F30/F31 host with X11 session
2. boot F31 VM in virt-manager, ideally GNOME, fully updated (but F31 Live Beta works as well)
3. verify that spice-vdagentd is running and that host<->guest clipboard integration is working
4. run attached test_clipboard clip, it should report a problem almost immediately. Once it does, your system clipboard will be empty.
5. you can also try working as usual while having the VM running (window opened), eventually you'll end up with an empty clipboard after pressing ctrl+c or ctrl+x

Comment 1 Kamil Páral 2019-09-24 15:19:10 UTC
Created attachment 1618646 [details]
test_clipboard script

This is a bash script useful to detect clipboard wipes.

Comment 2 Kamil Páral 2019-09-25 08:27:50 UTC
Benjamin, you've already fixed bug 1750120, would you perhaps be able to look into this as well? Thanks a lot.

Comment 3 Benjamin Berg 2019-09-25 09:30:52 UTC
Sorry, I fear that this bug is really different. I don't think I am the right person to look into this.

Comment 4 Kamil Páral 2019-09-26 10:25:13 UTC
I found out that when I have 2 VMs with F31 running, my clipboard is basically non-functional. My test script exits almost every time after 0-1 iterations. When I want to copy&paste something, I have to try e.g. 10 times before the clipboard is populated.

Comment 5 Kamil Páral 2019-09-26 10:34:25 UTC
I think this might be an issue to discussing during blocker review meeting. If I have 1 VM running, it's hit or miss. When I have 2 VMs running, I'm almost unable to use basic functionality in apps [1], like ctrl+c&ctrl+v copying of files in Nautilus, text processing in text editors, creating bug reports in firefox (because I need to copy hyperlinks often) etc. The condition is that you have virt-manager running [2] with 1 (but preferably multiple) VMs with F31 guests (preferably GNOME), and you're using X11 session on the host.

[1] https://fedoraproject.org/wiki/Fedora_31_Final_Release_Criteria#Default_application_functionality
[2] https://fedoraproject.org/wiki/Fedora_31_Beta_Release_Criteria#Self_hosting_virtualization

Comment 6 Adam Williamson 2019-09-26 15:17:56 UTC
Kamil, can you file an issue upstream at https://gitlab.freedesktop.org/spice/linux/vd_agent ? The upstream maintainer (Victor Toso) seems pretty active there but doesn't even have an account here, so I think we're more likely to get movement there.

There's an existing issue:
https://gitlab.freedesktop.org/spice/linux/vd_agent/issues/9

which looks sort of similar/related at least. That issue references this spice-gtk patch:
https://lists.freedesktop.org/archives/spice-devel/2019-March/048583.html

which looks like it has never been merged, so I guess you could try building spice-gtk with that patch and see if it helps?

Comment 8 Adam Williamson 2019-09-26 15:58:08 UTC
Thanks! It seems those have not been merged yet either, right?

Comment 9 Marc-Andre Lureau 2019-09-26 16:06:16 UTC
nope, I am not maintaining those components, and I am not affected by the bug (yet!), so I leave it to the spice team.

Comment 10 Jonathan Haas 2019-09-27 07:50:35 UTC
See also https://gitlab.freedesktop.org/spice/spice-gtk/issues/82 (which is probably the proper upsteam issue)

Comment 11 Kamil Páral 2019-09-27 08:44:05 UTC
(In reply to Marc-Andre Lureau from comment #7)
> The next/better version was:
> https://lists.freedesktop.org/archives/spice-devel/2019-March/048601.html
> https://lists.freedesktop.org/archives/spice-devel/2019-March/048605.html

Marc-Andre, could you perhaps create a koji scratch build for testing? Or at least provide the patch in some more easily digestible form, e.g. as a PR against upstream gitlab instance, so that I can download the whole diff? Also, do those patched versions need to be installed on the host, on the guest, or both? Thanks.

Comment 12 Adam Williamson 2019-09-27 17:17:14 UTC
Kamil, there's a patchwork for freedesktop. Here's all the relevant patches/series:

[Jan 16] First attempt to address #82, v1: https://patchwork.freedesktop.org/patch/277597/
[Jan 16] First attempt to address #82, v2: https://patchwork.freedesktop.org/patch/277609/

[Mar 21] "clipboard: skip release between grabs" series: https://patchwork.freedesktop.org/series/58353/#rev1
(rev2 seems to be a patchwork glitch)

[Mar 22] "Clipboard improvements" series for spice-gtk: https://patchwork.freedesktop.org/series/58418/#rev1
[Mar 22] "Clipboard improvements" series for spice-vdagent: https://patchwork.freedesktop.org/series/58418/#rev2
(note patchwork incorrectly thinks these are two revs of the same patch series, presumably because they have the same name)

I'm not sure what combinations of the above to try. I guess try just both of the March 22 series together first, then fiddle around with the others if that doesn't help.

Comment 13 Adam Williamson 2019-09-27 17:18:11 UTC
BTW, I think you update spice-gtk on the *host* side and the agent on the *client* side, but can't hurt to update spice-gtk on both sides I guess.

Comment 14 Jakub Janků 2019-09-29 18:11:58 UTC
This indeed is the same issue as #82, I assume that it's caused by commit 5c009c20 in mutter:

https://gitlab.gnome.org/GNOME/mutter/commit/5c009c20ab493fd610928d4581c52f0d448bea61

Previously, we saw issues on KDE with klipper which behaves the same as this new clipboard manager in mutter -- it takes clipboard ownership immediately once the original owner releases it.

Comment 15 Kamil Páral 2019-09-30 11:23:08 UTC
(In reply to Adam Williamson from comment #12)
> [Mar 22] "Clipboard improvements" series for spice-gtk:
> https://patchwork.freedesktop.org/series/58418/#rev1
> [Mar 22] "Clipboard improvements" series for spice-vdagent:
> https://patchwork.freedesktop.org/series/58418/#rev2

None of these apply to the master branch of their projects. I tried to apply vdagent diff to the Fedora distgit tarball (version 0.19.0) and it applies well enough, but then fails to compile, because it seems to require some unreleased changes available only in master. I tried to figure out what commit are those patches based on and how to resolve conflicts when applying those damned mbox formats, but my beard is not long enough to help me succeed. This will need someone else to prepare the scratch builds.

Comment 16 Adam Williamson 2019-09-30 15:34:53 UTC
I usually resolve conflicts by hand-editing the patches, but I may be nuts. :P

Comment 17 Jakub Janků 2019-09-30 17:33:53 UTC
I rebased the series onto the current master, you can grab it here, branch "clipboard-race":

https://github.com/jjanku/spice-protocol
https://github.com/jjanku/spice-gtk
https://github.com/jjanku/linux-vd_agent/

Comment 18 Geoffrey Marr 2019-10-01 00:29:55 UTC
Discussed during the 2019-09-30 blocker review meeting: [0]

The decision to classify this bug as a "RejectedBlocker" and an "AcceptedFreezeException" was made as we think a bug of this nature could conceivably be a blocker under various criteria, but as this one only manifests when using an X11 session (not default in most cases) *and* running a virtual machine, we agreed it's slightly too limited in impact. Accepted as an FE as it can't be fixed for live images with an update.

[0] https://meetbot.fedoraproject.org/fedora-blocker-review/2019-09-30/f31-blocker-review.2019-09-30-16.00.txt

Comment 19 Kamil Páral 2019-10-01 12:37:20 UTC
(In reply to Jakub Janků from comment #17)
> I rebased the series onto the current master, you can grab it here, branch
> "clipboard-race":

Thanks a lot, Jakub. I built those projects and installed them on both host and guest. The clipboard problem seems to be entirely gone. Now I can have 2 VMs easily and the clipboard still works as expected.

Comment 20 Adam Williamson 2019-10-04 15:29:02 UTC
I'm backporting all these patches to the packages. The linux-vd_agent branch has a *lot* of commits - I'm assuming all the not-obviously-related ones are needed for the clipboard ones to apply?

Comment 21 Fedora Update System 2019-10-04 16:13:43 UTC
FEDORA-2019-565a2a339d has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2019-565a2a339d

Comment 22 Adam Williamson 2019-10-04 16:17:50 UTC
Oh, another question: do we need to send the agent fixes out for F29 and F30 as well?

Comment 23 Fedora Update System 2019-10-04 22:51:15 UTC
spice-gtk-0.37-4.fc31, spice-protocol-0.14.0-3.fc31, spice-vdagent-0.19.0-4.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-565a2a339d

Comment 24 Jakub Janků 2019-10-06 19:28:41 UTC
(In reply to Adam Williamson from comment #22)
> Oh, another question: do we need to send the agent fixes out for F29 and F30
> as well?

The users on F29 and F30 could benefit from this as well, but the patches haven't been even reviewed by the spice team properly yet.
Apart from that, some of them aren't related to this clipboard bug.

Comment 25 Kamil Páral 2019-10-07 11:37:08 UTC
(In reply to Fedora Update System from comment #23)
> spice-gtk-0.37-4.fc31, spice-protocol-0.14.0-3.fc31,
> spice-vdagent-0.19.0-4.fc31 has been pushed to the Fedora 31 testing
> repository. 

I updated the F31 packages in my VM, but it doesn't fix the problem. I guess I'll need fixes for my F30 host as well, probably spice-gtk.

Comment 26 Fedora Update System 2019-10-08 00:27:24 UTC
spice-gtk-0.37-4.fc31, spice-protocol-0.14.0-3.fc31, spice-vdagent-0.19.0-4.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report.

Comment 27 Kamil Páral 2019-10-10 12:51:25 UTC
This is not fixed at least for F30 as a host. I'll try to test this with F31 host.

Adam, can you please submit an update for F30 as well? I guess the gtk part could be enough.

Comment 28 Adam Williamson 2019-10-10 15:36:07 UTC
I was sort of hoping to wait for review on the patches before sending them out to stable releases (as Jakub implied in #c24). Jakub, any news on review?

Comment 29 Kamil Páral 2019-10-10 16:09:29 UTC
(In reply to Fedora Update System from comment #26)
> spice-gtk-0.37-4.fc31, spice-protocol-0.14.0-3.fc31,
> spice-vdagent-0.19.0-4.fc31 has been pushed to the Fedora 31 stable
> repository. If problems still persist, please make note of it in this bug
> report.

I can confirm that this problem is fixed if the updated packages are installed on F31 host and F31 guest.

Comment 30 Adam Williamson 2019-10-10 16:11:58 UTC
OK, so let's drop F31 blocker metadata and re-assign to F30, assuming that's OK for you.

Comment 31 Adam Williamson 2020-03-17 00:09:12 UTC
hmm, so, 0.38 is done now, and sent to f31, but not f30. Jakub, Christophe, any ideas how to proceed here for F30? Should I try a backport for it?

Comment 32 Kamil Páral 2020-04-27 12:27:55 UTC
Dropping CommonBugs, because it's fixed in later releases.

Comment 33 Ben Cotton 2020-04-30 20:11:18 UTC
This message is a reminder that Fedora 30 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 30 on 2020-05-26.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '30'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 30 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 34 Ben Cotton 2020-05-26 18:43:51 UTC
Fedora 30 changed to end-of-life (EOL) status on 2020-05-26. Fedora 30 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 35 Red Hat Bugzilla 2023-09-14 05:43:43 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days