Bug 712938

Summary: Can't connect to linux guest with WAN options
Product: Red Hat Enterprise Linux 6 Reporter: Swapna Krishnan <skrishna>
Component: spice-clientAssignee: Christophe Fergeau <cfergeau>
Status: CLOSED ERRATA QA Contact: Desktop QE <desktop-qa-list>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.2CC: agilboa, alevy, cfergeau, cmeadors, dblechte, mkenneth, mkrcmari, uril
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: spice-client-0.8.2-1.el6 Doc Type: Bug Fix
Doc Text:
Cause When WAN options are given to spice-client, and an agent is running on the guest, spice-client sends a VD_AGENT_DISPLAY_CONFIG to the agent, and wait for repl y. Spice vdagent running on a linux guest does not yes support WAN options, and does not reply on VD_AGENT_DISPLAY_CONFIG. Consequence When WAN options are given to a spice-client connected to a Linux guest, conne ction fails with vdagent timeout. Fix When no agent is running on the guest, or if the agent does not support WAN op tions (VD_AGENT_CAP_DISPLAY_CONFIG capability), spice-client does not wait for a gent on the guest to reply, but continue with the initiating message sequence (sending SPICE_MSGC_MAIN_ATTACH_CHANNELS). Result When WAN options are given to a spice-client connected to a Linux guest, conn ection succeeds. See: Comment 3
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 15:22:29 UTC Type: ---
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
Proposed patch (ChangeLog needs writing ;)
none
The initial patch was buggy, fixed version
none
this patch was needed on top of the previous one
none
agent timeout patch none

Description Swapna Krishnan 2011-06-13 16:52:45 UTC
Description of problem:

If you try to connect to a linux guest with WAN options, SPICE window opens up and is blank - it then fails with vdagent timeout message.  It should give a warning that this is only applicable for windows guest and still connect to guest. 

# spicec -h localhost -p 5904 --color-depth 16
Warning: abort
Error: unhandled exception: vdagent timeout

Host is RHEL 6.1, guest is RHEL 6.1

spice-client-0.8.0-2.el6.x86_64
spice-server-0.8.0-1.el6.x86_64
qemu-kvm-0.12.1.2-2.160.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Connect to a linux guest through spicec with WAN options
2. Connections fails with vdagent timeout
  
Actual results:
Can't connect to linux guest

Expected results:
Connect to linux guest with warning message that WAN options are only for windows guests

Additional info:

Comment 2 Swapna Krishnan 2011-07-05 16:13:56 UTC
Forgot to mention this when I filed the bug.

When spice-vdagentd is running on the linux guest and I try to connect with WAN features, I still get vdagent timeout message. 

Thanks,
- Swapna

Comment 3 Christophe Fergeau 2011-07-06 14:25:18 UTC
I think I figured out what is going on.
It all starts in RedClient::handle_init
This function checks whether we have an agent or not, because if we have an agent, there will be some kind of handshake to check both sides capabilities before all the spice channels are created.

When there is no agent running, the startup process goes on with SPICE_MSGC_MAIN_ATTACH_CHANNELS

When there is a windows agent running, VD_AGENT_ANNOUNCE_CAPABILITIES and VD_AGENT_DISPLAY_CONFIG messages are sent to the agent, and when processing the agent answer to the VD_AGENT_DISPLAY_CONFIG message, SPICE_MSGC_MAIN_ATTACH_CHANNELS will be sent and the startup process will go on.

However, when there is no agent running but --color-depth was used, handle_init won't send the SPICE_MSGC_MAIN_ATTACH_CHANNELS message but will wait for the agent handshake to proceed to its end, which won't happen, so it will timeout waiting for agent answers.

Similarly, the linux agent handles VD_AGENT_ANNOUNCE_CAPABILITIES messages, but it doesn't handle VD_AGENT_DISPLAY_CONFIG messages, so we'll never reach the point where a SPICE_MSGC_MAIN_ATTACH_CHANNELS will be sent.

