[Spice-devel] RFC: dealing with client / agent disconnect during multi chunk agent messages

Hans de Goede hdegoede at redhat.com
Fri Apr 1 03:15:21 PDT 2011


Hi,

The agent protocol requires sending messages in 2048 byte chunks, this
means that 1 message can span multiple chunks. In the past this never
happened but now that we support copy and paste this can easily
happen with a large copy and paste.

There are 4 scenarios to keep in mind here:

1) The client disconnects halfway sending a multi chunk agent
message to the agent. In this case the agent has received some
data, but not all and will see any agent messages from a new client
as part of the previous message -> problem.

Proposed solution:
1a) Add a VD_AGENT_CAP_CLIENT_STATE capability to the agent protocol
1b) Add a VD_AGENT_CLIENT_STATE message to the protocol, which can
     have one of 2 values: connected and disconnected
1c) Make the agent send its capabilities to both the client port
     and the server port
1d) When the server has received agent capabilities including
     VD_AGENT_CAP_CLIENT_STATE, send a message to the agent whenever
     a client connects / disconnects (*)
1e) The agent will clear any state wrt a partial received agent
     message from the client port on client disconnect.


2) A new client connects while the guest agent is sending a multi chunk
agent message. We already throw away any guest agent messages
received when there is no client connected. But if a new client
connects half way through the agent sending a multichunk messages we
still have a problem.

Proposed solution:
Keep track of how much of the message has already been received (we
already do this now for message filtering) and throw away anything we
receive which is part of the message which was being send while the
client connected.


3) The agent disconnects halfway sending a multi chunk agent
message to the client. We already notify the client of agent start /
stop, so we need to make sure the client resets state wrt any partially
received messages on receiving an agent stop notification.


4) A new agent connects while the client is sending a multi chunk
agent message. We already throw away any client messages for the agent
received when there is no agent connected. But if a new agent
connects half way through the client sending a multichunk messages we
still have a problem.

Proposed solution:
Keep track of how much of the message has already been received (we
already do this now for message filtering) and throw away anything we
receive which is part of the message which was being send while the
agent connected.

Regards,

Hans


*) We need to think of how this works in multiclient, but that is a problem
in general. We could use the port multiplexing concept of the agent channel,
to allow multiple clients to use the agent for things like copy and paste,
the guest agent would then need to keep track of clipboard requests per
client, etc.


More information about the Spice-devel mailing list