Commit Graph

139 Commits

Author SHA1 Message Date
Hans de Goede
3953b9ff1b server: make sure we clear vdagent and update mouse mode on agent disconnect
The check this patch removes causes us to not set vdagent to NULL, nor
update the mouse mode when the guest agent disconnects when no client is
attached. Which leads to a non working mouse, and on agent reconnect a
"spice_server_char_device_add_interface: vdagent already attached" message
instead of a successful re-add of the agent interface .
2011-04-04 11:53:47 +02:00
Hans de Goede
00a03b7633 server: ignore SPICE_MSGC_MAIN_AGENT_START messages when there is no agent
This can happen for example when a SPICE_MSGC_MAIN_AGENT_START message
from the client and the vdagent disconnecting race.
2011-04-04 11:52:48 +02:00
Hans de Goede
e472bc7d5a server: hookup agent-msg-filter discard-all functionality
This ensures that if the client or agent connects to the client-agent
"tunnel" while the other side is halfway through sending a multi part
message, the rest of the message gets discarded, and the connecting
party starts getting data at the beginning of the next message.
2011-04-04 11:47:46 +02:00
Hans de Goede
3accb60240 server: add discard all option to agent message filter 2011-04-04 11:30:30 +02:00
Hans de Goede
66cf0e28b3 server: filter all data from client
Filter all data from client, even when there is no agent connected
to keep filter state correct.
2011-04-04 11:26:54 +02:00
Hans de Goede
326fdf34f2 server: reset read/write filter on agent/client disconnect
The agent message filter keeps track of messages as they are being send
reset the relevant filter to its initial state when one of the 2 ends
of the agent<->client "tunnel" disconnects.
2011-04-04 11:24:47 +02:00
Hans de Goede
d590666408 server: break read_from_vdi_port loop if the guest gets disconnected
read_from_vdi_port calls dispatch_vdi_port data, which will disconnect
the guest agent if it sends invalid data. It would then try to read more
data from the disconnected guest agent resulting in a NULL ptr dereference,
this patch fixes this.
2011-04-04 11:23:11 +02:00
Hans de Goede
c652dfa5e6 server: Don't stop writing agent data to the guest when the client disconnects
write_to_vdi_port() was checking for reds->agent_state.connected to determine
wether it could write queued data. But agent_state.connected reflects if
*both* ends are connected. If the client has disconnected, but the guest agent
is still connected and some data is still pending (like a final clipboard
release from the client), then this data should be written to the guest agent.
2011-04-04 11:23:05 +02:00
Hans de Goede
f8e6dc78c7 server: Don't reset agent state when the client disconnects
We were calling reds_reset_vdp on client disconnect, which is not a good
idea. reds_reset_vdp does 3 things:

1) It resets the state related to reading chunks from the spicevmc virtio
   port. If the client disconnects while the guest agent is in the middle
   of sending a chunk, this will lead to an inconsistent state, and lots
   of printing of "dispatch_vdi_port_data: invalid port" messages caused
   by this inconsistent state sometimes followed by a segfault.

   This can be triggered by copy and pasting something large (say
   a screenshot) from the guest to the spice-gtk client, as the spice-gtk
   client currently has a bug causing it to crash when receiving a multi
   chunk vdagent messages. Without this patch (and with the spice-gtk bug
   present) I can consistently reproduce this.

2) It clears any buffered writes from the client to the guest still pending
   because the virtio port cannot consume data fast enough. Since the agent
   itself is still running fine, throwing away writes for it because the
   client has disconnected makes no sense. Esp, since on clean exit the
   client may very well send a clipboard release message directly
   before closing the connection, and this may get lost this way.

3) It sets client_agent_started to false, this is the only thing which
   actually makes sense to do on client disconnect.