I suggest 2 fixes:
- unconditionnally send SPICE_MSGC_ATTACH_CHANNELS when no agent is running in handle_init
- send SPICE_MSGC_MAIN_ATTACH_CHANNELS in RedClient::on_agent_announce_capabilities if the agent doesn't have the VD_AGENT_CAP_DISPLAY_CONFIG capability

Comment 4 Christophe Fergeau 2011-07-06 14:56:14 UTC
Created attachment 511509 [details]
Proposed patch (ChangeLog needs writing ;)

Comment 8 Christophe Fergeau 2011-07-18 16:37:23 UTC
I committed the patch from comment #3 to spice git master

Comment 9 Christophe Fergeau 2011-07-19 11:53:29 UTC
Created attachment 513780 [details]
The initial patch was buggy, fixed version

Comment 10 Christophe Fergeau 2011-07-19 11:54:56 UTC
Comment on attachment 513780 [details]
The initial patch was buggy, fixed version

Wrong bug

Comment 11 Christophe Fergeau 2011-07-21 16:01:38 UTC
Created attachment 514226 [details]
this patch was needed on top of the previous one

First patch was buggy, this patch needs to be applied on top of it.

Comment 12 Christophe Fergeau 2011-07-28 09:01:22 UTC
This is fixed in spice 0.8.2 which RHEL6.2 is being rebased to.

Comment 13 Arnon Gilboa 2011-07-28 14:22:44 UTC
Created attachment 515734 [details]
agent timeout patch

Comment 14 Arnon Gilboa 2011-07-28 15:36:23 UTC
The (already pushed) patch from comment 11 caused the following regression:

When client runs without the auto-conf or disable-effects options (either from CLI or controller), which is the case when using Spice from Admin Portal, the client will unecessarily wait for 30sec before connecting.

The mentioned patch assumed that on_agent_reply() of VD_AGENT_DISPLAY_CONFIG will call send_main_attach_channels() and connect. However, when auto-conf or disable-effects are not used, on_agent_reply() will ignore the reply and not call send_main_attach_channels(). Therefore, send_main_attach_channels() will only be called on agent timeout.

The solution (attachment 515734 [details] by Christophe) is to activate agent timer only if auto-conf or disable-effects. Otherwise, simply call send_main_attach_channels().

Opend BZ #726441 for this one.

Comment 15 Christophe Fergeau 2011-07-28 15:47:23 UTC
(In reply to comment #14)
> When client runs without the auto-conf or disable-effects options (either from
> CLI or controller), which is the case when using Spice from Admin Portal, the
> client will unecessarily wait for 30sec before connecting.

and when the guest is a windows guest with an agent running, this won't happen on linux, or when the agent is not running.

Comment 17 Uri Lublin 2011-07-31 09:25:39 UTC
Comment on attachment 515734 [details]
agent timeout patch

A fix for rhbz#726441 (introduced by a fix for this bug)

Comment 18 Marian Krcmarik 2011-08-03 23:09:15 UTC
Verified on spice-client-0.8.2-2.

Comment 19 Uri Lublin 2011-11-20 14:48:08 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause
  When WAN options are given to spice-client, and an agent is running on the guest, spice-client sends a VD_AGENT_DISPLAY_CONFIG to the agent, and wait for repl
y.
  Spice vdagent running on a linux guest does not yes support WAN options, and does not reply on VD_AGENT_DISPLAY_CONFIG.

Consequence
  When WAN options are given to a spice-client connected to a Linux guest, conne
ction fails with vdagent timeout.

Fix
  When no agent is running on the guest, or if the agent does not support WAN op
tions (VD_AGENT_CAP_DISPLAY_CONFIG capability), spice-client does not wait for a
gent on the guest to reply, but continue with the initiating message sequence (sending SPICE_MSGC_MAIN_ATTACH_CHANNELS).

Result
   When WAN options are given to a spice-client connected to a Linux guest, conn
ection succeeds.

See: Comment 3

Comment 20 errata-xmlrpc 2011-12-06 15:22:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1518.html