summaryrefslogtreecommitdiffstats
path: root/server
Commit message (Collapse)AuthorAgeFilesLines
* s/USE_OGL/USE_OPENGLChristophe Fergeau2011-05-032-9/+9
| | | | This is more explicit about what it does, and not much longer
* add #include <config.h> to all source filesChristophe Fergeau2011-05-0322-6/+65
| | | | | | | | When using config.h, it must be the very first include in all source files since it contains #define that may change the compilation process (eg libc structure layout changes when it's used to enable large file support on 32 bit x86 archs). This commit adds it at the beginning of all .c and .cpp files
* autotools: correctly build canvas-related codeChristophe Fergeau2011-05-037-5/+114
| | | | | | | | | | | | | | | | | | | | | spice client and spice server shares code from common/{gdi,gl,sw}_canvas.[ch]. However, while most of the code is shared, the server code wants a canvas compiled with SW_CANVAS_IMAGE_CACHE defined while the client code wants a canvas compiled with SW_CANVAS_CACHE. The initial autotools refactoring didn't take that into account, this is now fixed by this commit. After this commit, the canvas files from common/ are no longer compiled as part of the libspice-common.la convenience library. Instead, there are "proxy" canvas source files in client/ and server/ which #include the appropriate C files after defining the relevant #define for the binary that is being built. To prevent misuse of the canvas c files and headers in common/, SPICE_CANVAS_INTERNAL must be set when including the canvas headers from common/ or when building the c files from common/ otherwise the build will error out.
* autotools: refactor the whole build machineryChristophe Fergeau2011-05-032-98/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | spice Makefile.am setup is a bit confusing, with source file names being listed several times in different Makefile.am (generally, once in EXTRA_DIST and another time in another Makefile.am in _SOURCES). The client binaries are built by client/x11/Makefile.am, which means recursing into client, then into x11 to finally build spicec. This Makefile.am is also referencing files from common/ and client/, which is a bit unusual with autotools. This patch attempts to simplify the build process to get something more usual from an autotools point of view. The source from common/ are compiled into a libtool convenience library, which the server and the client links against which avoids referencing source files from common/ when building the server and the client. The client is built in client/Makefile.am and directly builds files from x11/ windows/ and gui/ if needed (without recursing in these subdirectories). This makes the build simpler to understand, and also makes it possible to list source files once, which avoids potential make distcheck breakage when adding new files. There is a regression in this patch with respect to sw_canvas/gl_canvas/gdi_canvas. They should be built with different preprocessor #defines resulting in different behaviour of the canvas for the client and the server. However, this is not currently the case, both the client and the server will use the same code for now (which probably means one of them is broken). This will be fixed in a subsequent commit. make distcheck passes, but compilation on windows using the autotools build system hasn't been tested, which means it's likely to be broken. It shouldn't be too hard ot fix it though, just let me know of any issues with this.
* add missing "LGPLv2.1 or later" header to source filesChristophe Fergeau2011-05-023-0/+51
|
* server: s/desable/disableChristophe Fergeau2011-05-023-4/+4
| | | | | This fixes a typo in some function names, there should be no functional change.
* use foo(void) instead of foo() in prototypesChristophe Fergeau2011-05-029-29/+29
| | | | | In C, the latter isn't a prototype for a function with no arg, but declares a function with an undefined number of args.
* server: remove extra arg in reds_on_main_agent_start callChristophe Fergeau2011-05-021-1/+1
|
* server: use is_primary_surfaceChristophe Fergeau2011-05-021-7/+4
| | | | | red_worker.c has an is_primary_surface helper function, but there were some places in the file not using it. This patch fixes that
* server/tests remove useless assignmentChristophe Fergeau2011-04-081-1/+0
| | | | This was detected by clang-static-analyzer.
* tests: fix compilation with -Wall -WerrorChristophe Fergeau2011-04-083-3/+7
| | | | | | When compiling spice with make CFLAGS="-g3 -ggdb3 -O0 -Wall -Werror", the build broken because of a few unused variables/missing returns. This patch fixes these warnings.
* remove duplicated macroChristophe Fergeau2011-04-041-2/+0
| | | | MIN() is already defined in spice-protocol/spice/macros.h
* server: make sure we clear vdagent and update mouse mode on agent disconnectHans de Goede2011-04-041-3/+0
| | | | | | | | 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 .
* server: ignore SPICE_MSGC_MAIN_AGENT_START messages when there is no agentHans de Goede2011-04-041-0/+3
| | | | | This can happen for example when a SPICE_MSGC_MAIN_AGENT_START message from the client and the vdagent disconnecting race.
* server: hookup agent-msg-filter discard-all functionalityHans de Goede2011-04-041-30/+22
| | | | | | | 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.
* server: add discard all option to agent message filterHans de Goede2011-04-043-18/+26
|
* server: filter all data from clientHans de Goede2011-04-041-11/+11
| | | | | Filter all data from client, even when there is no agent connected to keep filter state correct.
* server: reset read/write filter on agent/client disconnectHans de Goede2011-04-041-0/+2
| | | | | | 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.
* server: break read_from_vdi_port loop if the guest gets disconnectedHans de Goede2011-04-041-1/+1
| | | | | | | 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.
* server: Don't stop writing agent data to the guest when the client disconnectsHans de Goede2011-04-041-2/+2
| | | | | | | | 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.
* server: Don't reset agent state when the client disconnectsHans de Goede2011-04-041-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* server: avoid unneeded recursion in dispatch_vdi_port_dataHans de Goede2011-03-241-1/+1
| | | | | | | | | | | | | 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.
* server: Make copy paste support configurableHans de Goede2011-03-242-3/+14
| | | | | | 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.
* spice-server: Add the ability to filter agent messagesHans de Goede2011-03-244-2/+162
|
* server/tests: add test_playbackAlon Levy2011-03-223-1/+105
|
* server: use -std=c99Alon Levy2011-03-221-0/+1
| | | | Finds some bugs.
* server/reds: allow call to reds_agent_remove even if it is goneAlon Levy2011-03-081-1/+3
| | | | | | | | | | | | | | | | | | | | | 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).
* server/input: avoid double free() of RedChannel on disconnectMarc-André Lureau2011-03-031-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current master is calling red_channel_destroy() on incoming error, but reds Channels still references it, which causes a double free() later on (see valgrind report below). Instead, on error condition, do like the rest of the channels and call reds_disconnect(), which remove the references and call shutdown(), which then call red_channel_destroy() and finally free the channel with red_channel_destroy(). Note: the previous code intention was certainly to be able to keep the rest of the channels connected when input channel has errors. This is not addressed by this patch. red_channel_shutdown: ==29792== Invalid read of size 8 ==29792== at 0x4C6F063: red_channel_shutdown (red_channel.c:460) ==29792== by 0x4C51EFA: inputs_shutdown (inputs_channel.c:463) ==29792== by 0x4C48445: reds_shatdown_channels (reds.c:539) ==29792== by 0x4C4868A: reds_disconnect (reds.c:603) ==29792== by 0x4C519E9: main_channel_on_error (main_channel.c:765) ==29792== by 0x4C6E80A: red_channel_peer_on_incoming_error (red_channel.c:215) ==29792== by 0x4C6E22D: red_peer_handle_incoming (red_channel.c:87) ==29792== by 0x4C6E551: red_channel_receive (red_channel.c:154) ==29792== by 0x4C6F329: red_channel_event (red_channel.c:531) ==29792== by 0x41CB8C: main_loop_wait (vl.c:1365) ==29792== by 0x437CDE: kvm_main_loop (qemu-kvm.c:1589) ==29792== by 0x41FE9A: main (vl.c:1411) ==29792== Address 0x30b0f6d0 is 0 bytes inside a block of size 28,648 free'd ==29792== at 0x4A05372: free (vg_replace_malloc.c:366) ==29792== by 0x4C6F032: red_channel_destroy (red_channel.c:454) ==29792== by 0x4C6E80A: red_channel_peer_on_incoming_error (red_channel.c:215) ==29792== by 0x4C6E22D: red_peer_handle_incoming (red_channel.c:87) ==29792== by 0x4C6E551: red_channel_receive (red_channel.c:154) ==29792== by 0x4C6F329: red_channel_event (red_channel.c:531) ==29792== by 0x41CB8C: main_loop_wait (vl.c:1365) ==29792== by 0x437CDE: kvm_main_loop (qemu-kvm.c:1589) ==29792== by 0x41FE9A: main (vl.c:1411) https://bugs.freedesktop.org/show_bug.cgi?id=34971
* Revert "server/red_channel: red_channel_event: push on blocked"Marc-André Lureau2011-03-031-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5062433d8af45822371b6487a8d7baea23071d18. red_channel_receive() can call red_channel_destroy() which frees channel. The condition bellow is then checked, which can access a freed channel: if (event & SPICE_WATCH_EVENT_WRITE || channel->send_data.blocked) Reverting this commit solves the issue without any apparent bugs/drawbacks, which kind of clears out the weird TODO. handle_dev_input: cursor connect ==11826== Invalid read of size 4 ==11826== at 0x4C6F83C: red_channel_event (red_channel.c:535) ==11826== by 0x41CB8C: main_loop_wait (vl.c:1365) ==11826== by 0x437CDE: kvm_main_loop (qemu-kvm.c:1589) ==11826== by 0x41FE9A: main (vl.c:1411) ==11826== Address 0x31fb00f0 is 96 bytes inside a block of size 28,648 free'd ==11826== at 0x4A05372: free (vg_replace_malloc.c:366) ==11826== by 0x4C6F536: red_channel_destroy (red_channel.c:453) ==11826== by 0x4C52B5D: inputs_channel_on_incoming_error (inputs_channel.c:449) ==11826== by 0x4C6ED0E: red_channel_peer_on_incoming_error (red_channel.c:215) ==11826== by 0x4C6E731: red_peer_handle_incoming (red_channel.c:87) ==11826== by 0x4C6EA55: red_channel_receive (red_channel.c:154) ==11826== by 0x4C6F82D: red_channel_event (red_channel.c:530) ==11826== by 0x41CB8C: main_loop_wait (vl.c:1365) ==11826== by 0x437CDE: kvm_main_loop (qemu-kvm.c:1589) ==11826== by 0x41FE9A: main (vl.c:1411) ==11826== https://bugs.freedesktop.org/show_bug.cgi?id=34971
* server/red_worker: use red_channel_pipe_item_initAlon Levy2011-03-022-30/+38
| | | | replaces in file red_pipe_item_init.
* server/red_channel: move out_bytes_counter from Outgoing to RedChannelAlon Levy2011-03-023-7/+17
|
* server/red_channel: split Incoming/Outgoing to callback and stateAlon Levy2011-03-022-42/+57
| | | | | | | | This allows later to have the callback table under RedChannel when the callbacks actually get used by RedChannelClient. Since the cb's are identical for different clients of the same channel it makes sense to store the callback pointers in one place per channel. The rest of the incoming and outgoing struct just gets moved to RedChannelClient.
* server/red_channel: no opaque in red_channel_peer_on_*_errorAlon Levy2011-03-021-8/+4
|
* server/red_worker: use red_channel_is_connectedAlon Levy2011-03-021-3/+3
|
* server/red_channel: add red_channel_disconnect, use in red_workerAlon Levy2011-03-023-15/+12
| | | | replace channel_release_res in red_worker with red_channel_disconnect.
* server/red_channel: reset send_data.item to NULL after releaseAlon Levy2011-03-021-0/+1
|
* server/red_worker: remove RedChannel argument from add_buf_from_infoAlon Levy2011-03-021-4/+4
| | | | It was unused.
* server/red_channel: add red_channel_{,no_}item_being_sentAlon Levy2011-03-023-7/+26
|
* server/red_worker: complete removal of send_data.marshaller useAlon Levy2011-03-021-23/+28
|
* server/red_worker: replace _send_ functions by _marshall_Alon Levy2011-03-021-111/+76
| | | | | | | | | | Changes in display channel for a code size win. A note about this and the previous cursor change: it will appear that we are now (with these changes) releasing resources too early. This is not so - send always has the option of blocking, which means after send you can not release resources anyway, that's what the release_item callback is for. So both the code before and now are doing the same accounting.
* server/red_channel: add red_channel_send_message_pendingAlon Levy2011-03-023-1/+9
|
* server/red_channel: add red_channel_all_blockedAlon Levy2011-03-023-5/+21
|
* server/red_worker: cursor channel: replace _send_ with _marshall_Alon Levy2011-03-021-31/+23
|
* server/red_channel (all): add red_channel_get_headerAlon Levy2011-03-022-0/+12
| | | | | This is useful during the channel specific channel_send_pipe_item_proc callback, it allows altering or reader the header being sent.
* server/red_channel: add red_channel_get_first_socketAlon Levy2011-03-023-4/+15
| | | | | | Use in main_channel. This is just for backward portability later when multiple clients are introduced - needs to be considered (which sockets do we want to export from libspiceserver?)
* server/red_channel (+): remove red_channel_add_bufAlon Levy2011-03-025-60/+55
|
* server/tunnel: pass SpiceMarshaller reference from sendAlon Levy2011-03-021-54/+37
| | | | | | | | Introduce SpiceMarshaller param to all send's that do add_buf Next patch will use marshaller in all functions that currently don't by replacing red_channel_add_buf with marshaller add_ref. Note - currently tunnel is broken due to wrong size in messages.
* server/red_channel (all): add red_channel_get_streamAlon Levy2011-03-025-7/+19
| | | | | use in config_socket, this makes the stream internal to the RedChannel implementation that will change later for multiple client support.
* server/common: introduce common/spice_common.hAlon Levy2011-03-021-45/+1
| | | | | | move all the ASSERT/PANIC/PANIC_ON/red_error/red_printf* macros to a common file to be used with ring.h that is going to be used externally (by spice-gtk).
* server/red_channel (all): handle MIGRATE_DATA and MIGRATE_FLUSH_DATAAlon Levy2011-03-027-52/+169
| | | | | | | | | | Handling done in red_channel instead of per channel, using call backs for the channel specific part. Intended to reduce furthur reliance of channels on RedChannel struct. The commit makes the code harder to understand because of the artificial get_serial stuff, should later be fixed by having a joint migration header with the serial (since all channels pass it).