Commit Graph

355 Commits

Author SHA1 Message Date
Yonit Halperin
84ff23cd2b server: replace redundant code with red_cursor_reset
In addition (1) make handle_dev_destroy_surfaces call red_release_cursor
(2) call red_wait_outgoing_item(cursor_channel) only after adding msgs to pipe

[3d3066b175 cherry-pick with modifications]
2011-07-21 15:09:29 +03:00
Christophe Fergeau
7db7212c3a use foo(void) instead of foo() in prototypes
In C, the latter isn't a prototype for a function with no arg,
but declares a function with an undefined number of args.

[picked from master with changes since no main_channel, spice_common,
 and a bunch of functions aren't there yet]
2011-07-21 15:09:29 +03:00
Alon Levy
c9c84c9f8d server: api: add spice_qxl_* calls based on QXLWorker contents
For each callback in QXLWorker, for example QXLWorker::update_area, add
a direct call named spice_qxl_update_area.

This will (a) remove the pointless indirection and (b) make shared
library versioning alot easier as we'll get new linker symbols which
we can tag with the version they appeared in the shared library.

[cherry-picked from master]
2011-07-21 15:09:29 +03:00
Christophe Fergeau
66ad3e84f3 s/__visible__/SPICE_GNUC_VISIBLE
The C specification reserves use of identifiers starting with __
to the compiler so we shouldn't use one such symbol.

[cherry-pick from master]
2011-07-21 15:09:29 +03:00
Alon Levy
f3ee396dfe server: spice-server.syms: move sasl symbols to 0.8.2
[0.8: there are no 0.10.0 symbols]
2011-07-21 15:09:29 +03:00
Christophe Fergeau
edce17a574 Fix spice-server/qemu channel version checks
When qemu creates a channel, reds.c contains code to check the
minor/major channel versions known to QEMU (ie the ones that were
current in spice-server when QEMU was compiled) and to compare these
versions against the current ones the currently installed spice-server
version.

According to kraxel [1], the rules for these interface numbers are:

"The purpose of the versions is exactly to avoid the need for a new
soname.  The rules are basically:

   (1) You add stuff to the interface, strictly append-only to not break
       binary compatibility.
   (2) You bump the minor version of the interface.
   (3) You check the minor version at runtime to figure whenever the
       added fields contain valid stuff or not.

An example is here (core interface, minor goes from 2 to 3, new
channel_event callback):

http://cgit.freedesktop.org/spice/spice/commit/?id=97f33fa86aa6edd25111b173dc0d9599ac29f879
"

The code currently refuses to create a channel if QEMU minor version is
less than the current spice-server version. This does not correspond
to the intended behaviour, this patch changes to fail is qemu was compiled
with a spice-server that is *newer* than the one currently installed. This
case is something we cannot support nicely.

[1] http://lists.freedesktop.org/archives/spice-devel/2011-July/004440.html
2011-07-21 15:09:29 +03:00
Yonit Halperin
4c44be35b0 server: fix access to a released drawable. RHBZ #713474
red_pipe_add_drawable can lead to removal of drawables from current tree
(since it calls red_handle_drawable_surfaces_client_synced), which can
also lead to releasing these drawables.
Before the fix, red_current_add_equal, called red_pipe_add_drawable,
without assuring afterwards that the drawables it refers to are still alive or
still in the current tree.
2011-07-21 15:09:28 +03:00
Yonit Halperin
e22354141e server: add missing calls to red_handle_drawable_surfaces_client_synced
red_handle_drawable_surfaces_client_synced was called only from red_pipe_add_drawable, while it
should also be called from red_pipe_add_drawable_after. Otherwise, the client
might receive a command with a reference to a surface it doesn't hold and crash.
2011-07-21 15:09:28 +03:00
Yonit Halperin
ec6198218a server: removing local cursor, this solves RHBZ #714801
When the worker was stoped, the cursor was copied from guest ram to the host ram,
and its corresponding qxl command was released.
This is unecessary, since the qxl ram still exists (we keep references
to the surfaces in the same manner).
It also led to BSOD on guest upon migration: the device tracks cursor set commands and it stores
a reference to the last one. Then, it replays it to the destination server when migrating to it.
However, the command the qxl replayed has already been released from the pci by the original
worker, upon STOP.

Conflicts:

	server/red_worker.c
2011-07-21 15:09:28 +03:00
Alon Levy
a3a6224820 server/smartcard: register channel only when hardware is available 2011-07-21 15:09:28 +03:00
Alon Levy
d830cf0553 server/smartcard: handle BaseChannel messages
According to spice.proto the smartcard channel can receive acks and any
other message defined in BaseChannel. While the spicec implementation didn't
send an ACK spice-gtk does, so handle it.
2011-07-21 15:09:28 +03:00
Zeeshan Ali (Khattak)
51bc547921 server: Unset executable bit of red_tunnel_worker.h 2011-07-21 15:09:28 +03:00
Christophe Fergeau
551ad336c1 add missing "LGPLv2.1 or later" header to source files 2011-07-21 15:09:28 +03:00
Christophe Fergeau
fdfc940f59 server/tests remove useless assignment
This was detected by clang-static-analyzer.
2011-07-21 15:09:27 +03:00
Marc-André Lureau
f42e261aa6 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

Conflicts:

	server/reds.c
	server/reds.h
2011-07-21 15:09:27 +03:00
Marc-André Lureau
6101cb805a server: add auth mechanism selection
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-07-21 15:09:27 +03:00
Marc-André Lureau
bb6747b3d5 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-07-21 15:09:26 +03:00
Marc-André Lureau
159fee00c2 server: simplify and constify sync_write()
+ symplify, improving style of code using it.

https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-07-21 15:09:26 +03:00
Marc-André Lureau
8186db28c2 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-07-21 15:09:26 +03:00
Marc-André Lureau
b1df04b9c5 build: add --with-sasl
Using cyrus SASL library (same as gtk-vnc/qemu).

https://bugs.freedesktop.org/show_bug.cgi?id=34795

Conflicts:

	configure.ac
2011-07-21 15:09:26 +03:00
Marc-André Lureau
a3732afda3 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-07-21 15:09:26 +03:00
Marc-André Lureau
26ded5e395 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-07-21 15:09:26 +03:00
Marc-André Lureau
5f27f8f522 server/reds: remove the void* ctx field
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-07-21 15:09:26 +03:00
Marc-André Lureau
36ab16d6c5 server: use the new reds_stream_{read,write}
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-07-21 15:09:26 +03:00
Marc-André Lureau
584cc5a3d1 server: remove cb_free, not needed anymore
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-07-21 15:09:26 +03:00
Marc-André Lureau
a5946a54dd 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-07-21 15:09:26 +03:00
Marc-André Lureau
6d8cbc2349 server: use reds_stream_remove_watch() helper
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-07-21 15:09:26 +03:00
Marc-André Lureau
eeb95c5b84 server: add reds_stream_{read,write,free,remove_watch}()
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-07-21 15:09:25 +03:00
Marc-André Lureau
881971fbca server: s/RedsStreamContext/RedsStream
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-07-21 15:09:25 +03:00
Marc-André Lureau
a1ef838d34 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-07-21 15:09:25 +03:00
Marc-André Lureau
e1cfe664c4 build: make it silent
This patch make it easier to spot warnings in compilation.  It should
work with older versions of automake that don't support silent rules.

If you want verbose build, make V=1.

Signed-off-by: Uri Lublin <uril@redhat.com>

https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-07-21 15:09:25 +03:00
Alon Levy
fcd4a8e446 server/red_channel: fix segfault on red_channel_destroy if peer already removed 2011-07-21 15:09:25 +03:00
Alon Levy
58f79a98b6 server/tests: Makefile.am: use AM_LDFLAGS instead of LDFLAGS 2011-07-21 15:08:32 +03:00
Alon Levy
ae7659fea9 server/red_channel: error channel if alloc_msg_buf fails (returns NULL) 2011-07-21 15:08:32 +03:00
Gerd Hoffmann
89accad2bf server: add symbol versioning to the spice server shared library.
This patch adds symbol versions to the spice server library.  Each
symbol which is exported by libspice-server gets tagged with the
(stable) version where it appeared first.  This way the linker and rpm
are able to figure which version of the spice-server libary is required
by a particular qemu binary/package.

[ 0.8 branch: drop 0.10 symbols from list ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-07-19 14:41:10 +02:00
Alon Levy
529dc40dc3 server/smartcard: fix use after free 2011-05-24 16:11:26 +03:00
Hans de Goede
443994ba87 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-01 16:46:55 +02:00
Hans de Goede
620a02da31 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-01 16:45:50 +02:00
Hans de Goede
2df49c8a67 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-01 16:31:37 +02:00
Hans de Goede
5d7cf4c002 server: add discard all option to agent message filter 2011-04-01 14:22:44 +02:00
Hans de Goede
1ec316e561 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-01 14:14:00 +02:00
Hans de Goede
add4bedb2f 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-01 14:08:56 +02:00
Hans de Goede
a19f51265c 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-01 11:13:50 +02:00
Hans de Goede
7cc85f33be 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-01 11:13:50 +02:00
Hans de Goede
ef6886732e 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-01 11:13:46 +02:00
Hans de Goede
302ab69f5b 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:24:31 +01:00
Hans de Goede
0417117417 spice-server: Add the ability to filter agent messages 2011-03-24 17:24:31 +01:00
Alon Levy
5315888a70 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:49:21 +02:00
Hans de Goede
7fd8b7c971 Release 0.8.0 2011-03-01 19:40:36 +02:00
Gerd Hoffmann
aa827c5b99 fix spice-server segfault on migration
spice-server tries to use the migration information without checking
whenever this is available in the first place ...

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-02-15 11:24:28 +01:00