Note that since we no longer reset the vdp state on client disconnect, we
must now reset it on agent disconnect even if we don't have a client. So
the reds_reset_vdp call in reds_agent_remove() gets moved to the top,
above both the agent_state.connected and reds->peer checks which will
both fail in the no client case.
2011-04-04 11:22:24 +02:00
Hans de Goede
c231417393 server: avoid unneeded recursion in dispatch_vdi_port_data
dispatch_vdi_port_data, was calling vdi_read_buf_release when no client
is connected to free the passed in buf. The only difference between
vdi_read_buf_release and directly adding the buffer back to the ring
with ring_add, is that vdi_read_buf_release calls read_from_vdi_port
after adding the buffer back. But dispatch_vdi_port_data only gets called
from read_from_vdi_port itself, thus this would lead to recursing into
read_from_vdi_port. read_from_vdi_port is protected against recursion and
will immediately return if called recursively. Thus calling
vdi_read_buf_release from dispatch_vdi_port_data is pointless, instead
simply putting the buffer back in the ring suffices.
2011-03-24 17:34:29 +01:00
Hans de Goede
bcf9a60aa9 server: Make copy paste support configurable
Also bump SPICE_SERVER_VERSION to 0x000801 as 0.8.1 will be the
first version with the new API for this, and we need to be able to
detect the presence of this API in qemu.
2011-03-24 17:30:03 +01:00
Hans de Goede
c2db6d1066 spice-server: Add the ability to filter agent messages 2011-03-24 17:28:21 +01:00
Alon Levy
61d8e54766 server/reds: allow call to reds_agent_remove even if it is gone
The current assert(reds->agent_state.connected) tiggers if when
the agent disconnected there was still data waiting to be sent (for
instance if there is a bug in the client handling clipboard and it
is killed while a large clipboard transfer is in progress). So first
call to reds_agent_remove happens from spice_server_char_device_remove_interface,
and then it is called again (triggering the assert) from free_item_data
from read_from_vdi_port because of the channel destruction.

Other option would be to not call it from one of the paths - but that
is suboptimal:
 * if there is no data in the pipe, the second call never happens.
 * the second call has to be there anyway, because it may fail during
  parsing data from the agent.

