Bug 731628

Summary: mouse right-click does not work on the host after stop guest with spicevmc
Product: Red Hat Enterprise Linux 8 Reporter: Mike Cao <bcao>
Component: spice-vdagent-winAssignee: David Blechter <dblechte>
Status: CLOSED CURRENTRELEASE QA Contact: Desktop QE <desktop-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: ---CC: acathrow, cfergeau, cpelland, dblechte, juzhang, michen, mkenneth, mkrcmari, shuang, tburke, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Windows   
Whiteboard:
Fixed In Version: vdagent-win-0.1-9 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-01-21 15:11:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
release clipboard ownership on agent stop & desktop switch none

Description Mike Cao 2011-08-18 06:47:39 UTC
Description of problem:


Version-Release number of selected component (if applicable):
# uname -r
2.6.32-188.el6.x86_64
# rpm -q qemu-kvm
qemu-kvm-0.12.1.2-2.183.el6.x86_64

guest drivers:
RHEV-toolsSetup_3.0_17


How reproducible:
100%

Steps to Reproduce:
1.start guest with spicevmc
CLI:/usr/libexec/qemu-kvm -M rhel6.0.0 -cpu Westmere -enable-kvm -m 2048 -smp 1,sockets=1,cores=1,threads=1 -name win7_64 -uuid 9c1e21b1-1740-4117-8328-c8ae7c94068b -monitor stdio -rtc base=localtime -boot c -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x4 -drive file=/rhev/data-center/e390e371-703e-4e36-a95b-cd85aaf0e34b/677134f8-9e35-4bad-a4cb-0f8a088d7756/images/4d31e2b1-aa38-4883-befe-af9a2dbb0177/eac7f89d-335f-4d16-a106-2b1d483b33f7,if=none,id=drive-virtio-disk0,format=raw,serial=83-befe-af9a2dbb0177,cache=none,werror=stop,rerror=stop,aio=threads -device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,id=hostnet0,vhost=on -device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:1a:4a:42:0b:01,bus=pci.0,addr=0x3 -chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/channels/win7_64.com.redhat.rhevm.vdsm,server,nowait -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.rhevm.vdsm -chardev spicevmc,id=charchannel1,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1,name=com.redhat.spice.0 -usb -spice port=5900,addr=0,disable-ticketing -k en-us -vga qxl -global qxl-vga.vram_size=67108864

2.copy datas from guest to host (in the host choose the text ,right-click copy, on the host open gedit ,right-click paste)
3.stop VM
4,repeat step2 2 times
  
Actual results:
right-click does not work on the *host*

Expected results:
right-click should still work on the host.

Additional info:

Comment 1 Christophe Fergeau 2011-09-21 16:46:52 UTC
I've managed to reproduce this both with a winxp and a win7 box. What I've done is
* setup a windows VM with RHEV-toolsSetup_3.0_17
* open notepad or wordpad
* type some text
* right click/copy
* switch to gedit or gnotes
* right click/paste
* shutdown computer from the start menu in the VM
* click on "discard changes" when the text editor asks
* while it's shutting down, try to use the right click button from any gtk+ app
=> the button doesn't seem to work

It seemed to work in firefox though, but I need to run more tests to be 100% sure.
The right mouse button starts working again after the VM is completely shut down.

Comment 2 Christophe Fergeau 2011-09-22 12:29:31 UTC
After a discussion with hansg and more investigation, this happens because the windows agent never tells the client that the agent is shutting down and that the client should release the X selection and no longer try to query it.

11:15 < hansg> What I think is happening is that gedit / sticky notes sends a 
               clipboard message to the current clipboard owner on right 
               click, before drawing the menu. And the popup menu does not 
               get drawn because the client is the clipboard owner, forwards 
               the message to the agent in the vm, and the agent never answer 
               because the vm is shutting down
11:16 < hansg> The fix would be for the agent in the vm to send a clipboard 
               release message as soon as the shutdown starts
11:17 < hansg> Then the client will release the clipboard of the 
               client-machine
11:17 < hansg> So I would move the bug over to the windows agent with the 
               above explanation of what we believe is going on (I'm pretty 
               sure this is the case)

I checked that when right clicking in gedit, RedClient::send_agent_clipboard_message is called and a message is sent to spice-server, but the answer never comes back.

Comment 3 Arnon Gilboa 2011-09-26 09:08:31 UTC
(In reply to comment #2)
> After a discussion with hansg and more investigation, this happens because the
> windows agent never tells the client that the agent is shutting down and that
> the client should release the X selection and no longer try to query it.
> 
> 11:15 < hansg> What I think is happening is that gedit / sticky notes sends a 
>                clipboard message to the current clipboard owner on right 
>                click, before drawing the menu. And the popup menu does not 
>                get drawn because the client is the clipboard owner, forwards 
>                the message to the agent in the vm, and the agent never answer 
>                because the vm is shutting down
> 11:16 < hansg> The fix would be for the agent in the vm to send a clipboard 
>                release message as soon as the shutdown starts
> 11:17 < hansg> Then the client will release the clipboard of the 
>                client-machine
> 11:17 < hansg> So I would move the bug over to the windows agent with the 
>                above explanation of what we believe is going on (I'm pretty 
>                sure this is the case)
> 
> I checked that when right clicking in gedit,
> RedClient::send_agent_clipboard_message is called and a message is sent to
> spice-server, but the answer never comes back.

Why not just call Platform::on_clipboard_release() from RedClient::handle_agent_disconnected(), which is called anyway when agent is stopped?

Comment 4 Christophe Fergeau 2011-09-26 09:28:34 UTC
I just tried that, RedClient::handle_agent_disconnected is called while the VM is shutting down, so I could add the call there. The result is that it helps somewhat, ie mouse clicks become functional again more quickly. However, there's still a window when mouse clicks are blocked between the click on "shutdown" in windows and the time RedClient::handle_agent_disconnected, and this takes a few seconds here so it's still noticeable.

Comment 5 Arnon Gilboa 2011-11-21 09:50:56 UTC
Created attachment 534751 [details]
release clipboard ownership on agent stop & desktop switch

Comment 6 Arnon Gilboa 2011-11-22 13:15:02 UTC
This patch solves buggy agent behavior, and it's not risky from other perspectives.
Proposing to rhevm‑3.0.0.

Comment 7 Marian Krcmarik 2011-11-28 18:48:42 UTC
Verified on vdagent-win-0.1-9.
(based on steps from comment #2)