This patch fixes a segfault on this assert when a client starts passing
from guest agent to client a large clipboard and dies in the middle. There
is still another assert happening occasionally at marshaller which I don't
have a fix for (but it doesn't seem to be related).
2011-03-08 21:18:55 +02:00
Marc-André Lureau
8f9cbd19db server: add SASL support
We introduce 2 public functions to integrate with the library user.

spice_server_set_sasl() - turn on SASL
spice_server_set_sasl_appname() - specify the name of the app (It is
used for where to find the default configuration file)

The patch for QEMU is on its way.

https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-28 16:36:35 +01:00
Marc-André Lureau
f4dddc50f0 server: add auth mechanism selection
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-28 16:36:35 +01:00
Marc-André Lureau
4f983b2c9c server: add reds_channel_dispose()
Try to have a common base dispose() method for channels. For now, it
just free the caps.

Make use of it in snd_worker, and in sync_write() - sync_write() is
going to have default caps later on.

https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-28 16:36:35 +01:00
Marc-André Lureau
09c01c9516 server: simplify and constify sync_write()
+ symplify, improving style of code using it.

https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-28 16:36:35 +01:00
Marc-André Lureau
37dbb8aec9 server: pull out reds_handle_link(), for future reuse
+ a couple of indent, style change

https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-28 16:36:35 +01:00
Marc-André Lureau
2ced8996c8 server/reds: make writev fallback more generic
We are going to reuse it for SASL/SSF encode write().

https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-28 16:36:35 +01:00
Marc-André Lureau
76dc27f08a server: rename s/peer/stream
This is stylish change again. We are talking about a RedStream object,
so let's just name the variable "stream" everywhere, to avoid
confusion with a non existent RedPeer object.

https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-28 16:36:35 +01:00
Marc-André Lureau
1a4923c210 server/reds: remove the void* ctx field
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-28 16:36:35 +01:00
Marc-André Lureau
fc5d7f7625 server: use the new reds_stream_{read,write}
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-28 16:36:28 +01:00
Marc-André Lureau
f32503258f server: remove cb_free, not needed anymore
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-27 18:26:19 +01:00
Marc-André Lureau
07d6dd6108 server: use reds_{link,stream}_free()
Be carefull removing the watch before, like __release_link

https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-27 18:26:19 +01:00
Marc-André Lureau
fca602124d server: use reds_stream_remove_watch() helper
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-27 18:26:18 +01:00
Marc-André Lureau
b79e7320de server: add reds_stream_{read,write,free,remove_watch}()
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-27 18:26:15 +01:00
Marc-André Lureau
d47912241f server: s/RedsStreamContext/RedsStream
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-27 16:55:22 +01:00
Marc-André Lureau
29be54f6d3 server/reds: remove unused readv
Let's not bother with it since nobody uses it, and it's not implemented for SSL anyway

https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-27 16:55:22 +01:00
Alon Levy
46c70521d5 client/server: warning fixes (gcc 4.6.0)
gcc 4.6.0 added "[-Werror=unused-but-set-variable]", this and the next
few fixes tend to that. Mostly harmless.
2011-01-25 17:22:48 +02:00
Alon Levy
d3b22d86f0 client/server: add missing USE_TUNNEL
disable some code that only makes sense when USE_TUNNEL is defined
in client and server channel security level setting.
2011-01-25 17:16:27 +02:00
Alon Levy
5a2ef3b21c client/server: add missing smartchannel channel security handling
The name to channel id mapping for the smartcard channel is missing,
add it in client and server.
2011-01-25 17:16:18 +02:00
Alon Levy
e7e667f81d server/reds: don't remove agent if it's not connected 2011-01-13 06:56:54 +02:00
Alon Levy
26cd666be5 server/reds: protect reds_update_mouse_mode when main_channel is disconnected 2011-01-13 06:56:54 +02:00
Alon Levy
42522e0db9 server/reds: don't call close on NULL channel on atexit callback 2011-01-13 06:56:54 +02:00
Alon Levy
cd6c57e337 server/reds: fix possible segfault when accessing vdagent from reds_update_mouse_mode after vdagent set to NULL 2011-01-13 06:56:53 +02:00
Alon Levy
cdfa261dbb server/reds: s/reds_push_migrate_data_item/reds_marshall_migrate_data_item/ 2011-01-13 06:56:53 +02:00
Alon Levy
685f82a48e server: split main_channel from reds 2011-01-13 06:56:51 +02:00
Gerd Hoffmann
4b1ea4e102 client migration: switch host
Implement server-side support for switch-host client migration.  Client
side support is present already in the tree.

Setting the migration information is done using the existing
spice_server_migrate_info() function.  A new
spice_server_migrate_switch() function has been added which triggers
sending out the switch-host message.

Seamless migration functions are left there for now.
spice_server_migrate_start() has been chamnged to just fail
unconditionally though as seamless migration is broken anyway.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2010-12-16 09:16:10 +01:00
Gerd Hoffmann
aafd8eea74 server: improve error handling
We should pass up errors instead of aborting.  Do that at least
for bind() failures which actually happen in real live due to the
tcp port being busy.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2010-12-09 14:50:36 +01:00
Alon Levy
347e32177c server: introduce inputs_channel, split from reds.c 2010-12-07 21:32:33 +02:00
Alon Levy
26c40c4196 server/reds: fix typo 2010-12-07 21:32:33 +02:00
Alon Levy
d99ec6c35b smartcard: server side (not enabled yet) 2010-12-07 13:31:42 +02:00
Alon Levy
7461ee17cf server: add spice_server_char_device_remove_interface 2010-12-07 13:31:28 +02:00
Alon Levy
5220e0a706 server: print subtype when adding CHAR_DEVICE interfaces 2010-12-06 18:09:15 +02:00
Alon Levy
0ac9ca51f4 server: add static to spice_server_char_device_add_interface 2010-12-06 18:09:15 +02:00
Alon Levy
b2f1b80a63 server: fix print text on vdagent interface addition 2010-12-06 18:09:14 +02:00
Alon Levy
673ade8a6f server: add char_device.h header, use in reds.c 2010-12-06 18:09:14 +02:00
Alon Levy
dc8946f9f4 server/vdi_port (virtserial): always read data
We erronously ignored data from guest on the serial channel if no client is
connected. This leads to an assert when the guest writes a second time, since
there is still data unconsumed by us (the host).
Fix by reading data anyway, and discarding it after parsing (and reading) whole
messages from the guest.
Net affect is that any messages the agent sends while no client is connected
get discarded, but only full messages are discarded.
This fixes an abort if booting a winxp guest with vdagent without a connected
client.
2010-12-06 13:20:14 +02:00
Alon Levy
b6e530f5f3 server/reds: zap unsetting of QEMU_AUDIO_DRV 2010-11-08 17:53:17 +02:00
Alon Levy
bd30095c75 reds: remove needless buffer in InputsState 2010-11-08 16:06:49 +02:00