2013-07-17 Uri Lublin Release 0.12.4 Update spice-common submodule (get spice-protocol 0.12.6) syntax-check: trailing whitespaces -- ignore binary files 2013-07-16 Uri Lublin syntax-check: remove trailing whitespaces Only whitespace changes in this commit. syntax-check: make sure config.h is the first included .h file syntax-check: use test A && test B instead of test A -a B syntax-check: fix no-newline or empty line at EOF syntax-check: s/the the/the/ in a comment syntax-check: update AUTHORS syntax-check: fix cast_of_argument_to_free In this case, make syntax-check is wrong, and we actually do need the cast. A cast is needed when types are uint64_t <--> pointer Using a local "ptr" variable makes both gcc and syntax-check happy. syntax-check: fix avoid_if_before_free server/tests: fix timer for test_empty_success server/tests: test_display_width_stride: add destroy command Otherwise, the test exits after the first iteration over all tests, on the second attempt to create an already created surface. server/tests: remove option from usage if AUTOMATED_TESTS is not configured server/tests: invalid-option: print the bad argument optind points to the next argument to parse. server/tests: fix produce_command for create surface Earlier in this function, test->target_surface is set to 1, which is the only allowed non-primary surface currently. If surface parameters are given (and specifically data is checked) they are being used, otherwise a default surface is used. Earlier in this function, "command" is set to a non-NULL value. Thus, the else part was unreachable code, which is fixed now. server/tests: test_display_base: set rect according to appropriate surface When surface_id == 0, primary is used. Otherwise (currently 1), secondary is used. Also, remove unused test_width and test_height. Since commit caea7699434c20dceef8fc79d21b8eeb663fbf53, test->width and test->height are used. red_channel: replace RING_FOREACH with RING_FOREACH_SAFE in some places This was originally intended to fix the problem fixed by commit 53488f0275d6c8a121af49f7ac817d09ce68090d. What is left are FOREACH loops that are at less risk and maybe safe (no read/write or disconnect/destroy are called from within them). red_worker: use a generic SAFE_FOREACH macro Introduce SAFE_FOREACH macro Make other safe iterators use SAFE_FOREACH red_worker: delete unused CCC_FOREACH red_worker: make DRAWABLE_FOREACH_DPI safe red_worker: use only DRAWABLE_FOREACH_GLZ_SAFE red_worker: make WORKER_FOREACH_DCC safe Specifically, the loop in red_pipes_add_draw can cause spice to abort. In red_worker.c (WORKER_FOREACH_DCC): red_pipes_add_drawable red_pipe_add_drawable red_handle_drawable_surfaces_client_synced red_push_surface_image red_channel_client_push red_channel_client_send red_peer_handle_outgoing reds_stream_writev (if fails -- EPIPE) handler->cb->on_error = red_channel_client_disconnect() red_channel_remove_client() ring_remove() -- of rcc from channel.clients ring. red_worker: reuse DCC_FOREACH in WORKER_DCC_FOREACH The only thing that is needed is to get the channel out of the worker. red_worker: use only RCC_FOREACH_SAFE RCC_FOREACH may be dangerous The following patches replace FOREACH loops with a SAFE version. Using unsafe loops may cause spice-server to abort (assert fails). Specifically a read/write fail in those loops, may cause the client to disconnect, removing the node currently iterated, which cause spice to abort in ring_next(): -- assertion `pos->next != NULL && pos->prev != NULL' failed 2013-07-05 David Gibson Use RING_FOREACH_SAFE in red_channel.c functions which are missing it Currently, both red_channel_pipes_add_type() and red_channel_pipes_add_empty_msg() use plaing RING_FOREACH() which is not safe versus removals from the ring within the loop body. Although it's rare, such a removal can occur in both cases. In the case of red_channel_pipes_add_type() we have: red_channel_pipes_add_type() -> red_channel_client_pipe_add_type() -> red_channel_client_push() And in the case of red_channel_client_pipes_add_empty_msg() we have: red_channel_client_pipes_add_empty_msg() -> red_channel_client_pipe_add_empty_msg() -> red_channel_client_push() But red_channel_client_push() can cause a removal from the clients ring if a network error occurs: red_channel_client_push() -> red_channel_client_send() -> red_peer_handle_outgoing() -> handler->cb->on_error callback = red_channel_client_default_peer_on_error() -> red_channel_client_disconnect() -> red_channel_remove_client() -> ring_remove() When this error path does occur, the assertion in RING_FOREACH()'s ring_next() trips, and the process containing the spice server is aborted. i.e. your whole VM dies, as a result of an unfortunately timed network error on the spice channel. Please apply. 2013-06-25 Yonit Halperin red_worker: fix for stuck display_channel over WAN (jpeg_enabled=true) The image descriptor flags shouldn't be copied as is from the flags that were set by the driver. Specifically, the CACHE_ME flag shouldn't be copied, since it is possible that (a) the image won't be cached (b) the image is already cached, but in its lossy version, and we may want to set the bit for CACHE_REPLACE_ME, in order to cache it in its lossless version. In case (b), the client first looks for the CACHE_ME flag, and only if it is not set it looks for CACHE_REPLACE_ME (see canvas_base.c). Since both flags where set, the client ignored REPLACE_ME, and didn't turned off the lossy flag of the cach item. Then, when a request from this lossles item reached the client (FROM_CACHE_LOSSLESS), the client display channel waited endlessly for the lossless version of the image. 2013-06-24 Yonit Halperin red_worker: improve stream stats readability and ease of parsing also added start/end-bit-rate and avg-quality to the final stream stats. mjpeg_encoder: add mjpeg_encoder_get_stats spice: silencing most of the ping/pong logging Those messages are too frequent and don't contribute much 2013-06-06 Hans de Goede server: Add support for filtering out agent file-xfer msgs (rhbz#961848) 2013-05-24 Yonit Halperin red_channel: replace an assert upon threads mismatch with a warning The assert: spice_assert(pthread_equal(pthread_self(), client->thread_id)) and the assert: spice_assert(pthread_equal(pthread_self(), rcc->channel->thread_id)) were coded in order to protect data that is accessed from the main context (red_client and most of the channels), from access by threads of other channels (namely, the display and cursor channels), and vice versa. However, some of the calls to the sound channel interface, and also the char_device interface, can be done from the vcpu thread. It doesn't endanger these channels internal data, since qemu use global mutex for the vcpu and io threads. Thus, pthread_self() can be != channel->thread_id, if one of them is the vcpu thread and the other is the io-thread, and we shouldn't assert. Future plans: A more complete and complicated solution would be to manage our own thread for spice-channels, and push input from qemu to this thread, instead of counting on the global mutex of qemu rhbz#823472 2013-05-23 Yonit Halperin main_channel: fix double release of migration target data If client_migrate_info was called once with cert-host-subject and then again without cert-host-subject, on a third call to client_migrate info, the cert-host-subject from the first call would have been freed for the second time. 2013-05-19 Christophe Fergeau Log actual address spice-server binds to It's not always obvious what address spice-server will bind to, in particular when the 'addr' parameter is omitted on QEMU commandline. The decision of what address to bind to is made in reds_init_socket with a call to getaddrinfo. Surprisingly, that function had a call to getnameinfo() already, but it does not seem to be using the result of that call in any way. This commit moves this call after the socket is successfully bound and add a log message to indicate which address it's bound to. 2013-05-17 Alon Levy 0.12.3 release server/red_parse_qxl: two coding convention pointer cast fix server/dispatchers: initialize stack to 0 for valgrind server/red_dispatcher: close pa hole in RedWorkerMessageDisplayConnect for valgrind server/tests: test_display_width_stride server/red_worker: simplify monitors_config update server/tests/test_display_base: add missing set_client_capabilities, fix client_monitors_config signature server/red_worker: turn critical (assert) non error into warning The situation causing this assert is unknown but it doesn't cause correctness issues with later rendering, and it is causing an abort. server/red_worker: s/driver_has_monitors_config/driver_cap_monitors_config/ (plus small comment) 2013-05-10 Yonit Halperin red_worker: don't get bit_rate from main_channel_client, if it wasn't initialized When setting an initial video stream bit rate, if the bit rate wasn't calculated by main_channel_client, and we don't have estimation from previos streams, use some default values. The patch also removes updating dcc->streams_max_bit_rate when the bit_rate held by the main_channel is larger than it. It is not necessary since we compare those 2 values each time we set the initial bit rate for a stream. 2013-05-08 Yonit Halperin reds: fix memory leak when core->base.minor_version < 3 reds: move handle_channel_event logic from main_dispatcher to reds main_dispactcher role is to pass events to the main thread. The logic that handles the event better not be inside main_dispatcher. red_worker: fail handle_migrate_data instead of aborting when there is an error during restoration of surfaces red_channel: notify and shutdown a channel client when its handle_migrate_data fails red_channel: add spice_channel_client_error spice_channel_client_error prints warning and shutdowns the channel_client that hit the error. This macro is useful for errors that are specific for one session and that are unrecoverable only with respect to this session. Prefer disconnecting a client over aborting when possible. red_worker: fix incorrect is_low_bandwidth after migrating a low bandwidth connection rhbz#956345 After a spice session has been migrated, we don't retest the network (user experience considerations). Instead, we obtain the is_low_bandwidth flag from the src-server, via the migration data. Before this patch, if we migrated from server s1 to s2 and then to s3, and if the connection to s1 was a low bandwidth one, we erroneously passed is_low_bandwidth=FALSE from s2 to s3. Cc: Marc-André Lureau red_worker: cleanup: add is_low_bandwidth flag to CommonChannelClient Replace the mixed calls to display_channel_client_is_low_bandwidth and to main_channel_client_is_low_bandwidth, with one flag in CommonChannelClient that is set upon channel creation. main_channel: add routine for checking if a network test had been conducted and completed 2013-05-05 Alon Levy red_worker: remove wrong TODO red_create_stream is called even without any client but there is no encoding since the mjpeg encoder is now associated with StreamAgent which is only created when we have a client. 2013-05-01 Yonit Halperin red_channel: on migration target, start sending ping messages only after the client's migration has completed The connection to the target server is established before migration starts. However, the client reads and replies to messages from the server only after migration completes. Thus, we better not send ping msgs from the target before migration completes (because the observed roundtrip duration will be bigger than the real one). red_channel: stop sending ping messages after migration has completed We mustn't send any msg to the client, besides MSG_MIGRATE_DATA, after we send MSG_MIGRATE. reds: fix not sending the mm-time after migration when there is no audio playback This bug results in the client dropping all the video frames after migration in case that (1) the hosts involved in migration have different mm-time; and that (2) there is no audio playback. This is relvant only for the client that was connected during the migration. rhbz#958276 2013-04-30 Yonit Halperin red_channel: fix not handling self pipe items in red_channel_client_release_item When a client disconnects, red_channel_client_pipe_clear is called. Releasing pipe items of type == MIGRATE||EMPTY_MSG||PING wasn't handled, and was passed to channel_cbs.release_item. There, an error occured since the pipe items were not recognized. 2013-04-24 Hans de Goede server: Add public spice_qxl_driver_unload method With a SPICE_DISPLAY_CAP_MONITORS_CONFIG capable client, the client needs to know what part of the primary to use for each monitor. If the guest driver does not support this, the server sends messages to the client for a single monitor spanning the entire primary. As soon as the guest calls spice_qxl_monitors_config_async once, we set the red_worker driver_has_monitors_config flag and stop doing this. This is a problem when the driver gets unloaded, for example after a reboot or when switching to a text vc with usermode mode-setting under Linux. To reproduce this start a multi-mon capable Linux guest which uses usermode mode-setting and then once X has started switch to a text vc. Note how the client window does not only not resize, if you try to resize it manually you always keep blackborders since the aspect is wrong. This patch is the spice-server side of fixing this, it adds a new spice_qxl_driver_unload method which clears the driver_has_monitors_config flag. The other patch needed to fix this is in qemu, and will calls this new method from qxl_enter_vga_mode. 2013-04-22 Yonit Halperin red_worker: assign mm_time to vga frames red_worker: increase the interval limit for stream frames collect and print video stream statistics server/red_worker: add an option to supply the bandwidth via env var SPICE_BIT_RATE can be set for supplying red_worker the available bandwidth (in Mbps). server/red_worker.c: use the bit rate of old streams as a start point for new streams mjpeg_encoder modify the initial bit we supply it, according to the client feedback. If it reaches a bit rate which is higher than the initial one, we use the higher bit rate as the new bit rate estimation. red_worker: video streams - adjust client playback latency reds: support mm_time latency adjustments When there is no audio playback, we set the mm_time in the client to be older than the one in the server by at least the requested latency (the delta is actually bigger, due to the network latency). When there is an audio playback, we adjust the mm_time in the client by adjusting the playback buffer using SPICE_MSG_PLAYBACK_LATENCY. snd_worker: support sending SPICE_MSG_PLAYBACK_LATENCY also update spice-common submodule dispatcher.h: fix - s/#define MAIN_DISPATCHER_H/#define DISPATCHER_H red_worker: ignoring video frame drops that are not due to pipe congestion A frame can be dropped if a new frame was added during the same call to red_process_command (we didn't attempt to send the older frame). Such drops are ignored. red_worker: notify mjpeg_encoder on server frame drops red_worker: support SPICE_MSGC_DISPLAY_STREAM_REPORT update mjpeg_encoder with reports from the client about the playback quality. The patch also updates the spice-common submodule. red_worker: start using mjpeg_encoder rate control capabilities This patch only employs setting the stream parameters based on the initial given bit-rate, the latency, and the encoding size. Later patches will also employ mjpeg_encoder response to client reports, and its control over frame drops. The patch also removes old stream bit rate calculations that weren't used. server/red_worker: enable latency monitoring in the display channel red_worker: stream - update periodically the input frame rate Periodically calculate the rate of frames arriving from the guest to the server. red_channel: monitor connection latency using MSG_PING server/red_worker: assign timer callbacks to worker_core, using spice_timer_queue display channel - supplying timeouts interface to red_channel, in order to allow periodic latency monitoring (see next patch). server: spice_timer_queue Each thread can create a spice_timer_queue, for managing its own timers. mjpeg_encoder: add stream warmup time, in which we avoid server and client drops The stream starts after lossless frames were sent to the client, and without rate control (except for pipe congestion). Thus, on the beginning of the stream, we might observe frame drops on the client and server side which are not necessarily related to mis-estimation of the bit rate, and we would like to wait till the stream stabilizes. mjpeg_encoder: keep the average observed fps similar to the defined fps The actual frames distribution does not necessarily fit the condition "at least one frame every (1000/rate_contorl->fps) milliseconds". For keeping the average frame rate close to the defined fps, we periodically measure the current average fps, and modify rate_control->adjusted_fps accordingly. Then, we use (1000/rate_control->adjusted_fps) as the interval between the frames. mjpeg_encoder: move the control over frame drops to mjpeg_encoder mjpeg_encoder: update the client with estimations for the required playback latency The required client playback latency is assessed based on the current estimation of the bit rate, the network latency, and the encoding size of the frames. When the playback delay that is reported by the client seems too small, or when the stream parameters change, we send the client an updated playback latency estimation. mjpeg_encoder: modify stream bit rate based on server side pipe congestion Downgrading stream bit rate when the input frame rate in the server exceeds the output frame rate, and frames are being dropped from the output pipe. mjpeg_encoder: adjust the stream bit rate based on periodic client feedback mjpeg_encoder can receive periodic reports about the playback status on the client side. Then, mjpeg_encoder analyses the report and can increase or decrease the stream bit rate, depending on the report. When the bit rate is changed, the quality and frame rate of the stream are re-evaluated. mjpeg_encoder: re-configure stream parameters when the frame's encoding size changes If the encoding size seems to get smaller/bigger, re-evaluate the stream quality and frame rate. mjpeg_encoder: configure mjpeg quality and frame rate according to a given bit rate Previously, the mjpeg quality was always 70. The frame rate was tuned according to the frames' congestion in the pipe. This patch sets the quality and frame rate according to a given bit rate and the size of the first encoded frames. The following patches will introduce an adaptive video streaming, in which the bit rate, the quality, and the frame rate, change in response to different parameters. Patches that make red_worker adopt this feature will also follow. server/red_worker: streams: moving mjpeg_encoder from Stream to StreamAgent The mjpeg_encoder should be client specific, and not shared between different clients**, for the following reasons: (1) Since we use abbreviated jpeg datastream for mjpeg, employing the same mjpeg_encoder for different clients might cause errors when the clients decode the jpeg data. (2) The next patch introduces bit rate control to the mjpeg_encoder. This feature depends on the bandwidth available, which is client specific. ** at least till we change multi-clients not to re-encode the same streams. red_worker: stream agent - fix miscounting of frames Frames counting was skipped when the previous frame was already sent completely to the client. 2013-04-19 Hans de Goede snd_worker: Make sure we never send an empty volume message My commit 71315b2e "snd_worker: Don't send empty audio-volume messages", fixes only one case of sending an empty volume message, if the client connects to a vm early during its boot sequence, while the snd hardware is being reset by the guest driver, qemu will call spice_server_playback_set_volume() with 0 channels from the reset handler. This patch also applies both fixes to the record channel. 2013-04-10 Hans de Goede spice-common: Update 2013-04-08 Yonit Halperin red_worker.c: fix not destroying streams before sending MSG_MIGRATE When qemu migration completes, we need to stop the streams, and to send the corresponding upgrade_items to the client. Otherwise, (1) the client might display lossy regions that we don't track (streams are not part of the migration data). (2) streams_timeout may occur after MSG_MIGRATE has been sent, leading to messages being sent to the client after MSG_MIGRATE and before MSG_MIGRATE_DATA (e.g., STREAM_CLIP, STREAM_DESTROY, DRAW_COPY). No message besides MSG_MIGRATE_DATA should be sent after MSG_MIGRATE. When a msg other than MIGRATE_DATA reached spice-gtk after MSG_MIGRATE, spice-gtk sent it to dest server as the migration data, and the dest server crashed with a "bad message size" assert. red_worker.c: s/red_display_destroy_streams/red_display_destroy_streams_agents In order not to confuse it with red_destroy_streams in the following patch. 2013-04-01 Hans de Goede snd_worker: Don't send empty audio-volume messages If no volume has been set it, we end up sending a volume message with audio-volume for 0 channels (iow an empty message). This is not useful and triggers the following warning in spice-gtk: (remote-viewer:8726): GSpice-WARNING **: set_sink_input_volume() failed: Invalid argument 2013-03-29 Hans de Goede char_device: Don't set active when stopped and don't access dev after unref 2 closely related changes in one: 1) When leaving the read or write loop because the chardev has been stopped active should not be updated. It has been set to FALSE by spice_char_device_stop and should stay FALSE 2) The updating of dev->active should be done *before* unref-ing dev char_device: Don't set the write-retry timer when not running The write-retry timer should not be set when we're leaving spice_char_device_write_to_device because the char-dev has been stopped. char_device: Properly update buffer status when leaving the write loop on stop Before this patch the write-loop in spice_char_device_write_to_device would break on running becoming 0, after having written some data, without updating the buffer status, causing the same data to be written *again* when started. 2013-03-15 Hans de Goede inputs-channel: Don't send insecure keyb notify to in migrate client This fixes spice-gtk printing message like these on migration: (remote-viewer:18402): GSpice-CRITICAL **: spice_channel_iterate_read: assertion `c->state != SPICE_CHANNEL_STATE_MIGRATING' failed inputs-channel: Handle printing of insecure keyboard notify This is clearly something which should be handled in the inputs_channel code, rather then having a special case for it in the generic channel handling code in reds.c. Moving it here also fixes the TODO we had on only sending this message to new clients. main-channel: Add a main_channel_client_push_notify function Sometimes we want to send a notify to a single client, rather then to all of them. main-channel: Make main_channel_push_notify deal with dynamic memory Currently main_channel_push_notify only gets passed a static string, but chances are in the future it may get passed dynamically allocated strings, prepare it for this. While at it also make clear that its argument is a string, and simplify things a bit by making use of this knowledge (pushing the strlen call down). 2013-03-07 Hans de Goede server/reds: Send the agent a CLIENT_DISCONNECTED msg on client disconnect Client -> agent messages can spawn multiple VDIChunks. When this happens the agent re-assembles the chunks into a complete VDAgentMessage before processing it. The server only guarentees coherency at the chunk level, so it is not possible for a partial chunk to get delivered to the agent. But it is possible for some chunks of a VDAgentMessage to be delivered to the agent followed by a client to disconnect without the rest of the VDAgentMessage being delivered! This will leave the agent in a wrong state, and the first messages send to it by the next client to connect will get seen as the rest of the VDAgentMessage from the previous client. This patch sends the agent a new VD_AGENT_CLIENT_DISCONNECTED message from the VDP_SERVER_PORT, on which the agent can then reset its VDP_CLIENT_PORT state. Note that no capability check is done for this, since the capabilities are something negotiated between client and agent. The server will simply always send this message on client disconnect, relying on older agents discarding the message since it has an unknown type (which both the windows and linux agents already do). char_device: Add spice_char_device_write_buffer_get_server_no_token() To allow the server to send agent messages without needing to wait for a self-token. IE for sending VD_AGENT_CLIENT_DISCONNECTED messages. Update spice-common 2013-03-04 Hans de Goede Silence __spice_char_device_write_buffer_get: internal buf is not available These messages are printed when the server tries to push a mouse event to the agent before the previous one has been flushed. This is a normal condition (which gets tracked by the reds->pending_mouse_event boolean), and as such it should *not* trigger the printing of error messages. I've seen these messages occasionally before, but with agent file-xfer they are trivial to trigger, simply send a large file to the agent and while it is transferring move the mouse over the client window. Note that due to the client tokens not allowing the client to completely saturate the agent channel mouse events do still get send to the agent, just with a slightly larger interval. So everything is working as designed and this spice_printerr is just leading to people chasing ghosts. 2013-01-15 Hans de Goede worker_update_monitors_config: Drop bogus real_count accounting 1) This does not buy us much, as red_marshall_monitors_config() also removes 0x0 sized monitors and does a much better job at it (also removing intermediate ones, not only tailing ones) 2) The code is wrong, as it allocs space for real_count heads, where real_count always <= monitors_config->count and then stores monitors_config->count in worker->monitors_config->count, causing red_marshall_monitors_config to potentially walk worker->monitors_config->heads past its boundaries. server: Fix SpiceWorker-CRITICAL **: red_worker.c:10968:red_push_monitors_config: condition `monitors_config != NULL' failed During my dynamic monitor support testing today, I hit the following assert in red_worker.c: "red_push_monitors_config: condition `monitors_config != NULL' failed" This is caused by the following scenario: 1) Guest causes handle_dev_monitors_config_async() to be called 2) handle_dev_monitors_config_async() calls worker_update_monitors_config() 3) handle_dev_monitors_config_async() pushes worker->monitors_config, this takes a ref on the current monitors_config 4) Guest causes handle_dev_monitors_config_async() to be called *again* 5) handle_dev_monitors_config_async() calls worker_update_monitors_config() 6) worker_update_monitors_config() does a decref on worker->monitors_config, releasing the workers reference, this monitor_config from step 2 is not yet free-ed though as the pipe-item still holds a ref 7) worker_update_monitors_config() creates a new monitors_config with an initial ref-count of 1 and stores that in worker->monitors_config 8) The pipe-item of the *first* monitors_config is send, upon completion a decref is done on the monitors_config, and monitors_config_decref not only frees the monitor_config, but *also* sets worker->monitors_config to NULL, even though worker->monitors_config no longer refers to the monitor_config being freed, it refers to the 2nd monitor_config! 9) The client which was connected when this all happened disconnects 10) A new client connects, leading to the assert: at red_worker.c:9519 num_common_caps=1, common_caps=0x5555569b6f60, migrate=0, stream=, client=, worker=) at red_worker.c:10423 at red_worker.c:11301 Note that red_worker.c:9519 is: red_push_monitors_config(dcc); gdb does not point to the actual line of the assert because the function gets inlined. The fix is easy and obvious, don't set worker->monitors_config to NULL in monitors_config_decref. I'm a bit baffled as to why that code is there in the first place, the whole point of ref-counting is to not have one single unique place to store the reference... This fix should not have any adverse side-effects as the 4 callers of monitors_config_decref fall into 2 categories: 1) Code which immediately after the decref replaces worker->monitors_config with a new monitors_config: worker_update_monitors_config() set_monitors_config_to_primary() 2) pipe-item freeing code, which should not touch the worker state at all to being with 2013-01-14 Michael Tokarev link libspice server with libm libpthread server/Makefile apparently forgot to link libspice-server with -lm -lpthread, but it uses symbols from these libraries directly. These libs are detected by configure and stored in $(SPICE_NONPKGCONFIG_LIBS) make variable, but this variable is never referenced at link time. Add it to server/Makefile.am, to libspice_server_la_LIBADD variable. Signed-off-By: Michael Tokarev 2013-01-08 Yonit Halperin red_worker.c: clearing the stream vis_region, after it has been detached The stream vis_region should be cleared after the stream region was sent to the client losslessly. Otherwise, we might send redundant stream upgrades if we process more drawables that are dependent on the stream region. red_worker.c: insert a drawable to its position in the current tree before calling red_detach_streams_behind resolves: rhbz#891326 Starting from commit 81fe00b08ad4f, red_detach_streams_behind can trigger modifications in the current tree (by update_area calls). Thus, after calling red_detach_streams_behind it is not safe to access tree entries that were calculated before the call. This patch inserts the drawable to the tree before the call to red_detach_streams_behind. This change also requires making sure that rendering operations that can be triggered by red_detach_streams_behind will not include this drawable (which is now part of the tree). 2013-01-01 Uri Lublin server: guest_set_client_capabilities: protect against NULL worker->display_channel Reported-by: Michal Luscon Found by a Coverity scan: in handle_dev_start - Checking "worker->display_channel" implies that "worker->display_channel" might be NULL. Passing "worker" to function "guest_set_client_capabilities" in guest_set_client_capabilities - Directly dereferencing parameter "worker->display_channel" 2012-12-20 Hans de Goede Release 0.12.2 2012-12-20 Yonit Halperin red_parse_qxl: fix throwing away drawables that have masks Non rgb bitmaps are allowed to not have a palette in case they are masks (which are 1BIT bitmaps). Related: rhbz#864982 2012-12-19 Hans de Goede spice-client: Add --hotkeys cmdline option To allow using the existing mechanism to override the default hotkeys from the cmdline. 2012-12-12 Christophe Fergeau reds: Use g_strlcpy instead of strncpy reds.c is using strncpy with a length one byte less than the destination buffer size, and is relying on the fact that the destination buffers are static global variables. Now that we depend on glib, we can use g_strlcpy instead, which avoids relying on such a subtle trick to get a nul-terminated string. build: Use glib2 Now that QEMU depends on glib, it won't really hurt if we depend on it as well, and we won't have to reinvent our own helpers. Don't build client by default It has been superseded by virt-viewer/remote-viewer Fail reds_init_socket when getaddrinfo fails We currently output a warning when getaddrinfo fails, but then we go on trying to use the information it couldn't read. Make sure we bail out of reds_init_socket if getaddrinfo fails. Make sure strncpy'ed string are 0-terminated spice_server_set_ticket and spice_server_set_addr get (library) user-provided strings as arguments, and copy them to fixed-size buffers using strncpy. However, if these strings are too long, the copied string will not be 0-terminated, which will cause issues later. This commit copies one byte less than the size of the destination buffer. In both cases, this buffer is a static global variable, so its memory will be set to 0. 2012-12-05 Yonit Halperin red_worker: revert 8855438a red_proccess_commands calls were added after calling guest_set_client_capabilities in order to cleanup the command ring from old commands that the client might not be able to handle. However, calling red_process_commands at this stage does send messages to the client. In addition, since setting the client capabilities at the guest is not synchronized, emptying the command ring is not enough in order to make sure the following commands will be supported by the client. The call to red_proccess_commands before initializing the display streams (the call to red_display_start_streams), caused inconsistencies related to video streaming upon reconnecting (rhbz#883564). I'm reverting this patch till another solution for the capabilities mismatch is introduced. Resolves: rhbz#883564 2012-12-05 Marc-André Lureau server: add "port" channel support A Spice port channel carry arbitrary data between the Spice client and the Spice server. It may be used to provide additional services on top of a Spice connection. For example, a channel can be associated with the qemu monitor for the client to interact with it, just like any qemu chardev. Or it may be used with various protocols, such as the Spice Controller. A port kind is identified simply by its fqdn, such as org.qemu.monitor, org.spice.spicy.test or org.ovirt.controller... The channel is based on Spicevmc which simply tunnels data between client and server, with a few additional messages. See the description of the channel protocol in spice-common history. server: bump SPICE_SERVER_VERSION to 0.12.2 update spice-common 2012-11-30 Yonit Halperin agent: fix mishandling of agent data received from the client after agent disconnection The server can receive from the client agent data even when the agent is disconnected. This can happen if the client sends the agent data before it receives the AGENT_DISCONNECTED msg. We should receive and handle such msgs, instead of disconnecting the client. This bug can also lead to a server crash if the agent gets reconnected fast enough, and it receives an agent data msg from the client before MSGC_AGENT_START. upstream bz#55726 rhbz#881980 2012-11-29 Yonit Halperin red_worker: no need to align the stride of internal images Internal images are just read from the surface, compressed, and sent to the client. Then, they are destroyed. I can't find any reason for aligning their memory. 2012-11-28 Yonit Halperin red_worker: fix sending internal images with stride > bpp*width to lz compression rhbz#876685 The current lz implementation does not support such bitmaps. The following patch will actually prevent allocating stride > bpp*width for internal images. 2012-11-26 Yonit Halperin red_worker.c: fix memory corruption when data from client is bigger than 1024 bytes Previously, there was no check for the size of the message received from the client, and all messages were read into a buffer of size 1024. However, migration data can be bigger than 1024. In such cases, memory corruption occurred. red_worker.c: fix not sending all pending messages when the device is stopped red_wait_outgoing_item only waits till the currently outgoing msg is completely sent. red_wait_outgoing_items does the same for multi-clients. handle_dev_stop erroneously called red_wait_outgoing_items, instead of waiting till all the items in the pipes are sent. This waiting is necessary because after drawables are sent to the client, we release them from the device. The device might have been stopped due to moving to the non-live phase of migration. Accessing the device memory during this phase can lead to inconsistencies. Also, MSG_MIGRATE should be the last message sent to the client, before MSG_MIGRATE_DATA. Due to this bug, msgs were marshalled and sent after handle_dev_stop and after handle_dev_display_migrate which sometimes led to the release of surfaces, and inserting MSG_DISPLAY_DESTROY_SURFACE after MSG_MIGRATE. This patch also removes the calls to red_wait_outgoing_items, from dev_flush_surfaces. They were unnecessary. smartcard.c: avoid marshalling migration data with reference to a memory that might be released before send has completed The current solution just copy the buffer. Currently data that is read from the guest is always copied before sending it to the client. When we will have ref count for these buffers, we can also use it for marshalling the migration data. red_worker.c: fix marshalling of migration data fix calling spice_marhsaller_add_ref with memory on stack reds.c: fix calls to spice_marshaller_add_ref with ptr to memory that might be released before sending char_device.c: when the state is destroyed, also free the buffer that is being written to the device char_device.c: add ref count for write-to-device buffers The ref count is used in order to keep buffers that were in the write queue and now are part of migration data, in case the char_device state is destroyed before we complete sending the migration data. 2012-11-21 Yonit Halperin char_device.c: fix call to spice_marshaller_add_ref with memory on stack rhbz#862352 2012-11-12 Yonit Halperin red_worker.c: fix calling set_client_capabilities when it is unsupported by qemu The erroneous call was in handle_dev_start. This patch also fixes not calling set_client_capabilities when the qxl major_version is > 3. display seamless migration: no need to trace the generation of the primary surface We no longer process destroy_primary or destroy_surfaces while waiting for migration data. display seamless migration: don't process both cmd ring and dispatcher queue till migration data is received fix: rhbz#866929 At migration destination side, we need to restore the client's surfaces state, before sending surfaces related messages. Before this patch, we stopped the processing of only the cmd ring, till migration data arrived. However, some QXL_IOs require reading and rendering the cmd ring (e.g., update_area). Moreover, when the device is reset, after destroying all surfaces, we assert (in qemu) if the cmd ring is not empty (see rhbz#866929). This fix makes the red_worker thread wait till the migration data arrives (or till a timeout), and not process any input from the device after the vm is started. 2012-11-04 Alon Levy Revert "server: add websockets support via libwebsockets" This reverts commit 63bb37276e028ab1b1c156c9e7907bf22b6d5952. update spice-common (was broken) 2012-11-01 Alon Levy server/red_worker: don't call set_client_capabilities if vm is stopped We try to inject an interrupt to the vm in this case, which we cannot do if it is stopped. Instead log this and update when vm restarts. RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=870972 (that bz is on qemu, it will be cloned or just changed, not sure yet) 2012-10-25 Alon Levy server/red_worker: wip: VALIDATE_SURFACE macros, remove asserts (but too late - should be done earlier) release 0.12.1 server: add websockets support via libwebsockets New API: spice_server_set_ws_ports This adds an optional dependency on libwebsockets. You need to get my patched 0.0.3 version here: git://people.freedesktop.org/~alon/libwebsockets There is no qemu patches yet, to test change in reds.c the default value of spice_ws_port to 5959 (for the default of spice-html5). For testing there is an online client at http://spice-space.org/spice-html5/spice.html Known issues: 1. The tester (server/tests/test_display_no_ssl) gets into dropping all data after a few seconds, I think it's an issue with the implemented watches, but haven't figured it out. 2. libwebsocket's read interface is inverted to what our code expects, i.e. there is no libwebsocket_read, so there is an additional copy involved (see RedsWebSocket). This can be fixed. 3. Listening on a separate port. Since the headers are different, we could listen on the same port (first three bytes RED/GET). I don't know if we want to? Todos: 1. SSL not implemented yet. Needs some thought as to how. 2. Serve spice-html5 when accessed as a http server. Nice to have. server/red_worker: stride > 0 is tested, remove abort Tested using the wip driver and xf86-video-modesetting. server/tests/test_display_base: fix segfault in test server/reds.c: split off reds-private.h configure.ac: add libcacard to SPICE_REQUIRES if built with smartcard support update spice-common 2012-10-24 Uri Lublin server: red_dispatcher: check major/minor of qxl for client_monitors_config This solves a problem with new spice-server and old qemu-kvm, where spice thinks qif->client_monitors_config exists, while it does not exist in qemu-kvm. Also "major > required_major" was added to the condition. Also only the specific RedDispatcher is checked (and not all dispatchers). 2012-10-19 Alon Levy add git-version-gen and gitlog-to-changelog 2012-10-18 Hans de Goede inputs_channel: Fix wrong handling of key up/down on big endian The client will send 0x000000## codes for regular keys, and 0x0000##e0 codes for extended keys. The current code which simply walks the uint32_t code in memory order relies on the memory order being little endian, which will clearly fail on big endian machines, this fixes this. 2012-10-11 Yonit Halperin snd channel: fix accessing freed memory snd_channel_put freed "channel", and then channel->worker was accessed. It caused segmentation faults during connections and disconnections of the client. 2012-10-01 Christophe Fergeau Fix PlaybackChannel forward declaration This caused a jenkins build failure: snd_worker.c:148: error: redefinition of typedef 'PlaybackChannel' snd_worker.c:126: note: previous declaration of 'PlaybackChannel' was here 2012-10-01 Andrew Eikum server: Access the correct SndChannel for a given AudioFrame The client of _get_buffer() holds a ref to the SndChannel, and we should access that SndChannel when _put_samples() is called, not the one that happens to currently be attached to the Interface. server: Don't release SndChannel twice from worker reference When we release the SndChannel reference during snd_disconnect_channel(), we need to set the pointer to NULL so it doesn't get released again on client reconnect during snd_set_playback_peer(). This can happen when a reference is held from _playback_get_buffer(). 2012-09-20 Christophe Fergeau reds: Report an error when reds_char_device_add_state fails This used to abort with spice_error. The caller currently does not check spice_server_char_device_add_interface return value, but it's still cleaner to report an error in this case. reds: Check errors returned from SSL_CTX_set_cipher_list reds: Report errors from load_dh_params reds: Check reds_init_ssl errors Now that this function can fail, propagate any error up to the caller. This allows qemu to fail when an SSL initialization error occurred. reds: report SSL initialization errors Errors occurring in reds_init_ssl used to be fatal through the use of spice_error, but this was downgraded to non-fatal spice_warning calls recently. This means we no longer error out when invalid SSL (certificates, ...) parameters are passed by the user. This commit changes reds_init_ssl return value from void to int so that errors can be reported to the caller. reds_init_net: report errors on watch setup failures We used to be aborting in such situations, but this was changed during the big spice_error/printerr cleanup. We are currently outputting a warning but not reporting the error with the caller when reds_init_net fails to register listening watches with the mainloop. As it's unlikely that things will work as expected in such cases, better to error out of the function instead of pretending everything is all right. reds: Abort on BN-new failures BN_new returns NULL on allocation failures. Given that we abort on malloc allocation failures, we should also abort here. The current code will segfault when BN_new fails as it immediatly tries to use the NULL pointer. 2012-09-15 Alon Levy Release 0.12.0 2012-09-13 Alon Levy server/spice-server.syms: add missing global labels Although global is the default, this makes the file more consistent. server/Makefile.am: fix for make distcheck Doesn't make sense to distribute test_spice_version.sh, so just ensure the build passes if it doesn't exist. spice-server 0.11.5 Added api: QXL interface (3.2) client_monitors_config server/tests: agent mock, client_monitors_config server: Filter VD_AGENT_MONITORS_CONFIG If the guest supports client monitors config we pass it the VDAgentMonitorsConfig message via the QXLInterface::client_monitors_config api instead of via the vdagent. server/reds: reuse already defined local server/red_dispatcher: client_monitors_config support Adds two functions: - red_dispatcher_use_client_monitors_config: check that QXLInterface supports client_monitors_config and that it's functional. - red_dispatcher_client_monitors_config: send the client monitors configuration to the guest. server: add QXLInterface::client_monitors_config Used to implement guest monitor configuration change similarly to real hardware in conjunction with the new qemu interrupt QXL_INTERRUPT_CLIENT_MONITORS_CONFIG. client_monitors_config is also used to probe the support by the interface. If it is not supported we send the message to the guest agent. This makes a linux qxl driver similar to existing kms drivers. The logic is: For every received VDAgentMonitorsConfig: if client_monitors_config(NULL): write client configuration to pci rom BAR. send interrupt to guest guest kernel reads configuration from rom BAR. guest kernel issues event to user space user space reads (libdrm) and reconfigures (libXRandr) else: (current implementation) write message to guest agent guest agent issues reconfiguration via XRandr / windows Escape ioctl to kernel update spice-common module For qxl client_monitors_config support. 2012-09-12 Alon Levy server/red_dispatcher: change a printerr to debug 2012-09-11 Søren Sandmann Pedersen Bump SPICE_INTERFACE_QXL_VERSION_MINOR Then check that we have the right version before accessing the set_client_capabilities() function. 2012-09-11 Peter Robinson Enable build on armv6+ The following patch enables it to build on ARM platforms that support atomics. Tested on an armv7hl on an ARMv7 device running Fedora 18. Using firefox connecting to a RHEV-M instance I could launch consoles in spice-xpi and login so basic support works! Resolves: rhbz#613529 2012-09-10 Christophe Fergeau Update spice-common to get A8 surface definitions Latest spice needs these definitions from spice-protocol 2012-09-07 Søren Sandmann Pedersen Bump spice.h version number to 0.11.4 No new symbols are added, but there is an addition to QXLInterface: void (*set_client_capabilities)(QXLInstance *qin, uint8_t client_present, uint8_t caps[58]); Set a8 capability in the QXL device if supported by the client Process outstanding commands in the ring after changing capability bits When a new client connects, there may be commands in the ring that it can't understand, so we need to process these before forwarding new commands to the client. By doing this after changing the capability bits we ensure that the new client will never see a command that it doesn't understand (under the assumption that the guest will read and obey the capability bits). Acked-by: Alon Levy 2012-09-06 Søren Sandmann Pedersen Add new set_client_capabilities() interface to QXLInstance A new interface set_client_capabilities (QXLInstance *qin, uint8_t client_present, uint8_t caps[58]); is added to QXLInstance, and spice server is changed to call it whenever a client connects or disconnects. The QXL device in response is expected to update the client capability bits in the ROM of the device and raise the QXL_INTERRUPT_CLIENT interrupt. There is a potential race condition in the case where a client disconnects and a new client with fewer capabilities connects. There may be commands in the ring that the new client can't handle. This case is handled by first changing the capability bits, then processing all commands in the ring, and then start forwarding commands to the new client. As long as the guest obeys the capability bits, the new client will never see anything it doesn't understand. client: Advertise A8_SURFACE capability 2012-09-05 Alon Levy server/red_parse_qxl: fix bitmap_consistent again 2012-09-05 Jeremy White Implement spice_server_set_exit_on_disconnect to enable an option whereby the spice server shuts down on client disconnect. 2012-09-05 Alon Levy server/red_parse_qxl: fix wrong bitmap_consistent The bit calculation was wrong for all the paletted types by a factor of between 8 and 1 (SPICE_BITMAP_FMT_{1,4,8}BIT_PLT_{LE,BE}) 2012-09-03 Alon Levy server/red_parse_qxl: add bitmap consistency check Just checks stride vs width times bpp. This fixes a potential abort on guest generated bad images in glz_encoder. Other files touched to move some consts to red_common, they are static so no problem to be defined in both red_worker.c and red_parse_qxl.c . server/tests/test_display_base: fix update_area abort Don't do zero area update_areas, server now aborts on those. This tester is not supposed to test those aborts. server: replace syntax-check reported tabs with spaces server: add dist-hook to prevent spice version configure/spice.h difference 2012-09-02 Alon Levy 0.11.3 release No new api entries. add server/tests/test_vdagent server/tests/test_two_servers server/tests: introduce Test struct 2012-08-30 Alon Levy server/red_worker: seamless: fix invalid memory reference replace add_ref with add for stack allocated SpiceMigrateDataDisplay. This fixes wrong MIGRATE_DATA message in display channel (symptom is glz_encoder_max being way too big, and malloc failure at target) seen on F18 with gcc-4.7.1-5.fc18.x86_64 and glibc-2.16-8.fc18.x86_64 (didn't appear on RHEL 6). server: freezed->froze, missing whitespace after declarations server: s/max_encdoers/max_encoders/ 2012-08-30 Yonit Halperin server/inputs_channel.c: whitespace fix 2012-08-30 Alon Levy server/red_tunnel_worker: remove unneeded expect_migrate_mark 2012-08-28 Alon Levy server/red_tunnel_worker.c: fix build Only passes compile, not tested. 2012-08-27 Marc-André Lureau inputs: handle SPICE_MSGC_INPUTS_KEY_SCANCODE Handle SPICE_MSGC_INPUTS_KEY_SCANCODE message, allowing arbitrary keyboard scancode sequence. 2012-08-27 Alon Levy support automake >= 1.12 Requires a single line (sans comments) change to configure.ac in spice-common too, to define the new AM_PROG_AR. server/red_worker: handle_dev_update_area: fail if invalid area 2012-08-27 Yann E. MORIN client: fix missing stdarg.h include When the C library is uClibc, stdarg.h is required to get the definition for va_list et al. 2012-08-27 Yonit Halperin enable seamless migration and set migration protocol version inputs channel migration: don't send any msg after MSG_MIGRATE Pending motion acks, and keyboard modifiers messages will be sent by the destination after receiving the migration data. inputs_channel: send and handle migration data migration_protocol: add inputs channel migration data Storing the motion count in uint16_t and not in uint32_t since the exact count is not important, just its division in SPICE_INPUT_MOTION_ACK_BUNCH (see the next 2 patches). main_channel: don't expect init msg in a seamless migration destination If the server is a destination of seamless migration, send msgs to the client, even though an init msg has not been sent to the client. red_channel: set send_data.last_sent_serial in red_channel_client_set_message_serial red_channel_client_set_message_serial is called for setting the serial of the display channel messages after migration (on the destination side). The serial is retrieved from the migration data. red_channel: remove unused migrate flag from RedChannel The relevant flags reside in RedChannelClient and RedClient snd_worker: handling migration The playback and record channel send SPICE_MSG_MIGRATE to the client. Both playback and record channel does not have a state to restore: while in the legacy migration implementation the record channel used to restore the mode and start time, it looks unnecessary since the client receives from the src MSG_RECORD_STOP before the migration completion notification (when the vm is stopped). Afterwards, when the vm starts on the dest side, the client receives MSG_RECORD_START. snd_channel: fix double release Due to the fix in the previous patch, snd_disconnect_channel can be called both when there is write/read error in the channel, or from red_client_destroy (which calls client_cbs.disconnect). Multiple calls to snd_disconnect_channel resulted in calling channel->cleanup(channel) more than once (double release). red_channel (dummy): fix not adding dummy RedChannelClient to the client snd channel wasn't added to be part of the client's channels list. As a result, when the client was destroyed, or migrated, snd channel client wasn't destroy, or its migration callback wasn't called. However, due to adding dummy channels to the client, we need special handling for calls to disconnecting dummy channel clients. TODO: we need to refactor snd_worker to use red_channel display migration: restore destination state Restoring display channel from migration data. Not notifying client about changes that are artifacts of loading the vm. Remove legacy migration code. display migration: marshall migration data display & cursor migration: send SPICE_MSG_MIGRATE migration_protocol: add display channel migration data inputs channel: use the default red_channel behaviour for client_cbs.migrate The default callback sends SPICE_MSG_MIGRATE to the client. inputs channel: fix using spice messages enums as pipe items type A channel pipe item type must start from PIPE_ITEM_TYPE_CHANNEL_BASE. SPICE_MSG_MIGRATE value eq. PIPE_ITEM_TYPE_SET_ACK. Setting a pipe item type to SPICE_MSG_MIGRATE, leads to red_channel handling PIPE_ITEM_TYPE_SET_ACK. char_device: don't connect a migrated client if the state of the device might have changed since it was created If reading/writing from the device have occured before migration data has arrived, the migration data might no longer be relvant, and we disconnect the client. main: restore state from migration data Also removed old migration leftovers. main: send migration data Also removed some unused definitions from reds that used to belong to old agent and migration code. main: send MSG_MIGRATE upon vm migration completion Before sending the above msg, if there is a pending partial msg that has been read from the agent, we send it to the client. The alternative was to keep the msg as part of the migration data, and then to send it to the destination server via the client and to wait there for the msg chunk completion, before sending it to the client. Of course, the latter is less efficient. reds: s/HADER/HEADER migration_protocol: add migration data for the main channel (mainly for the agent) main_channel: fix using spice messages enums as pipe items type A channel pipe item type must start from PIPE_ITEM_TYPE_CHANNEL_BASE. SPICE_MSG_MIGRATE value eq. PIPE_ITEM_TYPE_SET_ACK. Setting a pipe item type to SPICE_MSG_MIGRATE, leads to red_channel handling PIPE_ITEM_TYPE_SET_ACK. Also removed sending SPICE_MSG_MIGRATE. It will be handled in the next patch. red_channel: introduce PIPE_ITEM_TYPE_EMPTY_MSG The pipe item is used for sending messages that don't have body. smartcard: restore state after migration from migration data smartcard migration: send migration data migration_protocol: add migration data for smartcard smartcard: send MSG_MIGRATE upon vm migration completion The above is the default behaviour for red_channel_client, if client_cbs.migrate is not registered as part of red_channel_register_client_cbs smartcard: fix PIPE_ITEMs enum indexing The enum should start from PIPE_ITEM_TYPE_CHANNEL_BASE, otherwise, PIPE_ITEM_TYPE_ERROR is handled like PIPE_ITEM_TYPE_SET_ACK. smartcard: change the timing of attaching a client to SpiceCharDeviceState Attach/detach a client to a SpiceCharDeviceState upon its connection/disconnection, instead of upon reader_add/remove messages. When the client is removed from a SpiceCharDeviceState, all the messages from this client are removed from the device write queue. This shouldn't happen when we only receive reader_remove and the client is still connected. spicevmc migration: restore migration dest state from migration data spicevmc migration: send migration data spicevmc: send MSG_MIGRATE upon vm migration completion The above is the default behaviour for red_channel_client, if client_cbs.migrate is not registered as part of red_channel_register_client_cbs migration_protocol: add migration data for spicevmc char device migration: restore state at destination from migration data char device migration: don't read or write from/to the device while waiting for migraion data char device migration: marshall migration data char_device: variable token price for write buffers When restoring migration data, we also restore data that is addressed to the device, and that might have been originated from more than 1 message. When the write buffer that is assoicated with this data is released, we need to free all the relevant tokens. migration_protocol: add migration data for char devices replace some migration related spice_error calls with info/warning seamless migration: migration completion on the destination side Tracking the channels that wait for migration data. If there is a new migration process pending, when all the channels have restored their state, we begin the new migration. red_channel: handle sending SPICE_MSG_MIGRATE The relevant code is common to all channels. The patch also contains a fix to the return value for handle_migrate_data callback: s/uint64_t/int red_channel: fix pipe item leak seamleass migration: manage post migration phase in the src side In semi-seamless, SPICE_MSG_MAIN_MIGRATE_END is sent. In seamless, each channel migrates separately. The src waits till all the clients are disconnected (or a timeout), and then it notifies qemu that spice migration has completed. The patch doesn't include the per-channel logic for seamless migration (sending MSG_MIGRATE, MIGRATE_DATA, etc.). seamless migration: pre migration phase on the destination side - handle SPICE_MSGC_MAIN_MIGRATE_DST_DO_SEAMLESS - reply with SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_ACK/NACK - prepare the channels for migration according to the migration type (semi/seamless) see spice-protocol for more details: commit 3838ad140a046c4ddf42fef58c9727ecfdc09f9f seamless migration: pre migration phase on the src side sending SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS and handling SPICE_MSGC_MAIN_MIGRATE_CONNECTED_SEAMLESS The src side signals the client to establish a connection to the destination. In seamless migration, the client is also used to perform a sort of handshake with the destination, for verifying if seamless migration can be supported. see spice-protocol for more details: commit 3838ad140a046c4ddf42fef58c9727ecfdc09f9f seamless-migration: update spice-common submodule Also Update server and client according to the change of SpiceMsgMainMigrationBegin: it now holds all the fields inside SpiceMigrationDstInfo. seamless-migration: add migration_protocol.h The file will hold the declarations of the different migration data messages (depending on the channel), that will be passed from the src server to the dst server, via the client, using SPICE_MSG_MIGRATE_DATA. bump version to 0.11.2 New api entries: spice_server_vm_start spice_server_vm_stop spice_server_set_seamless_migration spice.h: add spice_server_set_seamless_migration This new call is used in order to identify whether qemu, or the management (e.g. libvirt), support seamless migration. If it is supported, qemu spice cmd-line configuration should have seamless-migration=on. In addition, we disable seamless migration support if multiple clients are allowed. Currently, only one client is supported. spice_server_vm_start/stop: notify red_dispatcher on vm start/stop Till now, red_worker was notfied about vm status changes via QXLWorker->start/stop (or spice_qxl_start/stop). Newer qemu, that supports calling spice_server_vm_start/stop, will call only these routines, and won't call QXLWorker->start/stop. spice.h: add entries for tracking vm state When vm state changes (started/stopped), we notify all the attached SpiceCharDeviceStates about the change. This is mainly required for avoiding writing/reading to/from the device during the non-live stage of migration. spice version will be bumped in one of the following patches. reds: add tracking for char devices The list of attached char_devices will be used in the next patch for notifying each instance of SpiceCharDeviceState when the vm is started or stopped. agent: don't attempt to read from the device if it was released if vdi_port_read_buf_process failes, we detach the agent and also release the read buffer. We shouldn't try reading from the device afterwards. agent: reset client tokens when notifying on agent connection send SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS red_channel: add red_channel_test_remote_cap for checking if all the channel clients connected support the cap 2012-08-24 Søren Sandmann Pedersen Add support for Composite command to the client All the real work is being done in spice-common, so this patch is just hooking up the virtual calls and adding the SPICE_DISPLAY_CAP_COMPOSITE capability. Add support for QXLComposite to spice server In red-parse-qxl.c add support for parsing QXLComposite into SpiceComposite. In red-worker.c add support for marshalling SpiceComposite onto the wire. Add support for LZ compression of A8 images Graduality is irrelevant for A8 images, so instead of using RGB-ness as a short-cut, add a new macro BITMAP_FMT_HAS_GRADUALITY() that returns true for the existing RGB images, but false for A8. 2012-08-09 Marc-André Lureau Update spice-common 2012-07-25 Yonit Halperin red_worker: Fix reference counting for the current frame (drawable) of a stream After marshalling MSG_STREAM_CREATE, there is no need to ref and unref stream->current before and after completing the sending of the message (correspondingly). The referencing is unnecessary because all the data that is required from the drawable (the clipping), is copied during marshalling, and no field in the drawable is referenced (see spice_marshall_msg_display_stream_create). Moreover, the referencing was bugous: While display_channel_hold_pipe_item and display_channel_client_release_item_after_push referenced and dereferenced, correspondingly, stream->current, stream->current might have changed in between these calls, and then we ended up with one drawable leaking, and one drawable released before its time has come (which of course led to critical errors). 2012-07-23 Alon Levy bump version to 0.11.1 for new spice_qxl_monitors_config_async bump current and age since only additions where done. new server library is libspice-server.so.1.2.0 . 2012-07-22 Alon Levy server: add monitors_config support a SpiceMsgDisplayMonitorsConfig is sent on two occasions: * as a result of a spice_qxl_monitors_config_async * whenever a client connects and there is a previously set monitors config Sending the new message is protected by a new cap, SPICE_DISPLAY_CAP_MONITORS_CONFIG More elaborately: spice_qxl_monitors_config_async receives a QXLPHYSICAL address of a QXLMonitorsConfig struct and reads it, caching it in the RedWorker, and sending it to all clients. Whenever a new client connects it receives a SpiceMsgDisplayMonitorsConfig message as well. server/red_parse_qxl: red_get_image: fix leaks on bad image server/red_worker: release bad drawables server/red_parse_qxl: disallow zero area bitmaps prevents division by zero later (SIGFPE, Arithmetic exception) in spice-common code, at spice-common/common/canvas_base.c:646 for both client and server (server only upon rendering). server/red_parse_qxl: get_path: remove return NULL introduced by 2ec2dbc78a660ee4e3315f50c881d9e31a8e4fe2 server/reds: more fixes for wrong spice_error in d2c99b59 server: don't abort on guest images with missing palettes server: factor out bitmap_fmt_is_rgb 2012-07-16 Marc-André Lureau Update spice-common tests: add missing file to .gitignore TODO: some day, switch to git.mk build-sys: remove cegui/slirp and mandatory client from dist-check The spicec client is no longer actively maintained. By removing cegui from distcheck, we can avoid extra build time and dependencies (>150Mb extra cegui/boost on fedora) Slirp is not available in most distributions, afaict, making it hard to build consistantly accross various systems. The client is still build if the dependencies are present. build-sys: define GL flags if enabled The server too can use opengl, independently from client. 2012-07-11 Alon Levy server/reds: fix wrong spice_error in d2c99b59 server/red_worker: fix wrong spice_error in commit 706232a8 2012-07-05 Alon Levy server/reds.c: spice_printerr cleanup Rules for replacing spice_printerr: * if it's a client drop / agent drop, spice_error * if it's important, spice_warning * else, spice_info. The fourth rule is spice_debug if it's going to fill up the log, but nothing of the sort here. Other things this patch does: * changed reds_show_new_channel to reds_info_new_channel in an attempt to advertise it doesn't always show anything, unless SPICE_DEBUG_LOG_LEVEL >= SPICE_DEVUG_LOG_INFO (==3) * removes two lines of whitespace. * added "crashy" to multiple client warning (only warning introduced, the rest are errors). server/red_worker: elevate some spice_debugs to spice_info Specifically all those that the previous patch converted to spice_debug. spice_debug contains very verbose stuff like update_area that drowns out those relatively rare (client connect / disconnect generated) messages. update spice-common for spice_info server/red_worker: cleanup lines starting with 5 spaces server/red_worker: death to spice_printerr, too verbose by far Replaced mostly with spice_debug, but spice_warning & spice_error as well where appropriate. 2012-07-04 Yonit Halperin smartcard: Remove redefinition of typedef 'SmartCardDeviceState' 2012-07-03 Yonit Halperin char_device.h: Remove redefinition of typedef 'SpiceCharDeviceState' The original definition is in spice.h char_device: move SpiceCharDeviceState from the header In addition, I also removed the no longer used wakeup callback smartcard: use SpiceCharDeviceState for writing to the guest device With SpiceCharDeviceState, the smartcard code now supports partial writes, and storing data that is received from the client after the device is stopped, instead of attempting to write it to the guest. smartcard: creating SmartCardChannelClient type The lifetime of the channel is not necessarily correlated to the life time of the device. In the next patch, we need to keep a reference to SpiceCharDeviceWriteBuffer, which might be in use even if the SpiceCharDeviceState is destroyed, but the channel is still connected. The next patch keeps this reference inside SmartCardChannelClient. This patch also removes the routine smartcard_readers_detach_all(rcc), which is unnecessary since we don't support multiple readers; even when we do support them, each channel client should be associated with only one reader (i.e., we will have different channels for different readers). smartcard: use SpiceCharDeviceState for managing reading from the device This patch and the following one do not introduce tokening to the smartcard channel. But this can be done easily later, by setting the appropriate variables in SpiceCharDeviceState (after adding the appropriate protocol messages, and implementing this in the client side). spicevmc: use SpiceCharDeviceState for writing to the guest device With SpiceCharDeviceState, spicevmc now supports partial writes, and storing data that is received from the client after the device is stopped, instead of attempting to write it to the guest. spicevmc: employ SpiceCharDeviceState for managing reading from the guest device This patch and the following one do not introduce tokening to the spicevmc channel. But this can be done easily later, by setting the appropriate variables in SpiceCharDeviceState (after adding the appropriate protocol messages, and implementing this in the client side). agent: employ SpiceCharDeviceState for writing to the device agent: use SpiceCharDeviceWriteBuffer for agent data from the client This is an intermediate patch. The next patch will actually push the buffer to the device, instead of copying it. agent: employ SpiceCharDeviceState for managing reading from the device agent: remove save/restore migration data code This code is never called, it was relevant for seamless migration. Most of the data that needs to be migrated was moved to SpiceCharDeviceState. When we implement seamless migration, we will have routines in char_device.c for migrating the relevant data. agent: Fix tokens handling in main_channel - Allow sending tokens to a specific client. - Do not ignore tokens that are sent from the client to the server. The tokens support for multiple clients and for server side tokens is still broken in reds. It will be fixed in following patches, when the server-side agent code will use the SpiceCharDeviceState api. Notice that ignoring the server-side tokens didn't introduce a problem since both the client and the server set it to ~0. char_device: Introducing shared flow control code for char devices. SpiceCharDeviceState manages the (1) write-to-device queue (2) wakeup and reading from the device (3) client tokens (4) sending messages from the device to the client/s, considering the available tokens. SpiceCharDeviceState can be also stopped and started. When the device is stopped, no reading or writing is done from/to the device. Messages addressed from the client to the device are being queued. Later, an api for stop/start will be added to spice.h and it should be called from qemu. This patch does not yet remove the wakeup callback from SpiceCharDeviceState, but once all the char devices (agent/spicevmc/smartcard) code will switch to the new implementation, SpiceCharDeviceState will be moved to the c file and its reference to the wakeup callback will be removed. smartcard: fix an error message smartcard: fix calc of remaining data size when reading more than one msg from the device 2012-07-02 Alon Levy update spice-common Includes using the same spice.proto as spice-gtk now, with smartcard fixes, more verbose output when SSL verification fails, and some warnings fixes. shortlog: Alon Levy (6): python_modules/ptypes.py/EnumBaseType.c_enumname: add missing return to fix broken enums generation smartcard: build fixes for spice server updated spice-protocol for smartcard enums non conflict with libcacard Makefile.am: fix .gitignore not being generated in spice-protocol/spice Makefile.am: now that spice_codegen.py is used add *.pyc to ignored files in root update spice-protocol for smartcard enums fix Christophe Fergeau (1): ssl: more verbose output when SSL verification fails Marc-André Lureau (3): ssl-verify: add a bit of run-time checks Fix invalid macro usage Fix a gcc warning 2012-06-27 Alon Levy spice.h: bump SPICE_SERVER_VERSION for release 0.11.0 (cherry picked from commit dd5c995c32cf595d31e59975bd1b3216cf996656) Revert "update spice-common for multiple monitor in single display channel support" This reverts commit 3baf290be79cfb1872b90f7724efa50aa343d74b. Revert "spice.h: bump SPICE_SERVER_VERSION for release 0.11.0" This reverts commit dd5c995c32cf595d31e59975bd1b3216cf996656. 2012-06-21 Alon Levy spice.h: bump SPICE_SERVER_VERSION for release 0.11.0 update spice-common for multiple monitor in single display channel support 2012-06-19 Nikolay Orlyuk Added configure option --disable-xinerama This parameter was added to be able to control dependency on libXinerama. Which is really useful for package managers. Fixes bug #51192 2012-06-12 Alon Levy Release 0.11.0 Current bumped and age bumped for new intefaces only (no backward incompatible changes). New libtool version is 2.0.1, using --version-info instead of --version-name. Doing the version change and --version-name to --version-info change here to avoid changing the libtool version twice. Added interfaces: spice_server_set_name spice_server_set_uuid spice_server_set_listen_socket_fd spice_server_is_server_mouse New library name in linux: libspice-server.so.1.1.0 Old: libspice-server.so.1.0.2 2012-06-07 Alon Levy server/red_channel: s/channle/channel 2012-06-06 Alon Levy m4/spice-compile-warnings: Squelch _FORTIFY_SOURCE when needed to avoid glibc #warnings. Fix copied from libvirt, commit by Eric Blake. glibc 2.15 (on Fedora 17) coupled with explicit disabling of optimization during development dies a painful death: /usr/include/features.h:314:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] Work around this by only conditionally defining _FORTIFY_SOURCE, in the case where glibc can actually use it. The trick is using AH_VERBATIM instead of AC_DEFINE. 2012-06-05 Alon Levy server/spice.h: s/Pleaes/Please/ 2012-05-31 Yonit Halperin server/red_channel: do not attempt to write if the channel client is disconnected The red_channel_client_event call to red_channel_client_receive might result in a disconnected channel client. The following call to red_channel_client_push may call to red_peer_handle_outgoing with a disconnected socket. server/red_channel: fix possible access to released channel clients Added ref count for RedChannel and RedChannelClient. red_channel.c/red_peer_handle_incoming call to handler->cb->handle_message might lead to the release of the channel client, and the following call to handler->cb->release_msg_buf will be a violation. This bug can be produced by causing main_channel_handle_parsed call red_client_destory, e.g., by some violation in reds_on_main_agent_data that will result in a call to reds_disconnect. 2012-05-24 Yonit Halperin server/red_worker: fix red_wait_pipe_item_sent Resolves: rhbz#824384 red_wait_pipe_item_sent mistakingly returned without waiting for sending the given pipe item when the channel wasn't blocked. As a result, we failed when we had to destroy a surface (e.g., QXL_IO_DESTROY_ALL_SURFACES) and to release all the drawables that are depended on it (by removing them or waiting they will be sent). In addition, red_wait_pipe_item_sent increased and decreased the reference to the pipe item using channel_cbs->hold_item, and channel_cbs->release_item. However, these calls can be called only by red_channel, otherwise display_channel_client_release_item_before_push is called twice and leads to a double call to ring_remove(&dpi->base). Instead ref/put_drawable_pipe_item should be called. server/red_channel: remove red_channel_client_item_being_sent The above routine was risky, since red_channel_client_init_send_data can also be called with item==NULL. Thus, not all pipe items can be tracked. The one call that was made for this routine was not necessary. 2012-05-21 Yonit Halperin server: handle red_channel_client_create returning NULL server/red_channel: prevent creating more than one channel client with the same type+id server/video: do not allow non-streamable drawables be stream candidates Resolves: rhbz#820669 Fix a segfault caused by a call to __red_is_next_stream_frame made by red_stream_maintenance, with a drawable that is not a DRAW_COPY one. The segfault is a reault of __red_is_next_stream_frame accessing red_drawable->u.copy.src_bitmap for a non DRAW_COPY drawable. 2012-05-16 Yonit Halperin server/tests: test_display_streaming - test wide sized frames Before, we tested only higher frames, while wider frames would have triggered a bug in mjpeg_encoder, when spice is linked with libjpeg and not libjpeg-turbo. server/mjpeg_encoder: realloc encoder->row, when a wider frame is given Fix crashes when there are sized wider frames in the stream, and we are linked with libjpeg. Related : rhbz#813826 Resolves: rhbz#820669 2012-05-15 Alon Levy server: move self_bitmap_image to RedDrawable Simplify keeping count of self_bitmap_image by putting it in RedDrawable. It is allocated on reading from the command pipe and deallocated when the last reference to the RedDrawable is dropped, instead of keeping track of it in GlzDrawable and Drawable. server/red_worker/put_red_drawable: s/drawable/red_drawable/ server/red_worker/red_handle_self_bitmap: add red_drawable local, one extra whitespace line removed server/red_worker: rename SpiceImage *self_bitmap to self_bitmap_image Revert "server/red_worker: fix possible leak of self_bitmap" This reverts commit 35dbf3ccc4b852f9dbb29eb8a53c94f26d2e3a6e. accidentally pushed v1 of patches, reverting in preperation of pushing v2. 2012-05-14 Alon Levy server/red_worker: fix possible leak of self_bitmap After the previous patch moving self_bitmap freeing inside red_drawable ref count, we have a possible self_bitmap leak: red_process_commands red_get_drawable | red_drawable #1, red_drawable->self_bitmap == 1 red_process_drawable | rd #2, d #1, d->self_bitmap != NULL release_drawable | rd #1, d# = 0, try to release self_bitmap, but blocked by rd #1 put_red_drawable | rd #0 This patch moves the call to release_drawable after the call to put_red_drawable, thereby fixing the above situation. server/red_worker/red_process_commands: rename drawable to red_drawable (later add a local drawable) server/red_worker: red_process_drawable: have single point of exit 2012-05-14 Yonit Halperin server/red_worker: don't release self_bitmap unless refcount is 0 RHBZ: 808936 2012-05-10 Yonit Halperin server/mjpeg_encoder: fix wrong size assigned to dest_len It should have been the allocated size and not the occupied one. This led to a lot of unnecessary allocations and deallocations. server/mjpeg_encoder: Fix memory leak for the inital output buffer given for each frame 2012-05-07 Alon Levy server/reds: add "usbredir" to recognized channel names RHBZ: 819484 2012-05-04 Nahum Shalman cleanup x11 library detection for building client Consolidate two separate chunks of library hunting that depend on the same check. Check if we're actually building the client before looking for client only libraries. Hide some of the final output if we're not building the client. 2012-05-03 Yonit Halperin server/tests/test_display_streaming: include tests for clip and sized frames CC: Alon Levy server/tests: use the correct dimensions in SIMPLE_UPDATE server/tests: add SLEEP command to test_display_base server/tests: add clip to SIMPLE_DRAW_BITMAP 2012-05-03 Alon Levy server/tests/test_display_streaming: update to create sized frames server/tests: add SIMPLE_DRAW_SOLID and SIMPLE_DRAW_BITMAP server/tests: refactor Command server/tests: add test_get_width/test_get_height server/tests: refactor test_display_base 2012-05-03 Yonit Halperin server/red_worker/video: don't override the clip in areas that belong only to sized frames server/red_worker.c/video: add support for frames of different sizes rhbz #813826 When playing a youtube video on Windows guest, the driver sometimes(**) sends images which contain the video frames, but also other parts of the screen (e.g., the youtube process bar). In order to prevent glitches, we send these images as part of the stream, using SPICE_MSG_DISPLAY_STREAM_DATA_SIZED. (**) It happens regularly with the you tube html5 player. With flash, it occurs when moving the cursor in the player area. Update the spice-common submodule spice-common changes: STREAM_DATA_SIZED message was added in order to support video streams with frames that their size is different from the initial size that the stream was created with. This patch also includes server and client adjustments to the new SpiceMsgDisplayStreamData. server/red_worker/video: don't detach a drawable from a stream due to it being rendered. The previous patch took care that streams will be upgraded by a surface screenshot and not the last frame, if necessary. Thus, there is no more a reason for detaching drawables from streams when they are rendered. Moreover, detaching such drawables can cause glitches, in case they are still in the pipe, and red_update_area is called frequently and leads to stream frames rendering. server/red_worker/video: upgrade stream by a screenshot instead of the last frame, if needed Upgrading a stream: When the stream's visible region is bigger than the one of the last frame, we will send an updated screenshot of the visible region, instead of sending the last frame losslessly. server/red_worker/video: maintain visible region and clip region for streams Differentiate between the clipping of the video stream, and the region that currently displays fragments of the video stream (henceforth, vis_region). The latter equals or contains the former one. For example, let c1 be the clip area at time t1, and c2 be the clip area at time t2, where t1 < t2. If c1 contains c2, and at least part of c1/c2, hasn't been covered by a non-video images, vis_region will contain c2, and also the part of c1/c2 that still displays fragments of the video. When we consider if a stream should be "upgraded" (1), due to its area being used by a rendering operation, or due to stopping the video, we should take into account the vis_region, and not the clip region (next patch: not upgrade by the last frame, but rather by vis_region). This fix will be more necessary when sized frames are introduced (see the following patches). Then, the vis_region might be larger than the last frame, and contain it, more frequently than before. (1) "upgrading a stream" stands for sending its last frame losslessly. Or more precisely, lossless resending of all the currently displayed lossy areas, that were sent as part of the stream. server/red_worker: add get_stream_id Update the spice-common submodule We need some rect/region getters methods that were added 2012-04-27 Jeremy White Force 64 bit multiplication on 32 bit systems; fixes a bug where the server times out the display channel freakily fast. 2012-04-26 Daniel P. Berrange Ensure __STDC_FORMAT_MACROS is always defined first The client/common.h file defines __STDC_FORMAT_MACROS before including inttypes.h so that the PRI* macros get defined in C++. This is ignoring the possibility that other global includes may have already pulled in inttypes.h We need __STDC_FORMAT_MACROS to be defined before any header files are included. Putting it in config.h satisfies this, since config.h is always the first header Disable -Waggregate-return if building with SLIRP The API design of SLIRP means that it is not practical to use the -Waggregate-return warning flag. Disable this flag in the (unlikely) scenario where SLIRP is actually requested at build time 2012-04-26 Alon Levy bump spice-common with SpiceClips fix 2012-04-25 Daniel P. Berrange Add some more 'noreturn' annotations Methods which longjump, unconditionally raise an exception, or call _exit() cannot return control to the caller so should be annotated with 'noreturn' Fix typo in is_equal_brush The 3 part of the conditional in the is_equal_brush method compared the b1->u.color field to itself, instead of b2->u.color Fix printf format specifiers for i686 hosts Add missing struct field initializers Ensure config.h is the first include in the file Add a few more syntax-check exemptions Add recent new committers to AUTHORS file / mailmap Enable many more compiler warnings * m4/manywarnings.m4m, m4/warnings.m4: Import GNULIB warnings modules * m4/spice-compile-warnings.m4: Define SPICE_COMPILE_WARNINGS * configure.ac: Replace compile warning check with a call to SPICE_COMPILE_WARNINGS * client/Makefile.am: Use WARN_CXXFLAGS instead of WARN_CFLAGS Make some int->pointer casts explicit Tell the compiler that was really do intend to cast from int to pointer, to prevent warnings about implicit casts * server/tests/test_display_base.c: Add explicit casts Fix broken -I../common to be -I../spice-common in client * Makefile.am: s/common/spice-common/ VSCMsgHeader.reader_id is unsigned, so don't check for >= 0 * server/smartcard.c: Fix assertion to not check for >= 0 on unsigned variable Avoid jumping across variables declarations with initializers If a 'goto' statement jumps across a variable declaration which also has an initializer, the variable is in an undefined state. Splitting the the declaration & initialization doesn't change that, but the compiler can at least now detect use of the unintialized variable Convert cases of () to (void) * server/reds.c, server/smartcard.c: s/()/(void) Remove 2 *MB* stack frame in red_worker_main The red_worker_main method allocates a RedWorker struct instance on the stack. This struct is a full 2 MB in size which is not at all resonable to allocate on the stack. * server/red_worker.c: Move RedWorker struct to the heap Mark some variables as volatile When using setjmp/longjmp the state of local variables can be undefined in certain scenarios: [quote man(longjmp)] The values of automatic variables are unspecified after a call to longjmp() if they meet all the following criteria: · they are local to the function that made the correspond‐ ing setjmp(3) call; · their values are changed between the calls to setjmp(3) and longjmp(); and · they are not declared as volatile. [/quote] * server/red_worker.c: Mark some vars as volatile Mark functions which never return control * client/red_channel.cpp: AbortTrigger::on_event can't return given its current impl * server/red_worker.c: red_worker_main can't return Fix multiple printf format problems All printf var-args style methods should be annotation with their format. All format strings must be const strings. * client/application.cpp, client/cmd_line_parser.cpp, client/hot_keys.cpp: Avoid non-const format * client/client_net_socket.cpp: Fix broken format specifier * client/red_peer.cpp: Fix missing format specifier * client/platform.h: Add SPICE_GNUC_PRINTF annotation to term_printf * client/utils.h: Add SPICE_GNUC_PRINTF annotation to string_printf * server/glz_encoder_config.h, server/red_worker.c: Add SPICE_GNUC_PRINTF annotation to warning callbacks Fix const-ness violations * server/red_worker.c: Add missing const for return type * server/reds.c: Static strings must be declared const Don't do arithmetic on void * type, use uint8_t instead Arithmetic on void * types is non-portable & trivially avoided * server/dispatcher.c: Use uint8_t for arithmetic 2012-04-18 Alon Levy spice-common: update submodule to verify_subject MSVC++ fix spice-common: update submodule update spice-common for MSVC++ build fixes 2012-04-18 Aric Stewart update visual studio project file Note, there may be line-ending issues here is we are not careful. This file is a msdos formatted file. There was some inconsistencies in those line-ending that I have normalized. 2012-04-18 Alon Levy client/windows/redc.vcproj: switch to unix EOL (dos2unix) 2012-04-18 Aric Stewart Update win32 generate(1).bat files to match modern usage This involves: generating .c instead of .cpp files Not including "common.h" Standardizing some parameters we do not need afxres.h included in redc.rc It is not an MFC project so simply including windef.h is better and allows for compiling with the Express editions of Visual Studio. 2012-04-18 Michael Tokarev fix error-path return in snd_set_record_peer() The error_{1,2} labels in this functions are backwards. 2012-04-17 Aric Stewart Copy getopt.h from old common/win/my_getopt-1.5/my_getopt This patch completes the copy from 4d8f39020ac83602c1647d4af04e8b19bf74ed6e which missed this file. update windows client generate.bat and generate1.bat the python script is now in spice-common and client_marshallers.h needs to be included instead of marshallers.h 2012-04-05 Alon Levy server: allow failure in getvirt This patch changed getvirt to continue working even if spice_critical doesn't abort (i.e. SPICE_ABORT_LEVEL != -1). This is in preparation to make getvirt not abort at all. The reason is that getvirt is run on guest provided memory, so a bad driver can crash the vm. 2012-04-02 Christophe Fergeau Replace sprintf with snprintf use The hotkey parser was generating a string with sprintf and data it got from the controller socket (ie data which can have an arbitrary length). Using sprintf there is a bad idea, replace it with snprintf. 2012-03-28 Marc-André Lureau spice-common: update to fix quic-encode warnings 2012-03-26 Alon Levy server: export spice_server_is_server_mouse predicate To be used by qemu query-spice / info spice commands. 2012-03-26 Marc-André Lureau Remove files moved to spice-common 2012-03-25 Marc-André Lureau Copy common/win/my_getopt-1.5/my_getopt client/windows Use the spice-common logging functions It will abort by default for critical level messages. That behaviour can be tuned at runtime. Use the spice-common submodule This patch will replace the common/ directory with the spice-common project. It is for now a simple project subdirectory shared with spice-gtk, but the goal is to make it a proper library later on. With this change, the spice-server build is broken. The following commits fix the build, and have been seperated to ease the review. v2 - moves all the generated marshallers to spice-common library - don't attempt to fix windows VS build, which should somehow be splitted with spice-common (or built from tarball only to avoid generation tools/libs deps) v3 - uses libspice-common-client - fix a mutex.h inclusion reported by Alon 2012-03-23 Marc-André Lureau sasl: small refactoring, check memcheck != NULL Use spice_strdup() to avoid crashing on NULL qemu can call spice_server_set_name(s, NULL) when the name is not given. Let's not crash in this case 2012-03-22 Alon Levy server/tests: add resolution changes tester server/tests/test_display_base: add Command add parameters to the commands used for display tests. 2012-03-21 Alon Levy server/tests/test_display_base: remove 64bit arch assumptions server/red_memslots: don't assume 64 bit environment assumption that unsigned long == QXLPHYSICAL causes get_virt to compute the wrong slot. Fix by replacing addr variables to be of type QXLPHYSICAL. server/red_worker: fix for case where ASSERT is compiled out server/red_memslots: use QXLPHYSICAL for addresses Cannot assume unsigned long == QXLPHYSICAL, not true for 32 bit architectures. server/red_memslots: drop two unused functions cb_get_virt and cb_validate_virt have disappeared a long time ago, not needed since: commit 5ac88aa79fa6445f96e5419d8bf4fce81da63b90 Author: Gerd Hoffmann Date: Thu Jul 1 17:55:33 2010 +0200 Properly parse QXLImage to the new-world SpiceImage SpiceImage now replaces RedImage and has all image types in it. All image data are now chunked (and as such not copied when demarshalling). 2012-03-20 Christophe Fergeau Don't truncate SPICE_FOREIGN_MENU_SOCKET When we get the socket name for the foreign menu socket from an environment variable, we cannot make assumptions about its length. Currently, we are strncpying to a 50 byte buffer which is easily too small. Don't limit spice controller socket name to 50 chars The spice controller socket name used to be hardcoded to /tmp/SpiceController-%lu.uds and generated using snprintf. A 50 bytes buffer was enough for that, but this was changed in commit 79fffbf95 because this was predictable and allowed other users on the system to sniff the browser/client communication. spicec now uses the value of the environment SPICE_XPI_SOCKET as the name of the socket to use. However, since the name that is used is no longer generated by spicec, no assumption can be made about its size. Currently, the socket is created inside the user home directory, which means that if the user name is too long, spicec will not be able to read the controller socket name. This commit directly uses the string from getenv as he name of the controller socket (on Linux) instead of limiting its size to 50 characters, which should fix this issue. This fixes rhbz #804561 Remove unused Canvas members The various Canvas have _max and _base variables which are not used, better to remove them. 2012-03-20 Alon Levy server/red_worker: don't typedef SpiceWatch twice First defined in spice.h, fixes build failure with gcc 4.4.6 2012-03-13 Hans de Goede red_worker: Check for NULL watches If we run out of watches slots, we return NULL from watch_add, which means that the other watch_foo functions may get called with a NULL parameter, protect them against this. 2012-03-12 Nahum Shalman server: remove superfluous check no need to duplicate the check that the fd isn't -1 server: listen on a pre-opened file descriptor Allow applications to pre-open a file descriptor and have spice listen on it. Thanks to Daniel Berrange for his comments server: don't fail on ENOPROTOOPT from setsockopt If we allow listening on arbitrary sockets like unix sockets, we can get ENOPROTOOPT errors from setsockopt calls that set TCP specific options. This should be allowed to happen. 2012-03-12 Hans de Goede red_channel: remove pre_disconnect hook Now that red_worker's EventListener is gone there are no more users of it. red_worker: Rework poll code to use the watch interface Commit 143a1df24e83e9c1e173c16aeb76d61ffdce9598 changed red_worker_main from epoll to poll. But epoll has edge triggered semantics (when requested and we requested them), where as poll is always level triggered. And red_worker was relying on the edge triggered semantics, as it was always polling for POLLOUT, which, when edge triggered, would only cause poll to register an event after we had blocked on a write. But after the switch to regular poll, with its level triggered semantics, the POLLOUT condition would almost always be true, causing red_worker_main to not block on the poll and burn CPU as fast as it can as soon as a client was connected. Luckily we already have a mechanism to switch from polling for read only to polling for read+write and back again in the form of watches. So this patch changes the red_worker dummy watch implementation into a proper watch implementation, and drops the entire EventListener concept since that then is no longer needed. This fixes spice-server using 400% CPU on my quad core machine as soon as a client was connected to a multi head vm, and as an added bonus is a nice cleanup IMHO. red_channel: Use the channel core to remove the stream watch on disconnect We allow channels to have different core implementations, but we were relying on reds_stream_free to remove the stream watch on disconnect, and reds_stream_free always uses the qemu core implementation. So far we were getting away with this since all the alternative core implementations always return NULL from watch_add. But: 1) The code before this patch clearly was not correct, since it was matching a channel-core watch_add with a qemu-core watch_remove 2) I plan to move red_worker over to actually using an alternative watch implementation at which point this becomes a real problem 2012-03-10 Hans de Goede red_worker: Remove ref counting from the EventListener struct The red_worker EventListener struct is either embedded in one of: 1) DisplayChannelClient 2) CursorChannelClient 3) RedWorker And as such gets destroyed when these get destroyed, in case 1 & 2 through a call to red_channel_client_destroy(). So free-ing it when the ref-count becomes 0 is wrong, for cases: 1) and 2) this will lead to a double free; 3) this will lead to passing memory to free which was not returned by malloc. This is not causing any issues as the ref-count never gets decremented, other then in red_worker_main where it gets incremented before it gets decremented, so it never becomes 0. So we might just as well completely remove it. Notes: 1) This is mainly a preparation patch for fixing issues introduced by the move from epoll to poll 2) Since removing the ref-counting removes the one code path where listeners would get set to NULL, this patch moves the setting of NULL to pre_disconnect, where it should have been done in the first place since red_client_destroy calls red_channel_client_disconnect (through the dispatcher) followed by red_channel_client_destroy, so after pre_disconnect the listener may be gone. Ensure all members of ChannelCbs and ClientCbs are either assigned or NULL While git-bisecting another issue I ended up hitting and not recognizing the bug fixed by commit 7a079b452b026d6ce38f95dcc397fa64b059fffb. While fixing this (again) I noticed that (even after the fix) not all users of ChannelCbs first zero it. So this patch ensures that all users of ChannelCbs first zero it, and does the same for ClientCbs while at it. Since before this patch there were multiple zero-ing styles, some using memset and other using a zero initializer this patch also unifies all the zero-ing to use a NULL initializer for the first element. 2012-03-06 Alon Levy server/red_worker: fix use after free for listeners This fixes a core dumped observed once by repeated migration. So far 100 migrations and no recurrence. Core was generated by `/home/alon/spice/upstream/bin/qemu-system-x86_64 --enable-kvm -qmp unix:/tmp/mi'. Program terminated with signal 11, Segmentation fault. 11197 if (evt_listener && evt_listener->refs > 1) { Missing separate debuginfos, use: debuginfo-install bluez-libs-4.98-3.fc17.x86_64 brlapi-0.5.6-4.fc17.x86_64 bzip2-libs-1.0.6-4.fc17.x86_64 cryptopp-5.6.1-6.fc17.x86_64 keyutils-libs-1.5.5-2.fc17.x86_64 libssh2-1.4.0-1.fc17.x86_64 nss-softokn-freebl-3.13.1-20.fc17.x86_64 xen-libs-4.1.2-11.fc17.x86_64 xz-libs-5.1.1-2alpha.fc17.x86_64 (gdb) bt (gdb) l 11192 for (i = 0; i < MAX_EVENT_SOURCES; i++) { 11193 struct pollfd *pfd = worker.poll_fds + i; 11194 if (pfd->revents) { 11195 EventListener *evt_listener = worker.listeners[i]; 11196 11197 if (evt_listener && evt_listener->refs > 1) { 11198 evt_listener->action(evt_listener, pfd); 11199 if (--evt_listener->refs) { 11200 continue; 11201 } (gdb) p evt_listener $1 = (EventListener *) 0x7f15a9a5d1e0 (gdb) p *evt_listener Cannot access memory at address 0x7f15a9a5d1e0 (gdb) p i $2 = 2 (gdb) p worker.listeners $3 = {0x7f15bc832520, 0x7f15a406e1a0, 0x7f15a9a5d1e0, 0x0 } 2012-03-05 Marc-André Lureau Use SPICE_FOREIGN_MENU_SOCKET if it's available If specified, use SPICE_FOREIGN_MENU_SOCKET environment variable over snprintf(pipe_name, PIPE_NAME_MAX_LEN, PIPE_NAME, Platform::get_process_id()); since it's impossible to guess the client pid when spice-xpi launches the client as a grand-child (via script etc). This is also more aligned with the way we handle SPICE_XPI_SOCKET location. Fix spice-protocol reference Send name & uuid to capable clients Add spice_server_set_name() and spice_server_set_uuid() that allows the client to identify a Spice server (useful to associate settings with a particular server) The SPICE_MSG_MAIN_NAME and SPICE_MSG_MAIN_UUID messages are only sent to capable clients, announcing SPICE_MAIN_CAP_NAME_AND_UUID. demarshal: fixed-size array are missing __nelements A message with a fixed-size array, such as uint8 uuid[16] will generate an invalid code, missing the __nelements variable. Make sure that variable is defined. 2012-03-05 Christophe Fergeau server: more logging about certificates used This commit adds some log messages indicating which certificates could be loaded (or not). Fixes rhbz#787678 Add log for invalid/expired tickets Currently, when a ticket has already expired, or is invalid, there is no qemu log to tell what went wrong. This commit adds such a log. Fixes rhbz#787669 2012-03-04 Christophe Fergeau mingw: workaround weird openssl build failure If X509_NAME isn't undefined before including x509v3.h, very weird compilation error occurs. It seems to be caused by duplicate definitions for this symbols coming from wincrypto.h mingw: don't try to redefine alloca mingw already has a #define alloca __builtin_alloca so trying to redefine it triggers a warning. mingw: fix signed/unsigned comparison warnings mingw: add workaround for _ftime_s issue on mingw mingw has a _ftime_s prototype in its headers, but no corresponding symbol available at link time. Workaround this issue for now by #defining it to _ftime. This is untested on win64 where the workaround may not be needed. mingw: #ifdef unneeded #define in common.h common.h has some #define when doing win32 build to workaround a few missing functions on these systems. However, since mingw32 has some of these, this causes either warnings about redefining preprocessor symbols or wreak havoc in mingw headers trying to use these symbols. This commit wraps these symbols in an #ifndef __MINGW32__ to avoid using them on this platform. mingw: use uintptr_t when converting a pointer to an int win64 uses 32 bit long, so we cannot use a long to hold a 64 bit pointer. Thankfully, there's a [u]intptr_t type available exactly for these uses. 2012-03-01 Marc-André Lureau build-sys: fix make distcheck - Do not refer to .c files managed by another makefile (this will fail make distclean) - Do not refer to files by relative path (should use $top_srcdir for ex) - Use LDADD for object linking instead of LDFLAGS, for linker flags build-sys: cleanup server/tests/Makefile.am build-sys: use spice-protocol as submodule build-sys: cleanup, use autoreconf 2012-03-01 Arnon Gilboa client/windows: fix SetClipboardViewer error handling rhbz#786554 MSDN says the following about SetClipboardViewer(): "If an error occurs or there are no other windows in the clipboard viewer chain, the return value is NULL". Seems like the buggy case was "no other windows in the clipboard viewer chain", which explains the 3rd party clipboard manager workaround detailed in the bug description. It also seems like SetClipboardViewer() does not clear the error state on succcess. Calling SetLastError(0) before SetClipboardViewer() seems to solves this issue. Since we could not reproduce the bug on our env, the customer has verified on several of their systems that a private build resolved the issue. 2012-03-01 Yonit Halperin client X11: support volume keys when evdev is in use Add support for sending volume keys scancodes to the guest RHBZ #552539 client: keyboard - add mapping for volume keys Add support for sending volume keys scancodes to the guest RHBZ #552539 A good reference for mapping keymaps to scancodes can be found in spice-gtk/gtk/keymaps.csv 2012-02-29 Christophe Fergeau Fix compilation when smartcard support is disabled The addition of smartcard control to the controller doesn't handle the case when smartcard support is disabled at compile time. When this is the case, this causes compile errors. 2012-02-28 Alon Levy controller_test: add README client controller_test: reorder parameters since pid isn't needed for linux client test client: handle CONTROLLER_ENABLE_SMARTCARD (rhbz 641828) controller_test: add ENABLE_SMARTCARD 2012-02-26 Alon Levy server: fix segfault on client disconnect ..as a result of missing initialization of newly introduced pre_disconnect in main channel. 2012-02-26 Fabiano Fidêncio Enabling cursor in server/tests Now, cursor is being shown in all tests as a white rectangle and is running in the screen doing a diagonal movement. It's a very simple way to test cursor commands and is sufficient for our tests. 2012-02-21 Dan McGee Use standard IOV_MAX definition where applicable This is provided by on all platforms as long as _XOPEN_SOURCE is defined. On Linux, this is 1024, on Solaris, this is 16, and on any other platform, we now respect the value supported by the OS. Respect IOV_MAX if defined Solaris has a pitiful maximum writev vector size of only 16, so the ping request at initial startup destroyed this call and broke things immediately. Reimplement stream_writev_cb() to respect IOV_MAX and break the writev() calls into chunks as necessary. Care was taken to return the correct values as necessary so the EAGAIN handling logic can determine where to resume the writev call the next time around. red_worker: reimplement event loop using poll() This removes the epoll dependency we had in red_worker, which was the last Linux-specific call we were using in the entire Spice server. Given we never have more than 10 file descriptors involved, there is little performance gain had here by using epoll() over poll(). The biggest change is introduction of a new pre_disconnect callback; this is because poll, unlike epoll, cannot automatically remove file descriptors as they are closed from the pollfd set. This cannot be done in the existing on_disconnect callback; that is too late as the stream has already been closed and the file descriptor lost. The on_disconnect callback can not be moved before the close and other operations easily because of some behavior that relies on client_num being set to a certain value. Use memcpy call in red_channel_create Rather than assign the callbacks one-by-one, we can just memcpy the struct into the one we have allocated in our RedChannel object, which is much more efficient, not to mention future-proof when more callbacks are added. Cleanup definitions of disconnect methods We had multiple stub methods that simply called other disconnect methods, making my head hurt with the indirection. Call the right methods at the right time and rip out the stub methods; if they are truely needed later they can be added again. red_worker: rename epoll_timeout to event_timeout With future patches in mind that will allow for some other non-Linux-specific event polling sytem to be used, rename this to a more generic name. All of the select/poll/epoll/kqueue family of calls are related to evented I/O, so 'event_' makes sense in this case. Add configure-time check for -Wl, --version-script option This is supported by the GNU linker, but not the Solaris linker, which is used as the default on that platform even when compiling with GCC. Omit passing the option to the linker on platforms that do not support it. 2012-02-20 Hans de Goede server/spicevmc: Don't destroy the rcc twice spicevmc calls red_channel_client_destroy() on the rcc when it disconnects since we don't want to delay the destroy until the session gets closed as spicevmc channels can be opened, closed and opened again during a single session. This causes red_channel_client_destroy() to get called twice, triggering an assert, when a connected channel gets destroyed. This was fixed with commit ffc4de01e6f9ea0676f17b10e45a137d7e15d6ac for the case where: a spicevmc channel was open on client disconnected, and the main channel disconnect gets handled first. But the channel can also be destroyed when the chardev gets unregistered with the spice-server. This path still triggers the assert. This patch fixes this by adding a destroying flag to the rcc struct, and also moves the previous fix over to the same, more clean, method of detecting this special case. 2012-02-15 Alon Levy server/tests/basic_event_loop: print something on channel_event server, separate SpiceChannelEventInfo from RedStream fixes rhbz 790749 use after free of SpiceChannelEventInfo. The lifetime of the SpiceChannelEventInfo was that of RedsStream, but it is used by main_dispatcher_handle_channel_event after the RedsStream is freed for the cursor and display channels. Making SCEI allocation be at RedsStream allocation, and deallocation after the DESTROY event is processed by core->channel_event, fixes use after free. README: make a note of SPICE_DEBUG_ALLOW_MC 2012-02-14 Dan McGee Remove all usages of bzero() As recommended by modern C practice, we should just be using memset(). Remove extra '\n' from red_printf() calls red_printf() takes care of adding a newline to all messages; remove the extra newline from all messages and macros that were doubling them up. 2012-02-14 Alon Levy server/tests: use getopt_long 2012-02-14 Fabiano Fidêncio Adding image to be used as "correct" in regression tests Adding support to automated tests As suggested by Alon, a simple automated test to try to find regressions in Spice code. To use this, compile Spice with --enable-automated-tests and run test_display_streaming passing --automated-tests as parameter. 2012-02-14 Dan McGee Add casts for compatibility purposes Some non-Linux platforms return a (caddr_t *) result for the return value of mmap(), which is very unfortunate. Add a (void *) cast to explicitly avoid the warning when compiling with -Werror. For the IO vector related stuff, signed vs. unsigned comes into play so adding a (void *) cast here is technically correct for all platforms. 2012-02-12 Yonit Halperin server: support IPV6 addresses in channel events sent to qemu RHBZ #788444 CC: Gerd Hoffmann 2012-02-09 Erlon Cruz Fix mandatory -Werror option Compilation was breaking due to warning errors even when configuring with --enable-werror=no. This patch fix this. 2012-02-03 Christophe Fergeau Handle Application::set_hotkeys failure Application::set_hotkeys can throw an exception if it fails parsing the string describing the hotkeys to set. Currently this exception is uncaught which causes spicec to terminate when the controller tries to set invalid hotkeys. Fall back to using the default hotkeys when the controller sends an invalid hotkeys string. 2012-01-31 Christophe Fergeau Don't use "hw:0,0" for recording with alsa We currently hardcode this device when spicec needs to record with alsa. However, this doesn't interact well with PulseAudio, which means that if something is already using the recording device, spicec won't be able to open it again. Using "default" as the device will let spicec use the PulseAudio alsa support and will avoid this issue. 2012-01-23 Hans de Goede More comparison between signed and unsigned integer expressions warning fixes Turns out that more recent snapshots of gcc-4.7 emit even more of these, so the fixes which I've done before tagging the 0.10.1 release are not enough to build warning free with the latest gcc-4.7 snapshot . This fixes this. Release 0.10.1 Fix various comparison between signed and unsigned integer expressions warnings These turn into errors because of our -Werror use, breaking the build. 2012-01-23 Alon Levy server/red_channel: red_peer_handle_incoming: comment on null check server/tests/test_empty_success: fix warning on bzero 2012-01-23 Dan McGee Use found python binary to check for pyparsing This matches what we do in client/Makefile.am to actually run the python scripts, which is to use the python binary we find first, preferring 'python2' over 'python'. This makes the compile work on odd systems such as Arch Linux where the python binary is actually python3. Remove epoll headers from client code There is no more usage of epoll on the client side, so no need to include these header files. 2012-01-23 Nahum Shalman server: don't complain if setsockopt(SO_PRIORITY) call fails dc7855967f4e did this for the TCP_NODELAY and IP_TOS calls; we should do it for priority as well if necessary. We also #ifdef the setting of the low-level socket priority based on whether we have a definition of SO_PRIORITY available. This option is not available on Illumos/Solaris platforms; however, since we set IP_TOS anyway it is not a big deal to omit it here. 2012-01-23 Dan McGee server/inputs_channel: don't set O_ASYNC option on socket output to send a SIGIO signal to the running program. However, we don't handle this signal anywhere in the code, so setting the option is unnecessary. Update .gitignore with a few more generated files Fix git commit hook errors in red_worker This ensures all line lengths are down below 100 characters as well as removing some trailing spaces. Fix line length errors in main_channel These are all existing errors; fix them so they don't block future commits in this file unnecessarily. error (1): length @ server/main_channel.c +369 error (2): length @ server/main_channel.c +444 error (3): length @ server/main_channel.c +764 error (4): length @ server/main_channel.c +932 error (5): length @ server/main_channel.c +1044 2012-01-22 Alon Levy docs/Spice_for_newbies.odt: some updates - added copy paste and wan mention, removed vdi_port server/red_channel: avoid segfault if stream == NULL client/foreign_menu: arm build fix import existing odt docs 2012-01-18 Hans de Goede server: Don't complain if setsockopt NODELAY fails on unix sockets With Daniel P. Berrange's patches to allow use of pre-supplied fd's as channels, we can no longer be sure that our connections are TCP sockets, so it makes no sense to complain if a TCP/IP specific setsockopt fails with an errno of ENOTSUP. Note that this extends Daniel's commit 492ddb5d1d595e2d12208f4602b18e4432f4e6b4 which already added the same check to server/inputs_channel.c 2012-01-13 Daniel P. Berrange Add a 'syntax-check' make target The 'make syntax-check' target is used to perform various code style sanity checks, as well as to detect certain trivial error patterns. The target is placed in GNUmakefile, instead of Makefile.am since it relies on GNU specific make extensions. The actual GNUmakefile and maint.mk files are taken from the GNULIB project, unchanged The cfg.mk file is used to configure which of the syntax checks are activated, to allow addition of new project specific syntax checks, and to blacklist certain files which should not be checked * .mailmap: Add mapping for various broken email addrs in commit log, to stop complaints about AUTHORS file missing entries * GNUmakefile: define the 'syntax-check' rule * maint.mk: definition of standard syntax checks * cfg.mk: configuration for checks Remove trailing whitespace from end of lines Replace test XXX -a YYY with test XXX && test YYY The '-a' and '-o' operators to test are not portable. Always combine two invocations of 'test' using || or && instead. Add missing includes of config.h Not all files were including config.h Remove bogus include of strings.h The tests include strings.h but don't need any of its functions Remove unused backup file The common/glc.c.save file appears to be a obsolete copy of glc.c Remove trailing blank lines Remove any blank lines at the end of all source files Remove 'the the' typos Remove unused assert.h include The assert.h include was never used in any code Always quote first arg to AC_DEFINE The first arg to AC_DEFINE should always be quoted Fix up copyright decl to always use 'Copyright (C) Red Hat, Inc.' A couple of files were missing '(C)' in the copyright header Improve usefulness of README file The COPYING file already contains the license text, so the README file need not repeat it. Instead put in a description of what SPICE is, simple install instructions & pointers to mailing lists and bug trackers Fill out the AUTHORS file with some content The AUTHORS file is empty, fill it in with a list of present and past maintainers, and email addresses of all people who have contributed patches Remove casts from void * with xrealloc() calls The xrealloc() function returns void*, so the return value never needs to be cast Rewrite code to avoid triggering warning about casting param to free() Since free() takes a void* parameters do not need to be cast. The existing code here is actally fine, but it trips up the syntax-check rule, so tweak it to an equivalent construct which passes the syntax check Remove useless if() before free() The free() function allows NULL to be passed in, so any code which puts a if() before free() is wasting time Death to all TABs Source files should all use spaces instead of tabs for indentation. Update the few files not already in compliance 2012-01-13 Alon Levy common/ssl_verify: special case to WIN32 that isn't MINGW32 common/bitops: mingw32: reorder so __GNUC__ define is checked first common/backtrace: for mingw32 no pipe/wait_pid, just disable client/windows: fix several assigned but not used errors client/windows: arraysize(inf.bmiColors) == 1 in mingw32 client/windows: fix typo, make error messages unique client/windows/main: mingw32 provides PACKAGE_VERSION client/common: mingw32: workaround HAVE_STDLIB_H redefined in jconfig.h client: mingw32 build needs the jpeg_boolean define client/common.h: mingw32 fix define PACKAGE_VERSION only ifndef __GNUC__ Since it is defined by autoconf and so it kinda comes with using the GNU compilers. client/Makefile.am: mingw32 fixes * build resource file with windres * include client/windows and not client/x11 * use CXIMAGE_CFLAGS (it's already set to -DDISABLE_CXIMAGE correctly) client: log command line (rhbz 767581) 2012-01-13 Hans de Goede client-x11: Fix building with gcc-4.7 Without this change gcc says: x11/res.cpp:31:1: error: narrowing conversion of ‘(((unsigned int)_alt_image.::width) * 4u)’ from ‘unsigned int’ to ‘int’ inside { } is ill-formed in C++11 [-Werror=narrowing] x11/res.cpp:61:1: error: narrowing conversion of ‘_red_icon.::width’ from ‘const uint32_t {aka const unsigned int}’ to ‘int’ inside { } is ill-formed in C++11 [-Werror=narrowing] x11/res.cpp:61:1: error: narrowing conversion of ‘_red_icon.::height’ from ‘const uint32_t {aka const unsigned int}’ to ‘int’ inside { } is ill-formed in C++11 [-Werror=narrowing] cc1plus: all warnings being treated as errors smartcard handling: Fix compilation when ASSERT-s are turned on 2012-01-12 Yonit Halperin server: add support for SPICE_COMMON_CAP_MINI_HEADER Support for a header without a serial and without sub list. red_channel: Support the two types of headers. Keep a consistent consecutive messages serial. red_worker: use urgent marshaller instead of sub list. snd_worker: Sound channels need special support since they still don't use red_channel for sending & receiving. configure: spice-protocol >= 0.10.1 (mini header support) server: Limit the access to SpiceDataHeader of messages - only via red_channel. server/red_worker: pass remote caps to display/cursor red_channel_client's server/red_channel: introduce urgent marshaller When red_channel::red_channel_client_begin_send_message is called, the message that is pending in the urgent marshaller will be sent before the one in the main channel. The urgent marshaller should be used if in the middle of marshalling one message, you find out you need to send another message before. This functionality is equivalent to the sub_list messages. It will replace them in the following patches, when sub_list is removed from Spice data header. spice.proto: add SPICE_MSG_LIST to base channel 2012-01-12 Hans de Goede codegen: Fix enums.h generation With the new usbredir code we have the new concept of the abstract / generic spicevmc channel type (which just tunnels data from a qemu chardev), and we've the usbredir channel, which is the only current user of this. This was reflected in the protocols enum in spice-protocol.h by a manual edit done by me, my bad. This patch teaches spice.proto about the relation between the abstract spicevmc channel and the usbredir channel and modifies codegen to deal with this. 2012-01-09 Daniel P. Berrange Do not assume that SPICE is using a TCP socket If setting the TCP_NODELAY socket option fails with ENOTSUP, then don't treat this is a fatal error. SPICE is likely just running over a UNIX socket instead. * server/inputs_channel.c: Ignore TCP_NODELAY socket opt fails Allow auth to be skipped when attaching to pre-accepted clients When an applications passes in a pre-accepted socket for a client, they may well have already performed suitable authentication out of band. They should thus have the option to request that any spice authentication is skipped. * server/reds.c, spice.h: Add flag for skipping auth Add APIs for injecting a client connection socket Allow applications to pass a pre-accepted client socket file descriptor in. The new APIs are spice_server_add_ssl_client and spice_server_add_client * server/reds.c: Implement new APIs * server/spice.h: Define new APIs Move SSL setup out of reds_accept_ssl_connection To allow setup of an SSL client, from a passed in client socket, move all the SSL client initialization code out of reds_accept_ssl_connection and into a new method called reds_init_client_ssl_connection * server/reds.c: Introduce reds_init_client_ssl_connection Rename __reds_accept_connection into reds_init_client_connection Remove the accept() call from __reds_accept_connection and rename it to reds_init_client_connection. The caller is now responsible for accepting the new socket. The method reds_init_client_connection merely initializes it for usage. * server/reds.c: Add reds_init_client_connection Merge reds_accept_connection into reds_accept Neither reds_accept_connection or reds_accept are very long, so the split is pointless & increases code size for no gain. Merge them together to reduce code size * server/reds.c: Merge reds_accept_connection into reds_accept 2011-12-22 Hans de Goede spicevmc: Set sockopt nodelay for usbredir channels We want as little latency as possible with usb channels. 2011-12-22 Yonit Halperin server: don't reset the display channel when disconnecting all its clients ,FDBZ #43977 The display channel was unnecessarily set to NULL when we disconnect all the clients (on flush display commands timeout). As a result, we recreated the display channel when a new client was connected. The display channel was created with default red_channel.client_cbs, while its correct client_cbs are the ones that are set by the red_dispatcher when it creates the first display_channel. This fix enforces a single creation of the display channel (per qxl), via the red_dispatcher. 2011-12-22 Uri Lublin client: screen: fix typo _forec_update_timer sed -i 's/_forec_update_timer/_force_update_timer/' screen.cpp screen.h client: RedScreen::RedScreen: fix initialization order of _menu_needs_update Related to a91b0b3ff712eb2a7d91a951f2af7842495357c3 2011-12-20 Uri Lublin client: foreign-menu: pass "active" param when creating a ForeignMenu (#769020) The default stays the same -- false. A race could prevent setting ForeignMenu::_active correctly. That happened when Application::on_app_activated was called before _foriegn_menu was created. When foriegn_menu was created its _active defaults to false, and that has not changed, until focus was taken out and back in spice-client window. This caused usbrdr to sometimes not auto-share devices, unless the user switched focus to a different application and back to spicec. The fix updates ForiegnMenu::_active upon creation. client: update menu if needed when exiting full-screen mode (#758260) client: menu: make RedWindow::set_menu() return an error-code (#758260) RedWindow::set_menu() can fail (on Windows when in fullscreen mode). For Windows spice-client, when in fullscreen mode, the system-menu is NULL. Returns 0 upon success, non-0 (currently only -1) upon failure. client controller/foreign_menu: use memmove instead of memcpy in readers When src/dst memory areas may overlap, it's safer to use memmove. 2011-12-18 Hans de Goede spicevmc: Fix assert when still connected on session disconnect (fdo#43903) Currently when the main channel disconnects while a spicevmc channel (such as a usbredir channel) is still connected, qemu will abort with the following message: ring_remove: ASSERT item->next != NULL && item->prev != NULL failed This is caused by red_client_destroy() first calling: rcc->channel->client_cbs.disconnect(rcc); And then calling: red_channel_client_destroy(rcc); For each channel. This is fine, but the spicevmc disconnect code does a red_channel_client_destroy(rcc) itself since as usb devices are added / removed, the channels carrying their traffic get connected / disconnected and they get re-used for new devices, which won't work if the old channel is still there when the new connection comes in. This patch fixes the double destroy when there are still spicevmc channels connected by not doing the red_channel_client_destroy from the spicevmc disconnect code when not just the channel, but the entire client is disconnecting. 2011-12-15 Marc-André Lureau build: remove unused variable 2011-12-15 Hans de Goede server/red_parse_qxl.h: License should be LGPLv2+ rather then GPLv2+ Also fixup the header of server/red_parse_qxl.c, which still contained some GPL (program rather then library) text in its header. 2011-12-14 Marc-André Lureau spelling: s/cupture/capture 2011-11-28 Jürg Billeter server: Move $(Z_LIBS) from INCLUDES to LIBADD in Makefile.am This fixes undefined references to deflate* when building tests. 2011-11-24 Gal Hammer client: handle the redundant right ctrl windows' message send when a alt-gr is pressed bz#709074 Hello, The second patch check to see if Windows is sending a fake VK_CONTROL message when the user pressed Alt-Gr when using a non-US keyboard layout (German, Czech, etc...). If the function is_fake_ctrl return true and key event is translated to a REDKEY_INVALID and the event is discarded. Gal. client: handle the redundant right ctrl windows' message send when a alt-gr is pressed bz#709074 Hello, I first updated the translate_key function. It now requires the windows message as parameter (will be used later). It also use the raw wparam and lparam parameters in order to remove the code duplication when calling the function. Gal. 2011-11-14 Arnon Gilboa client: add xinerama support RHEL-6 Bugzilla: 695323 cherry-picked from qspice commit 003667ac99beeec9b330a07bc3569c59a96d4588 which fixes RHEL-5 541566 with merge of the one line qspice fix to SPICE_REQUIRES: 9f3fe4755f11044a45c4b21148466a997fcbf735 spice: fixed reference to xinerama pkg config file (Xinerama.pc=>xinerama.pc) Author: Yonit Halperin 2011-11-10 Alon Levy Release 0.10.0 Update NEWS for 0.10.0 release server/mjpeg_encoder: use size_t * consistently fix another 64 bit-ism. unsigned long != size_t in general. server/main_channel: fix pointer-to-int-cast error 64 bit-ism removed. server/main_channel: use PRIu64 where needed 2011-11-08 Alon Levy server/spice-server.syms: fix 0.8 compatibility spice_server_migrate_connect is in 0.8.3 in the released 0.8 branch, and so should not be changed in 0.10. This doesn't break the 0.9.1 release which didn't contain this symbol at all, only 0.9.2 release that hopefully no one actually packaged. server/red_worker: reuse dispatcher This patch reuses Dispatcher in RedDispatcher. It adds two helpers to red_worker to keep RedWorker opaque to the outside. The dispatcher is abused in three places that use the underlying socket directly: once sending a READY after red_init completes once for each channel creation, replying with the RedChannel instance for cursor and display. FDO Bugzilla: 42463 rfc->v1: * move callbacks to red_worker.c including registration (Yonit) * rename dispatcher to red_dispatcher in red_worker.c and red_dispatcher.c * add accessor red_dispatcher_get_dispatcher * s/dispatcher_handle_recv/dispatcher_handle_recv_read/ and change sig to just Dispatcher *dispatcher (was the SpiceCoreInterface one) * remove SpiceCoreInterface parameter from dispatcher_init (Yonit) * main_dispatcher needed it for channel_event so it has it in struct MainDispatcher * add dispatcher_get_recv_fd for red_worker server/dispatcher: add dispatcher_register_async_done_callback introduce DISPATCHER_{NONE,ACK,ASYNC} server: introduce dispatcher used for main_dispatcher only in this patch. Dispatcher is meant to be used for Main<->any low frequency messages. It's interface is meant to include the red_dispatcher usage: fixed size messages per message type some messages require an ack Some methods are added to be used by RedDispatcher later: dispatcher_handle_read - to be called directly by RedDispatcher epoll based loop dispatcher_set_opaque - to be set from red_worker pthread dispatcher_init - allow NULL core as used by red_worker Read and Write behavior: Sender: blocking write, blocking read for ack (if any). Reader: poll for any data, if such then blocking read for a message_type and following message. repeat until poll returns with no pending data to read. FDO Bugzilla: 42463 2011-11-07 Alon Levy server/red_dispatcher: remove semicolon from DBG_ASYNC server: add prefix argument to red_printf_debug printed before function name. No central location for prefixes. Adding "WORKER", "ASYNC", "MAIN" since those were the current users. server/red_dispatcher: support concurrent asyncs This is part of the dispatcher update, extracting the dispatcher routine from red_dispatcher and main_dispatcher into dispatcher. Supporting multiple async operations will make it natural to support async monitor commands and async guest io requests that could overlap in time. Use a Ring for AsyncCommands. Free Desktop Bugzilla: 42463 Related FD: 41622 common/spice_common.h: red_printf_debug: fix wrong sign 2011-11-02 Yonit Halperin Release 0.9.2 client: support semi-seamless migration between spice servers with different protocols. It can't actually happen right now, since switch-host migration scheme will take place if the src/target server has protocol 1. (cherry picked from commit 4b2bf4d88c253502003aa5e4b93a045742eec9b4 branch 0.8) client: display channel - destroy all surfaces on disconnect Fix not destroying surfaces and other data (e.g., streams) upon disconnection. (cherry picked from commit 010b22cd771b7e81363b4b6521e4265b093fcd25 branch 0.8) client: display channel migration (cherry picked from commit cad3c585444f940f60c12789f4174f2d32bec70f branch 0.8) Conflicts: client/display_channel.cpp client: playback/record channels: implement on_disconnect (cherry picked from commit d3ed9d5e9d52ddcadcb3c8c77dd827b50071d813 branch 0.8) client: main channel migration: do partial cleanup when switching hosts Implement on_disconnect_mig_src and on_connect_mig_target in order to avoid unnecessary cleanups done in on_(disconnet|connect). In addition, do not request guest display settings changes after migration. (cherry picked from commit f91d202eb3bf631cf5e70277d1aabffec7da9393 branch 0.8) client: handle SPICE_MSG_MAIN_MIGRATE_END (1) disconnect all channels from the migration src (2) after all channels are disconnected, clean global resources (3) send SPICE_MSGC_MAIN_MIGRATE_END to migration target (4) wait for SPICE_MSG_MAIN_INIT (4) switch all channels to migration target (cherry picked from commit 510a4ff7c4f188fe6d0fb12198b8f9fdb74b9a2d branch 0.8) Conflicts: client/red_channel.h client: handle SpiceMsgMainMigrationBegin (semi-seamless migration) RHBZ 725009, 738270 (cherry picked from commit 31ed2519a752b7332ed40d0d7ab02e938c0e65cb branch 0.8) Conflicts: client/red_client.cpp client: rewrite surfaces cache use std::map instead of a specific template (CHash). There is no need for special template. Moreover, using std::map will allow easy iteration over the surfaces. (cherry picked from commit fcb3b4ce5231218bcf949da4270bd85a2cfb3535 branch 0.8) Conflicts: client/display_channel.cpp server: turn spice_server_migrate_start into a valid call We will add a qemu call to spice_server_migrate_start when migration starts. For now, it does nothing, but we may need this notification in the future. (cherry picked from commit b8213167717979e6f2fb52646e43eb458634e6a1 branch 0.8) server: handling semi-seamless migration in the target side (1) not sending anything to a migrated client till we recieve SPICE_MSGC_MIGRATE_END (2) start a new client migration (handle client_migrate_info) only after SPICE_MSGC_MIGRATE_END from the previous migration was received for this client (3) use the correct ticket Note: we assume the same channles are linked before and ater migration. i.e., SPICE_MSGC_MAIN_ATTACH_CHANNELS is not sent from the clients. server: move the linking of channels to a separate routine server: handle spice_server_migrate_end If the migration has completed successfully: (1) send MSG_MAIN_MIGRATE_END to the clients that are connected to the target (2) send MSG_MAIN_SWITCH_HOST to all the other clients If the migration failed, send MSG_MAIN_MIGRATE_CANCEL to clients that are connected to the target. (cherry picked from commit 4b82580fc36228af13db4ac3c403753d6b5c40b5 branch 0.8; Was modified to support multiple clients, and the separation of main_channel from reds) Conflicts: server/reds.c spice.proto: add SPICE_MSG_MAIN_MIGRATE_END & SPICE_MSGC_MAIN_MIGRATE_END (cherry picked from commit cfbd07710562e522179ae5a7085a789489a821bb branch 0.8) server,proto: tell the clients to connect to the migration target before migraton starts (1) send SPICE_MSG_MAIN_MIGRATE_BEGIN upon spice_server_migrate_connect (to all the clients that support it) (2) wait for SPICE_MSGC_MAIN_MIGRATE_(CONNECTED|CONNECT_ERROR) from all the relevant clients, or a timeout, in order to complete client_migrate_info monitor command (cherry picked from commit 5560c56ef05c74da5e0e0825dc1f134019593cad branch 0.8; Was modified to support the separation of main channel from reds, and multiple clients) Conflicts: server/reds.c configure: spice-protocol >= 0.9.1 (semi-seamless migration protocol) (cherry picked from commit 55ccc022ec9829523ebe36fdf0ec7c593ce76c22 branch 0.8) Conflicts: configure.ac server: handle migration interface addition (cherry picked from commit 3ac0075cdac8fa42de47a7882022795e96cb1fee branch 0.8) Conflicts: server/reds.h server/spice.h: semi-seamless migration interface, RHBZ #738266 semi-seamless migration details: migration source side --------------------- (1) spice_server_migrate_connect (*): tell client to link to the target side - send SPICE_MSG_MAIN_MIGRATE_BEGIN. This should be called upon client_migrate_info cmd. client_migrate_info is asynchronous. (2) Complete spice_server_migrate_connect only when the client has been connected to the target - wait for SPICE_MSGC_MAIN_MIGRATE_(CONNECTED|CONNECT_ERROR) or a timeout. (3) spice_server_migrate_end: tell client migration it can switch to the target - send SPICE_MSG_MAIN_MIGRATE_END. (4) client cleans up all data related to the connection to the source and switches to the target. It sends SPICE_MSGC_MAIN_MIGRATE_END. migration target side --------------------- (1) the server identifies itself as a migraiton target since the client is linked with (connection_id != 0) (2) server doesn't start the channels' logic (channel->link) till it receives SPICE_MSGC_MAIN_MIGRATE_END from the client. * After migration starts, the target qemu is blocked and cannot accept new spice client connections. Thus, we trigger the connection to the target upon client_migrate_info command. (cherry picked from commit 6e56bea67c5648b0c81990171d4bc0cf1a402043 branch 0.8) Conflicts: server/spice.h server: set & test channel capabilities in red_channel The code for setting and testing channel capabilities was unnecessarily duplicated. Now it is in red_channel. RedsChannel was dropped from Reds; It was used only for holding the channels common capabilities, which are now held in RedChannel. 2011-10-31 Alon Levy [0.8 branch] server: add main_dispatcher add main_dispatcher, a message passing mechanism for sending messages to the main thread. The main thread is the thread that implements SpiceCoreInterface, which is assumed to be a single thread. Similar to the async operation of red_worker, a socket pair is created and used to pass messages. The messages are a fixed size to ease parsing. A single message is defined to pass a channel_event. RHBZ: 746950 FDBZ: 41858 This patch is 0.8 branch only, for the master branch there should be a better approach to share code with red_dispatcher and ready the way for later adding more threads. cherry-pick from 0.8 80caf07e09efe14c67f89a3c01501a6a39681167 Conflicts: server/reds.c 2011-10-23 Liang Guo spice-server.pc.in: move Requires to Requires.private When using pkg-config, Requires and Requires.private field list packages required by this package, but packages listed under Requires.private are not taken into account when a flag list is computed for dynamically linked executable. In the situation where each .pc file corresponds to a library, Requires.private shall be used exclusively to specify the dependencies between the libraries. 2011-10-18 Yonit Halperin server/red_worker: fix placing of ASSERT(red_channel_client_no_item_being_sent) (fdbz #41523) Call ASSERT(red_channel_client_no_item_being_sent) only if red_wait_outgoing_item/s did not timeout. 2011-10-05 Christophe Fergeau client/x11: reset screen positions in XMonitor::do_restore XMonitor::do_restore (called for example when going out of fullscreen) restore the screen resolution to its previous state, but it doesn't take care of repositioning the screen to their previous position, which is one of the advantages of using randr 1.2. Since MultyMonScreen::restore handles all of this for us, just call it to restore the monitor position/resolutions to their previous settings. Before doing any changes, MultyMonScreen::restore checks if there's something to do, so calling it once per monitor won't be an issue, the resolution/position will only be set the first time. This has the side-effect of fixing bug #693431. This bug occurs when closing the client after the client went in and out of fullscreen. MultyMonScreen::~MultyMonScreen calls MultyMonScreen::restore, which decides to change the screen positions since they were lost when going to fullscreen because XMonitor::restore didn't restore the positions. After this change, the positions will be properly restored and MultyMonScreen::restore won't be needlessly called upon client shutdown. client/x11: fix mode setting in MultyMonScreen::restore MultyMonScreen::restore changes the X11 Screen resolution, but it doesn't use MultyMonScreen::set_size. This means MultyMonScreen::_width and MultyMonScreen::_height don't get updated to reflect the new resolution settings, which could cause issues later on. Until now this was safe since the only caller of MultyMonScreen::restore was MultyMonScreen destructor. client/x11: fix typos (finde => find) 2011-09-20 Christophe Fergeau client: fix typo commnad=>command 2011-09-19 Christophe Fergeau client: don't crash when booting a Xinerama setup In a Xinerama setup, when X starts up and creates one of the secondary screens, first a non-primary surface is created on the secondary screen, and then the primary surface for this screen is created. This causes a crash when the guest uses Xinerama and the client is attached to the VM before X starts (ie while the guest is booting). This happens because DisplayChannel::create_canvas (which is called when creating a non-primary surface) assumes a screen has already been set for the DisplayChannel while this only happens upon primary surface creation. However, it uses the screen for non important stuff, so we can test if screen() is non NULL before using it. This is what is done in other parts of this file. Fixes rhbz #732423 replace warning with comment in glz_usr_free_image When running some xinerama tests, I got several glz_usr_free_image: error messages. Looking at the code, this error is reported when this function is called from a different DisplayChannelClient than the one which created the glz compressed image. When this happens, the backtrace is at glz_encoder_dictionary.c:362 0x7fff940b6670) at glz_encoder_dictionary.c:449 image_type=LZ_IMAGE_TYPE_RGB32, image_width=512, image_height=256, image_stride=2048, first_lines=0x0, num_first_lines=0, usr_image_context=0x7fff7420da40, image_head_dist=0x7fff9b2a3194) at glz_encoder_dictionary.c:570 top_down=4, lines=0x0, num_lines=0, stride=2048, io_ptr=0x7fff740ea7c0 " ZL", num_io_bytes=65536, usr_context= 0x7fff7420da40, o_enc_dict_context=0x7fff7420da60) at glz_encoder.c:255 drawable=0x7fff9b46bc08, o_comp_data=0x7fff9b2a3350) at red_worker.c:5753 0x7fff9b46bc08, can_lossy=0, o_comp_data=0x7fff9b2a3350) at red_worker.c:6211 0x7fff9b46bc08, can_lossy=0) at red_worker.c:6344 0x7fff74085c50, dpi=0x7fff7445b890, src_allowed_lossy=0) at red_worker.c:7046 0x7fff7445b890) at red_worker.c:7720 at red_worker.c:7964 at red_worker.c:8431 Since the glz dictionary is shared between all the DisplayChannelClient instances that belong to the same client, it can happen that the glz dictionary code decides to free an image from one thread while it was added from another thread (thread == DisplayChannelClient), so the error message that is printed is not an actual error. This commit removes this message and adds a comment explaining what's going on. 2011-09-15 Christophe Fergeau fix typos applicaion => application Attache => Attach Detache => Detach _layes => _layers 2011-09-05 Christophe Fergeau server: fix function prototypes Several functions in server/ were not specifying an argument list, ie they were declared as void foo(); When compiling with -Wstrict-prototypes, this leads to: test_playback.c:93:5: erreur: function declaration isn’t a prototype [-Werror=strict-prototypes] 2011-09-01 Marc-André Lureau fix bug #692833 2011-09-01 Christophe Fergeau add C++ guards to backtrace.h Without these, spice_backtrace() can't be used from the C++ client code. server: init all fields on SpiceMsgDisplayStreamCreate red_display_marshall_stream_start initializes a SpiceMsgDisplayStreamCreate structure before marshalling it and sending it on the wire. However, it never fills SpiceMsgDisplayStreamCreate::stamp which then causes a complaint from valgrind. This patch sets this value to 0, it's not used by the client so the value shouldn't matter. fix valgrind warning in test_display__stream create_test_primary_surface::test_display_base.c creates a QXLDevSurfaceCreate structure and initialize it, but doesn't set the position field. Moreover, this structure has 4 bytes of padding to the end (as shown by pahole from dwarves), so initialize the whole structure to 0 before using it. 2011-08-25 Hans de Goede Fixup NEWS entry for multiclient Release 0.9.1 fix more inverted memset parameters 2011-08-25 Christophe Fergeau fix leak in do_jpeg_encode Issue found by the Coverity scanner. HDG: Fixup don't free RGB24_line if it was not allocated by do_jpeg_encode fix memory leak in error path Issue found by the Coverity scanner fix inverted memset parameters Issue found by the Coverity scanner. 2011-08-25 Hans de Goede Rename usbredir channel code to spicevmc While discussing various things with Alon in Vancouver, it came up that having a channel which simply passes through data coming out of a qemu chardev frontend unmodified, like the usbredir channel does, can be used for a lot of other cases too. To facilitate this the usbredir channel code will be turned into a generic spicevmc channel, which is just a passthrough to the client, from the spicevmc chardev. This patch renames usbredir.c to spicevmc.c and changes the prefix of all functions / structs to match. This should make clear that the code is not usbredir specific. Some examples of why having a generic spicevmc pass through is good: 1) We could add a monitor channel, allowing access to the qemu monitor from the spice client, since the monitor is a chardev frontend we could re-use the generic spicevmc channel server code, so all that is needed to add this (server side) would be reserving a new channel id for this. 2) We could allow users to come up with new channels of their own, without requiring qemu or server modification. The idea is to allow doing something like this on the qemu startup cmdline: -chardev spicevmc,name=generic,channelid=128 To ensure these new "generic" channels cannot conflict with newly added official types, they must start at the SPICE_CHANNEL_USER_DEFINED_START value (128). These new user defined channels could then either be used with a special modified client, with client plugins (if we add support for those), or by exporting them on the client side for use by an external ap, see below. 3) We could also add support to the client to make user-defined channels end in a unix socket / pipe, allowing handling of the data by an external app, we could for example have a new spice client cmdline argument like this: --custom-channel unixsocket=/tmp/mysocket,channelid=128 This would allow for something like: $random app on guest -> virtio-serial -> spicevmc chardev -> -> spicevmc channel -> unix socket -> $random app on client 4) On hind sight this could also have been used for the smartcard stuff, with a 1 channel / reader model, rather then the current multiplexing code where we've our own multiplexing protocol wrapper over the libcacard smartcard protocol. usbredir: Merge UsbRedirState and UsbRedirChannel Now that the Channel struct is gone and the RedChannel has the same lifetime as the chardev interface there is no need to have these 2 separate. usbredir: Fix crash caused by MC changes usbredir: Ensure that our msg_rcv_buf is not used re-entrantly red_channel: Fix msg buf memleak on parser error 2011-08-25 Yonit Halperin client: setting monitors resolution before resizing screens, RHBZ #728252 fix for "client: fix endless recursion in rearrange_monitors, RHBZ #692976" 2011-08-23 Alon Levy server: add tester and todo for multiple client support server/snd_worker.c: add reference counting to SndChannel Fixes a valgrind discovered possible bug in spice-server - valgrind on test_playback saw it, didn't see it happen with qemu. The problem is that the frames buffers returned by spice_server_playback_get_buffer are part of the malloc'ed SndChannel, whose lifetime is smaller then that of SndWorker. As a result a pointer to a previously returned spice_server_playback_get_buffer could remain and be used after SndChannel has been freed because the client disconnected. server/reds: reds_client_disconnect: remove wrong check for reds_main_channel_connected The "channel->disconnecting" parameter already protects against recursion. Removed fixed TODOs. server/reds: fix reds_main_channel_connected instead of checking just for reds->main_channel check that there is at least one client as well. server: add public spice_server_get_num_clients server/snd_worker.c: add red_channel_client_destroy_dummy server/red_channel: release channel allocated message buffer handler->cb->release_msg_buf was not being called except in the error path, causing a memory leak. server/main_channel: reduce verbose agent data command by using the new SPICE_DEBUG_LEVEL. 2011-08-23 Yonit Halperin drawables count for debug server: registering RedChannel in reds, instead of Channel Merging the functionality of reds::channel, into RedChannel. In addition, cleanup and fix disconnection code: before this patch, red_dispatcher_disconnect_display_client could have been called from the red_worker thread (and it must be called only from the io thread). RedChannel holds only connected channel clients. RedClient holds all the channel clients that were created till it is destroyed (and then it destroys them as well). Note: snd_channel still doesn't use red_channel, however it creates dummy channel and channel clients, in order to register itself in reds. server/red_channel.c: a channel is connected if it holds at least one channel client Previously I changed RedChannel to hold only connected channel clients and RedClient, to hold all the channel clients as long as it is not destroyed. usbredir: multichannel has not been tested, it just compiles. server/red_channel.c inroducing client_cbs client_cbs are supposed to be called from client context (reds). This patch will be used in future patches for relacing reds::Channel with RedChannel in order to eliminate redundancy. server/red_channel.c: pack all channel callbacks to ChannelCbs 2011-08-23 Alon Levy server/red_worker: add ref counting to RedDrawable introduces ref_red_drawable and put_red_drawable (rename from free_red_drawable) RedDrawable is already references by Drawable and RedGlzDrawable, with a hack to NULL the drawable field in RedGlzDrawable to indicate RedGlzDrawable is the last reference holder. Using an explicit reference count instead. server/red_worker: add stream_count (for debug purposes) server/red_worker: validate_surface: print paniced surface_id server/red_worker: no panic on double destroy primary server/red_worker: DEBUG_CURSORS Add cursor allocation debugging code that is turned off as long as DEBUG_CURSORS is not defined. server/red_worker: on_new_display_channel_client: push ack, cleanup small cleanup patch, only functional change is sending a set ack message. server/red_worker: add cursor_channel_client_disconnect makes RED_WORKER_MESSAGE_CURSOR_DISCONNECT_CLIENT disconnect only a single client. server/red_worker: remove forced disconnect on connect 2011-08-23 Yonit Halperin server/red_worker.c: fix CursorPipeItem leak CursorPipeItems and their corresponding cursor_item were not freed when they were removed from the pipe without sending them. In addition cursor_channel_hold_pipe_item used wrong conversion to (CursorItem*) for a (CursorPipeItem*). 2011-08-23 Alon Levy server/red_worker: split cursor pipe item from cursor item Required to support multiple clients. Also changes somewhat the way we produce PIPE_ITEM_TYPE_LOCAL_CURSOR. Btw, I haven't managed to see when we actually produce such an item during my tests. Previously we had a single pipe item per CursorItem, this is impossible with two pipes, which happens when we have two clients. server/red_worker: whitespace fixes server/reds: add RedsState.allow_multiple_clients Currently set by environment variable SPICE_DEBUG_ALLOW_MC (any value means to allow multiple connections). Later will be set by spice api from qemu. server/red_channel: introduce client ring in RedChannel Also adds Drawable pipes and glz rings. main_channel and red_worker had several locations that still accessed rcc directly, so they had to be touched too, but the changes are minimal. Most changes are in red_channel: drop the single client reference in RedChannel and add a ring of channels. Things missing / not done right in red_worker: * StreamAgents are in DCC - right/wrong? * GlzDict is multiplied - multiple compressions. We still are missing: * remove the disconnect calls on new connections server/red_channel: add pipe_size helpers server/red_worker: remove more direct access to RedChannelClient.rcc 2011-08-23 Yonit Halperin server/red_worker.c: make dictionary and cache different per client There is no inter-client shared dictionary and cache yet. At this point the display channel can be used by multiple clients. You can still crash on lack of Drawables or CursorItems due to the slower clients pipe growing uncontrollably. 2011-08-23 Alon Levy server/red_worker: multiple client support - base split This patch compiles but breaks spice. Split both display and cursor channels to a client part and channel part. Introduce DisplayChannelClient, CursorChannelClient, CommonChannelClient. don't disconnect channel on client disconnect. Move all caches to the ChannelClient's. Remove reference counting of the channel. No new functionality introduced. NOTE: Introduces a crash in disconnections, a regression, resulting from incorrect thread access, that is fixed in the patch titled: "server: registering RedChannel in reds, instead of Channel" server/red_worker: cleanup server/smartcard: support multiple clients each client supplying a smartcard channel gets it's own smartcard. If there are not enough smartcards provided by the server (read: qemu) then it will be as though there are none. currently disabled - later patches that enable smartcard don't make this channel available to any but the first client. server/red_tunnel_worker: trivial multi client support s/TunnelChannel/TunnelChannelClient/ That's about it. this is probably the wrong way to do it. Not tested at all. What do we want, a separate interface per client? same interface for all clients? probably the later. This doesn't do that. Not tested, so probably doesn't even work. changes red_channel_pipe_item_is_linked to red_channel_client_pipe_item_is_linked, since tunnel channel is the only user, must be done in patch to not break compilation. server/inputs_channel: support multiple clients from server events are broadcast - leds change. The rest is client to server, so it is just passed on. server/main_channel: support multiple clients The main channel deals with connecting new clients, announcing mouse mode changes, and the agent channel. The implementation is currently done without any changes to the protocol, so everything has to be either broadcast or to a specific client. channels list - specific client mouse mode - broadcast agent - broadcast notify - broadcast (should have two modes, and use the appropriate) Notable TODOs: * migration testing * agent tokens are wrongly sent (or did I fix that? check) server/red_channel: introduce pipes functions Introduce functions to add (via producer method) the same item to multiple pipes, all for the same channel. Note: Right now there is only a single channel, but the next patches will do the per-channel breakdown to channel and channel_client before actually introducing a ring in RedChannel, this makes it easier to make smaller changes - the channel->rcc link will exist until removed in the ring introducing patch. server/red_channel: ignore error if already shutdown on red_channel_peer_on_incoming_error, if we are already shutdown, do not call the channel's error handler. Since the channel has been shutdown, we assume this is a second or later error, and handling has already occured. server/main_channel: move connection_id from reds Expose additional api to find a client given a connection_id. The connection_id is first set when the first channel connects, which is the main channel. It could also be kept in the RedClient instead, not sure. TODO: multiple todo's added for multiclient handling. I don't remember why I wrote them exactly, and besides if I did any migration tests. So: TODO. server/main_channel: move ping here from reds. cleanup only. Note that the ping function is half used since the opt parameter stopped being called with anything but NULL, should be returned at some point, specifically when we drop the 250kbyte ping on start and do a continuous check for latency and bandwidth. See: 81945d897 - server: add new vd interface QTerm2Interface, Yaniv Kamay introducing the usage of ping with a non NULL opt 3f7ea8e7a - zap qterm interfaces, Gerd Hoffman removing it server/main_channel: move latency and bitrate to channel client They were globals before. This introduces api for other channels to query the low bandwidth status. The queries themselves are still done from the wrong context (channel and not channel client) but that's because the decoupling of channel and channel client will be done in the following patches. Note that snd_worker.c got two copied function declarations that belong to main_channel.h but can't be easily dragged into snd_worker.c since it still uses it's own RedChannel struct. server/reds: add concept of secondary channels Secondary channels are those that don't support multiple clients. The support added in this patch just doesn't let the second or more connected client receive the unsupported channels in the channels list sent by the server to the client. This doesn't handle the situation where: client A connects (gets all channels) client B connects (gets supported multiple client channels) client A disconnects (Suboptimal 1: B doesn't get new channels at this point) client C connects (Suboptimal 2: C doesn't get the full list of channels, but the partial one) Specifically the channels that only support a single client are: sound (both playback and record channels) smartcard tunnel server: Add RedClient That means RedClient tracks a ring of channels. Right now there will be only a single client because of the disconnection mechanism - whenever a new client comes we disconnect all existing clients. But this patch adds already a ring of clients to reds.c (stored in RedServer). There is a known problem handling many connections and disconnections at the same time, trigerrable easily by the following script: export NEW_DISPLAY=:3.0 Xephyr $NEW_DISPLAY -noreset & for ((i = 0 ; i < 5; ++i)); do for ((j = 0 ; j < 10; ++j)); do DISPLAY=$NEW_DISPLAY c_win7x86_qxl_tests & done sleep 2; done I fixed a few of the problems resulting from this in the same patch. This required already introducing a few other changes: * make sure all removal of channels happens in the main thread, for that two additional dispatcher calls are added to remove a specific channel client (RED_WORKER_MESSAGE_CURSOR_DISCONNECT_CLIENT and RED_WORKER_MESSAGE_DISPLAY_DISCONNECT_CLIENT). * change some asserts in input channel. * make main channel disconnect not recursive * introduce disconnect call back to red_channel_create_parser The remaining abort is from a double free in the main channel, still can't find it (doesn't happen when running under valgrind - probably due to the slowness resulting from that), but is easy to see when running under gdb. server/main_channel+reds: make main_channel_init return MainChannelClient This makes it easier to introduce RedClient in the next patch. server/red_worker: release PIPE_ITEM_TYPE_VERB in display channel We send a SPICE_MSG_DISPLAY_MARK verb. server/red_client: clear pipe on disconnect server/red_channel: workaround for fast client disconnect bug (TODO - real fix) server/main_channel: use MainChannel in sig use MainChannel* instead of Channel* for a many functions in main_channel.h (affects main_channel.c and reds.c). some one liner fixes are hidden in here too. server: move pipe from RedChannel to RedChannelClient Another cleanup patch, no change to behavior (still one client, and it disconnects previous client if any). The implementation for multiple client is straightforward: the pipe remains per (channel,client) pair, so it needs to move from the RedChannel that to RedChannelClient. Implementation using a single pipe with multiple consumers (to reflect different latencies) doesn't fit well with pipe rewriting that is used by the display channel. Additionally this approach is much simpler to verify. Lastly it doesn't add considerable overhead (but see the display channel changes in a later patch for a real place to rethink). This patch is just technical, changing signatures to reflect the first argument (oop style) so red_channel becomes red_channel_client. Some places may seem odd but they should be fixed with later comits where the channels grow to support multiple clients. Sound (playback/record) channels are the only ones not touched - this is consistent with previous patches, since they have been left out of the RedChannel refactoring. That is left as future work. (note that they don't use a pipe, which was the reason for not refactoring). server/red_worker: introduce {display,cursor}_is_connected Instead of checking for worker->{display,cursor}_channel directly. server/red_channel (all): introduce RedChannelClient This commit adds a RedChannelClient that now owns the stream connection, but still doesn't own the pipe. There is only a single RCC per RC right now (and RC still means RedChannel, RedClient will be introduced later). All internal api changes are in server/red_channel.h, hence the need to update all channels. red_worker.c is affected the most because it makes use of direct access to some of RedChannel still. API changes: 1. red_channel_client_create added. rec_channel_create -> (red_channel_create, red_channel_client_create) 2. two way connection: rcc->channel, channel->rcc (later channel will hold a list, and there will be a RedClient to hold the list of channels per client) 3. seperation of channel disconnect and channel_client_disconnect TODO: usbredir added untested. server/red_worker: drop red_pipe_add_tail, use red_channel_pipe_add_tail The only difference between them being that the later also does a push. I don't believe that to be a problem, but if it does I can always introduce a push'less version. server/red_channel: renames to use _proc postfix consistently rename types - we use _proc suffix mostly to indicate function pointer types, use it for some function pointers that were missing it. s/channel_handle_migrate_flush_mark/channel_handle_migrate_flush_mark_proc/ s/channel_handle_migrate_data_get_serial/channel_handle_migrate_data_get_serial_proc/ s/channel_handle_migrate_data/channel_handle_migrate_data_proc/ spice.proto: add comment for origin of STYLED and START_WITH_GAP server/red_worker: explicitly include unistd and errno common: introduce red_printf_debug server/tests/test_playback: correctly use spice_server_playback_get_buffer and spice_server_playback_put_samples. The former retrieves a buffer from a free list with spice_server_playback_get_buffer, and should be used once via spice_server_playback_put_samples. The tester previously reused the same buffer a number of times. server/tests/basic_event_loop: multiple fixes reuse common/ring.h ignore SIGPIPE fix handling of removed watches tests/migrate.py: add --vdagent Adds the required options to provide a vdagent to the guest in both source and target qemu instances. This will be the last update of the in spice git tests directory, I've moved those tests to the repository spice-tests. The longer term goal remains autotest integration, but since this test (and some minor others for qemu) need a home it is: http://cgit.freedesktop.org/~alon/spice-tests/ (I'm reluctant to put it under spice/ because of my wish to go to autotest, but still, there they are. Nothing as permanent as the temporary). Independent (of external modules, i.e. qemu) tests (server/tests) should remain in tree. 2011-08-23 Yonit Halperin server/red_worker.c: fix - locking the wrong mutex when releasing glz dict 2011-08-23 Alon Levy server/tests/test_display_base: fix compile common/ring: RING_FOREACH_SAFE: use shorter version from qemu server/reds.h: explicitly include config.h server/tests/migrate.py: make executable 2011-08-17 Christophe Fergeau use Xkb to get keyboard modifier mask To be able to enable/disable keyboard leds on X11, we need to query the X server for which mask correspond to which led (NumLock, CapsLock). So far this was done using XKeysymToKeycode and iterating over X modifier mapping. Xkb provides XkbKeysymToModifiers for this purpose, and since we're using Xkb anyway, it makes more sense to use it. At some point, on my Fedora 15 box, XKeysymToKeycode was returning NoSymbol for CapsLock and NumLock leading to spicec not being able to change the keyboard leds when qemu tells it to. However, I couldn't reproduce this when I tried again :-/ fix harmless typo in InputsChannel::handle_modifiers InputsChannel::handle_modifiers converts _modifiers which is a bitflag of SPICE_KEYBOARD_MODIFIER_FLAGS_* to a Platform::*_MODIFIER bitflag, which is what Platform::set_keyboard_lock_modifiers expects. However, it's called with _modifiers, and the bitflag that this function computes is never used. Pass the computed bitflag to ::set_keyboard_lock_modifiers since _modifiers format is meaningless for ::set_keyboard_lock_modifiers. This bug was harmless because the two different set of modifier flags actually use the same values, so _modifiers and modifiers could be used interchangeably. However it's more future-proof to use the right format here. 2011-08-15 Christophe Fergeau fix 2 X11 related leaks channel: fix EVP_PKEY leak always set VDAgentDisplayConfig::depth Even if VDAgentDisplayConfig::depth will be unused if the VD_AGENT_DISPLAY_CONFIG_FLAG_SET_COLOR_DEPTH isn't set, it's better to initialize it anyway to avoid warnings from valgrind. 2011-08-10 Hans de Goede server: Add a usbredir channel 2011-08-03 Alon Levy client/red_client: fix broken switch host migration (RHBZ 727969) 3f8d7e59dbd94b1837503f37b5065698df3ffbc7 introduced a regression, after sending one attach_channels message we never send another one. Fix by resetting on disconnect. 2011-08-02 Christophe Fergeau mjpeg: add missing SPICE_BITMAP_FMT_RGBA I forgot to handle SPICE_BITMAP_FMT_RGBA when mapping from spice image formats to libjpeg-turbo colorspaces. 2011-08-02 Liang Guo Fix typo: treshold -> threshold Fix typo: seperator -> separator 2011-08-01 Christophe Fergeau mjpeg: fix libjpeg assertion After the changes to add libjpeg-turbo support to spice-server mjpeg compression code, it's relatively easy to hit an assertion from libjpeg in spice-server about "too few scanlines transferred" when the mjpeg streaming code triggers. This assertion brings down qemu, which is bad :) This is because when we first initialize the mjpeg encoder, we do: stream_width = SPICE_ALIGN(src_rect->right - src_rect->left, 2); stream_height = SPICE_ALIGN(src_rect->bottom - src_rect->top, 2); stream->mjpeg_encoder = mjpeg_encoder_new(stream_width, stream_height); and then when we iterate over the image scanlines to feed them to libjpeg, we do: const int image_height = src->bottom - src->top; const int image_width = src->right - src->left; for (i = 0; i < image_height; i++) { mjpeg_encoder_encode_scanline(...); } mjpeg_encoder_end_frame(...); When stream_height is odd, the mjpeg_encoder will be created with an height that is 1 more than the number of lines we encode. Then libjpeg asserts when we tell it we're done with the compression while it's still waiting for one more scanline. Looking through git history, this rounding seems to be an artifact from when we were using ffmpeg for the mjpeg encoding. Since spicec and spicy (the latter needs a few fixes) can handle streams with odd height/width, the best way to solve this issue is to stop rounding up the height and width of the streams we create. This even saves some bandwidth :) 2011-07-31 Alon Levy server/red_dispatcher: fix wrong resolution set for tablet when changing resolutions due to the new async code paths the surface creation command was kept by reference, and later, when the red_worker signaled completion by calling async_complete the mouse mode was updated using the reference. This caused the wrong values to be read resulting in wrong resolutions set and a non working mouse pointer. Fix this by keeping a copy of the surface creation command instead of a reference. No bz. Found in testing. 2011-07-31 Christophe Fergeau client: fix 30s timeout regression Changelog from Arnon Gilboa, patch from me: Commit eb6f55409412 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 to a Windows guest with an agent running (this won't happen with linux guests or without an agent running). 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 is to activate agent timer only if auto-conf or disable-effects. Otherwise, simply call send_main_attach_channels(). Fixes rhbz #726441 2011-07-31 Alon Levy common/backtrace.h: disable for WIN32 This also catches mingw32 which is probably fine, but at least it fixes the build on visual studio. 2011-07-28 Christophe Fergeau fix integer marshalling helpers on big endian They were trying to convert the destination pointer to an integer before trying to dereference it. The initial conversion was meant to be a cast to a pointer of the right size, not to an integer. fix typo in big endian code path uint63_t should be uint64_t 2011-07-26 Hans de Goede Bump version in server/spice,h to 0.9.1 It is a bit early to bump, since a 0.9.1 release is not happening yet, but this allows me to test if the vdagent SpiceCharInterface state callback fixes are present or not in qemu code, and thus disabling the ugly vdagent specific workaround from spice-qemu-char.c when compiling against a new enough spice-server. 2011-07-25 Hans de Goede server: Don't call vdagent chardev state callback on client (dis)connect See this long mail for the rationale for this: http://lists.freedesktop.org/archives/spice-devel/2011-July/004837.html 2011-07-23 Alon Levy Release 0.9.0 2011-07-22 Alon Levy server/smartcard: fix smartcard_channel_send_error It was sending the wrong data, the memory right after the VCSMsgHeader which was actually not where the data was. Fixed by having the header and data (VSCError, 4 bytes of the error code) embedded in the ErrorItem pipe item. 2011-07-22 Christophe Fergeau mjpeg: rename jpeg_mem_dest jpeg_mem_dest is a public symbol in libjpeg8 so using it with no prefix will cause symbol clashes. Rename it to spice_jpeg_mem_dest. mjpeg_encoder: allocate "row" on demand It's not used when we use jpeg-turbo colorspaces, so it's better to allocate it when we know we'll need it rather than always allocating it even if it won't be used. mjpeg_encoder: remove unused functions After the refactoring to optionally use libjpeg-turbo, some of the functions that mjpeg-encoder used to provide are now no longer used. This commit removes them. mjpeg_encoder: use libjpeg-turbo extra colorspaces When libjpeg-turbo is available, we can use the BGR and BGRX colorspaces that it provides to avoid extra conversions of the data we want to compress to mjpeg red_worker: use new mjpeg_encoder_encode_scanline API The main point is to move the pixel conversion code into the MjpegEncoder class to be able to make use libjpeg-turbo additional pixel formats without the reds_worker code noticing. mjpeg_encoder: add mjpeg_encoder_get_bytes_per_pixel Returns the number of bytes per pixel corresponding to the input data format. mjpeg_encoder: add mjpeg_encoder_encode_scanline This API is meant to allow us to move the pixel format conversion into MjpegEncoder. This will allow us to be able to use the additional pixel formats from libjpeg-turbo when available. red_worker: simplify red_rgb_to_24bpp prototype It takes a lot of arguments, "id" is unused, "frame" and "frame_size" can be obtained from the "stream" argument, so can get rid of 3 arguments to make things more readable. mjpeg_encoder: rework output buffer allocation When encoding a frame, red_worker passes an allocated buffer to libjpeg where it should encode the frame. When it fails, a new bigger buffer is allocated and the encoding is restarted from scratch. However, it's possible to use libjpeg to realloc this buffer if it gets too small during the encoding process. Make use of this feature, especially since it will make it easier to encore one line at a time instead of a full frame in subsequent commits. red_worker: factor pixel conversion code When encoding to mjpeg, the on screen data have to be converted to 24bpp RGB since that's the format that libjpeg expects. Factor as much code as possible for the 3 formats we handle. set version number to 0.9.0 fix make distcheck configure.ac: fix pyparsing check 2>&1 was typo'ed 2&>1 which caused an empty '1' file to be created when running this test. add SASL and smartcard to distcheck flags client: don't die if initial agent timeout triggers When the client connects to a spice VM, if an agent is detected, there will be a few messages exchanged to exchange capabilities, display resolutions, ... This exchange has a timeout in case something goes wrong. However, when it fires, the client dies. This commit changes this and lets the client connects to the guest when the timeout happens. rhbz #673973 client: only send one SPICE_MSGC_MAIN_ATTACH_CHANNELS messages 492f7a9b fixed unwanted timeouts during initial client startup, but it also caused a bad regression when connecting to RHEL6+agent guests: the SPICE_MSGS_MAIN_ATTACH_CHANNELS message was sent multiple times, once in RedClient::handle_init, then once again in RedClient::on_agent_announce_capabilities (which can even be triggered multiple times). Sending this message multiple times is a big NO and causes the server to close the client connection, and the client to die. Add a _msg_attach_message_sent boolean to make sure we only send this message once. rhbz #712938 client: split overlong option descriptions 2011-07-21 Hans de Goede 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 . hansg: Note this is commit 443994ba from the 0.8 branch, which I did not forward port back then because it seemed unnecessary on master, but it turns out that the (wrong) check was just hidden in another place on master. 2011-07-21 Yonit Halperin client: fix endless recursion in rearrange_monitors, RHBZ #692976 The endless recursion happens due to Application::prepare_monitors calling RedScreen::resize calling Application::rearrange_monitors calling Application::prepare_monitors I changed RedScreen::resize not to call rearrange_monitors. Instead, the monitor should be configured correctly from Application, before calling resize. In addition, I made some cleanups to allow reusing rearrange_monitors code. 2011-07-21 Hans de Goede spicec: Make loglevel configurable through the environment Having a loglevel variable is much more useful if we can actually change its value without a recompile. Use a SPICEC_LOG_LEVEL environment variable so we can do this from the spice xpi / activex too (by setting the environment variable before starting the browser). 2011-07-20 Yonit Halperin server/red_worker: send surface images to client on-demand after S3/4 wakeup When surfaces are being reloaded to the worker, we will send them to the client only if and when it needs them. 2011-07-20 Alon Levy server/spice.h: bump QXL_MINOR because of QXLWorker and QXLInterface changes server: add QXLWorker.flush_surfaces_async for S3/S4 support This does the following, all to remove any referenced memory on the pci bars: flush_all_qxl_commands(worker); flush_all_surfaces(worker); red_wait_outgoing_item((RedChannel *)worker->display_channel); red_wait_outgoing_item((RedChannel *)worker->cursor_channel); The added api is specifically async, i.e. it calls async_complete when done. server: add QXLInterface::update_area_complete callback when update_area_async is called update_area_complete will be called with the surfaces dirty rectangle list. server/red_worker: handle_dev_input: reuse write_ready introduced for async server: add async io support The new _ASYNC io's in qxl_dev listed at the end get six new api functions, and an additional callback function "async_complete". When the async version of a specific io is used, completion is notified by calling async_complete, and no READY message is written or expected by the dispatcher. update_area has been changed to push QXLRects to the worker thread, where the conversion to SpiceRect takes place. A cookie has been added to each async call to QXLWorker, and is passed back via async_complete. Added api: QXLWorker: update_area_async add_memslot_async destroy_surfaces_async destroy_primary_surface_async create_primary_surface_async destroy_surface_wait_async QXLInterface: async_complete bump required spice-protocol to 0.8.1 for qxl_dev async and s3 updates 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. server: spice-server.syms: move sasl symbols to 0.8.2 server/red_worker: remove print on handle_dev_destroy_surfaces server/red_worker: *_release_item: less frequent debug messages server/tests: test_util.h: fix double ASSERT definition 2011-07-19 Alon Levy common: add backtrace via gstack or glibc backtrace Add a backtrace printing function copied from xserver os/backtrace.c that uses gstack, and if that isn't found then glibc's backtrace. Used in ASSERT, tested on F15. 2011-07-19 Gerd Hoffmann 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. 2011-07-19 Christophe Fergeau remove unused function client: add missing "," in option list In commit 44073d1b38e2 - client: improve WAN option description one "," was missing at the end of the line. Since the next argument was a string too, gcc silently concatenated them, and thanks to C++ polymorphic functions, the compiler didn't complain about the missing argument, so it went unnoticed. The effects are pretty bad though, since it prevents spicec from running because it thinks command line parsing fails. 2011-07-18 Christophe Fergeau 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-18 Uri Lublin client: rename connect_unsecure to connect_to_peer Both connect_secure() and connect_unsecure() call connect_to_peer(). Prior to this commit spicec.log reported all connections as unsecure, as connect_secure() called connect_unsecure() to make the connection. This fixes RH bug #653545 2011-07-18 Christophe Fergeau client: don't crash when agent is missing WAN support 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. 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. This commit fixes this in 2 places: - 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 This fixes RH bug #712938 client: improve WAN option description The WAN options (--color-depth and --disable-effects) need support from the guest agent to be working. Currently they are only supported on Windows. While I don't want to explicitly mention Windows in --help output, we can hint that it won't work with all guests in --help. This fixes RH bug #712941 x11: don't return freed memory from get_clipboard There is a double free in client/x11/platform.cpp. In get_selection(), in the exit: case with ret_val == -1 and data != NULL, *data_ret (which is returned to the caller) has already been assigned "data", so it will be pointing to freed memory when "data" is XFree'd'. Then in handle_selection_notify, get_selection_free is called on this pointer, which causes a double free. When the length of the read data = 0, set the returned value to NULL, this way subsequent free attempts will be a noop. Fixes RH bug #710461 client: match delete[] with new[] vinfo in x11/platform.cpp is allocated using new[] so it needs to be freed with delete[] client: s/recive/receive 2011-07-12 Yonit Halperin 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. 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-06 Alon Levy server: fix segfault if no migrate_info provided qemu calls spice_server_migrate_switch even if it didn't do a spice_server_migrate_info first. Fix the resulting error by not pushing a switch host tag to the pipe in this case, and add a check anyway in the marshalling code just in case. 2011-07-05 Yonit Halperin server: cursor_channel: releasing pipe items resources when the pipe is cleared (on disconnect) same as commit 74a9d10af96f4d7c8c1b1d7fca124a8df9180787 for cursor channel server: display_channel: releasing pipe items resources when the pipe is cleared (on disconnect) fixes "display_channel_release_item: panic: invalid item type" Before changing the red_worker to use the red_channel interface, there was a devoted red_pipe_clear routine for the display channel and cursor channel. However, clearing the pipe in red_channel, uses the release_item callback the worker provided. This callback has handled only resources that need to be released after the pipe item was enqueued from the pipe, and only for pipe items that were set in red_channel_init_send_data. This fix changes the display channel release_item callback to handle all types of pipe items, and also handles differently pushed and non-pushed pipe items. server: not reading command rings before RED_WORKER_MESSAGE_START, RHBZ #718713 On migration, destroy_surfaces is called from qxl (qxl_hard_reset), before the device was loaded (on destination). handle_dev_destroy_surfaces led to red_process_commands, which read the qxl command ring (which appeared to be not empty), and then when processing the command it accessed unmapped memory. 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 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. 2011-07-05 Alon Levy tests/migrate: update to use argparse and run spicy by default Most helpful change is that it prints help if you do --help. It can take --image parameter, and --client parameter, defaults to spicy. Incidentally, spicy switch host seems broken - if you run with --client spicec (assuming spicec is in the PATH), it works fine, but using the default spicy (or --client spicy) it fails after a single switch. server/tests/basic_event_loop: strange assert failure; fix server/smartcard: register channel only when hardware is available 2011-06-29 Alon Levy Revert "server/smartcard: don't register the channel if no hardware emulated" This reverts commit 456ff9f8d5d27ac763e89e67a100661084695dc5. That patch just disabled the smartcard channel completely because the check was done *before* the initialization of the qemu smartcard devices, not after. 2011-06-28 Christophe Fergeau red_worker: remove 2 empty functions red_worker was using some share/unshare stream_buf functions whose body is empty. This commit removes them and their use. 2011-06-23 Alon Levy server/smartcard: don't register the channel if no hardware emulated 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-06-22 Christophe Fergeau don't #include config.h in generated header files 7e30572ab adds a #include to the beginning of generated files. It also does this for generated headers and enums files, which is not wanted, especially if it's an installed file. This commit only adds this include for the non-header non-enum case (hopefully, enums are only generated for use in a .h file). 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. add check for pyparsing Check both in configure.ac (after checking if we need to rebuild the marshalling files) and in the python script using pyparsing (for people modifying .proto files in tarballs) 2011-06-22 Marc-André Lureau sndworker: check the caps before sending volume messages sndworker: add AudioVolume/AudioMute messages These messages allow the guest to send the audio device volume to the client. It uses an arbitrary scale of 16bits, which works good enough for now. Save VolumeState in {Playback,Record}State, so that we can send the current volume on channel connection. Note about future improvements: - add exact dB support - add client to guest volume change Updated since v2: - bumped record and playback interface minor version to allow conditional compilation Updated since v1: - sync record volume on connection too 2011-06-21 Marc-André Lureau python: remove c-ism trailing ; codegen: typedef the protocol enums Commit 9d5ef9beeca722b2ceff7d15aaa3aaaaf07ecfbf in spice-protocol introduced a typedef manually in the generated enums.h header. This patch adds them automatically to all enums during enums.h generation. 2011-06-14 Yonit Halperin client: fix for redundant shift+f11 RHBZ #674532 After shift+F11, both in Windows 7 and xp clients, WM_KEYUP events were missing for SHIFT and F11. For F11 it was less important since unpress_all was preformed for all keys. However, we perform sync for all the keyboard modifiers and the GetKeyboardState returns "down" for shift. In windows7 client, we sometimes received afterwards a F11 KEYDOWN event repetition, and this caused SHIFT+F11 to be called again. Not performing hiding of the windows while changing client resolutions, solved the problem of missing events, and I don't see any difference in how spice looks while toggling to full screen. Using GetAsyncKeyState, returns "UP" for shift in windows 7, and helps avoid performing shift+f11 again, if there is an F11 repetition before we receive the KEYUP event for shift. 2011-05-30 Arnon Gilboa client/windows: enable image randomization (ASLR) rhbz#701111 Enable image randomized base address, hindering some types of security attacks by making it more difficult for an attacker to predict target addresses. client/windows: remove slash from x64 build dir otherwise x64 is built in root if REDC_BUILD_DIR is not defined 2011-05-24 Alon Levy server/smartcard: fix use after free 2011-05-22 Arnon Gilboa client/windows: remove precompiled header for common.h (fix broken windows debug build) -Release currently doesn't use precompiled headers at all -Debug is broken since common/*.c files don't include common.h -PCH can be enabled for all but specifically-chosen c-files common: add WIN64 ifdef for spice_bit_find_msb (fix broken windows x64 build) inline __asm is not supported in x64, so use the naive implementation until x64 asm implemented. 2011-05-19 Yonit Halperin client: fix flipped video in Linux guest on windows client, RHBZ #667689 Video streams from Linux guests are oriented top-down, where gdi_canvas_put_image always received display context for down-top oriented bitmap. I fixed create_bitmap to consider the stream orientation. 2011-05-12 Arnon Gilboa common: use INLINE instead of inline needed for spice/common files used by the client, server & qxl driver. in windows _inline works for both c/c++, while inline is c++ only. compiling the client with mixed c/c++ code required this define. client/windows: undef SIZE_MAX in stdint.h eliminating redefinition warning common: fix ssl_verify windows build errors client/windows: add common\ssl_verify.c/h to project disable WarnAsError, due to c/c++ warnings client/windows: inc version to 0,9,0,0 client/windows: init PACKAGE_VERSION in windows, we set PACKAGE_VERSION to the binary version since we don't have config.h as generated by linux configure 2011-05-12 Alon Levy client: fix return code when missing host 2011-05-09 Alon Levy server/red_worker: stat_now cleanup static, remove inline, add (void), and empty line after function variables. server/red_worker: fix typo (lats_send_time) server/tests: show port to connect to 2011-05-08 Marc-André Lureau server: bump SPICE_SERVER_VERSION to 0.9.0 SASL functions will be released with 0.9.0 2011-05-05 Zeeshan Ali (Khattak) server: Unset executable bit of red_tunnel_worker.h 2011-05-03 Marc-André Lureau build: fix gettimeofday warning CC test_playback.o test_playback.c: In function ‘playback_timer_cb’: test_playback.c:56:5: warning: implicit declaration of function ‘gettimeofday’ client: make use of ssl_verify.c Fixed since v1: - don't include C code, rather use the common lib - add missing spice_openssl_verify_free() call - keep the extra-parsing of subject for error reporting common: add ssl_verify.c common code Code adapter from RedPeer::ssl_verify_callback() and used by spice-gtk. Since v1: - fixed Makefile.am - added config.h include - autoconf alloca added in patch series - moved int escape inside for loop - added a failed case when missing assignment - replaced strlen () by -1 - skip spaces after comma - c++ guards I didn't use bool, because openSSL uses int, and it is more future proof for error reporting. common: add ring_get_length() for debugging purposes Please notice it has a "static" modifier, like the rest of the inlined functions in ring.h, so it won't warn if it isn't used. common: mem.h add alloca definition We don't support the autoconf ALLOCA/C_ALLOC fallback. If one day, someone cares for a weird platform, he can fix it. common: spice_memdup could accept NULL (this patch is not to solve a crash fix, but to align with glib API) common: add windows.h where required, make gdi_handlers static This patch has not been verified with VS/brew. It should be safe hopefully. Compilation is fine with mingw32/spice-gtk. build: require c99 Because we use c99: stdbool.h, inttypes.h, bool, variadic macros, // comments, ... 2011-05-03 Christophe Fergeau move get_time_stamp to main_channel.c There is only one user of get_time_stamp from spice_common.h so it's not really useful to keep it there. use standard do { } while (0) for spice_common.h macros move WARN and WARN_ONCE to spice_common.h common: use PANIC from spice_common.h common,server: use ASSERT from spice_common.h spice_common.h provides an ASSERT macro, no need to duplicate it in many places. For now client/debug.h keeps its own copy since debug.h and spice_common.h have clashes on other macros which are trickier to unify. server: use gcc builtin for atomic get/set bit client: remove unused mb() macro common: don't duplicate find_msb implementation remove void * arithmetic With -Wpointer-arith, gcc complains about void pointer arithmetic. This is not a big deal with gcc, but could be with other compilers, so it's better to cast to char */uint8_t * before doing the arithmetic on such pointers. add missing static configure.ac: remove setting default C(XX)FLAGS automake/autoconf already set them for us to -g -O2 if there are no flags defined. win32: remove obsolete preprocessor #defines SW_CANVAS_NO_CHUNKS isn't used anywhere but in this file. SW_CANVAS_CACHE is now defined directly in the files where it's needed so we no longer need it in the .vcproj file. add comment to beginning of autogenerated files s/USE_OGL/USE_OPENGL This is more explicit about what it does, and not much longer use AC_DEFINE instead of hardcoding preprocessor flags Now that all source files include config.h, we can use AC_DEFINE to enable/disable optional features (opengl, cegui). This is cleaner than directly appending -Dxxx directives to the preprocessor flags. This also guarantees that everything will be appropriately rebuilt when using the same source tree to build first with opengl support and then without (the config.h timestamp will change, triggering a rebuild of the files including it) add config.h to autogenerated files too Modify the python (de)marshaller generator to add #include at the beginning of the C files it generates add #include to all source files 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 code 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. configure.ac: remove unused AC_SUBST autotools: refactor the whole build machinery 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. 2011-05-02 Christophe Fergeau add missing "LGPLv2.1 or later" header to source files common: don't try to redefine PANIC if it already exists canvas_base.c tries to define PANIC, but it might already be set if eg client/debug.h has been included before. All the other macros in this file are guarded by #ifndef, this commit adds the missing #ifndef to PANIC. Note that this is just a bandaid, ideally common/ would contain a logging frameword, and these macros would only be defined once instead of being defined in several places. server: s/desable/disable This fixes a typo in some function names, there should be no functional change. 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. server: remove extra arg in reds_on_main_agent_start call client: remove c++ wrappers client/ contains several .cpp file which only #include a .c file of the same name. This is unusual and seems to only be done to get C++ name mangling on the symbols defined in the C file. Now that all headers files in common/ use extern "C", these wrappers are no longer useful. common: add missing header guards to gl_canvas.h common: add extern "C" guards to headers Since some spice C++ code is using code from common/, the C functions need to be marked as such for the C++ compiler, otherwise we'll get linkage issues. client: make building client optional configure.ac: replace tab with spaces This makes the "C++ Compiler: ...." status output nicely aligned with the other messages. configure.ac: remove unused dynamic linkage flag configure.ac defines a SPICEC_STATIC_LINKAGE_BDYNAMIC variable when --enable-static-linkage is not set, but it's never used. SPICEC_STATIC_LINKAGE_BSTATIC is used in client/, but since we are using libtool, it might be more appropriate to use 'make LDFLAGS="-all-static"' to achieve static link. configure.ac: fix use of AC_ARG_ENABLE Most uses of AC_ARG_ENABLE were buggy: - when passing --disable-xxx, configure.ac would behave as if it was passed --enable-xxx - passing --enable-xxx=foo would "leak" into the summary, ie the summary (at the end of configure) would say "xxx: foo" instead of "xxx: yes" This patch fixes these 2 issues. configure.ac: fix make dist server: use is_primary_surface 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 2011-04-26 Alon Levy spice.proto: Fill.rop_descriptor type s/uint16/ropd (10x atiti) 2011-04-18 Christophe Fergeau client: skip spaces in --host-subject This fixes fdo bug #32896: "Subject in certificates is stored in following format (values separated by comma and space): grep Subject: server-cert.pem | awk -F": " '{print $2}' O=REDHAT, CN=10.34.58.2 While spicec expects that values in host subject are separated only by comma: spicec --host-subject "O=REDHAT,CN=10.34.58.2" " In this case, ignoring spaces make it much easier to directly copy and paste the subject line from certificates. draw: remove SPICE_ADDRESS This commit removes the typedef for SPICE_ADDRESS which was no longer used. This is the last thing that was missing to close fdo bug #28984 client: add --version cmdline option to spicec This fixes freedesktop bug #33907 client: s/reqired/required in CmdLineParser client: s/AVAILIBLE/AVAILABLE in CmdLineParser It was mispelt in a CmdLineParser enum. 2011-04-08 Christophe Fergeau server/tests remove useless assignment This was detected by clang-static-analyzer. common/pixman: remove dead assignments They were detected using clang-static-analyzer. Don't initialize the variable to a value to override it with a different value a few lines after. tests: fix compilation with -Wall -Werror 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. 2011-04-08 Christophe Fergeau gl: remove unused variables gcc 4.6 warned about these. gl: use correct pixman accessor for image data Commit 774e5bd36f4 changed - dest->source.pixmap.x_image->data + + (uint8_t *)pixman_image_get_stride(dest->source.pixmap.pixman_image) + The correct accessor to use is pixman_image_get_data. Thanks to gcc 4.6 for warning about a "different size" int to pointer conversion. client: use silent generation rules in Makefile.am The server Makefile.am rules for marshallers generation are prefixed with AM_V_SILENT to integrate nicely with automake silent rules. The same AM_V_SILENT prefix isn't used in client/Makefile.am resulting in verbose output even when automake silent mode is enabled. This commit removes this verbosity. 2011-04-04 Christophe Fergeau configure.ac: remove detection of WARN_UNUSED_RESULT spice configure.ac has some code to detect if the compiler has a special attribute to tag some functions so that they generate a warning when their return value isn't checked. However, this test is broken (the gcc attribute name is "warn_unused_result", not "__warn_unused_result__" and WARN_UNUSED_RESULT is unused anyway since spice-protocol provides SPICE_GNUC_WARN_UNUSED_RESULT. Thus we can just drop that block of code from configure.ac 2011-04-04 Christophe Fergeau remove duplicated macro MIN() is already defined in spice-protocol/spice/macros.h 2011-04-04 Hans de Goede 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 . 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. 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. server: add discard all option to agent message filter server: filter all data from client 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 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. 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. 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. 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-03-24 Hans de Goede 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. 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. spice-server: Add the ability to filter agent messages 2011-03-23 Hans de Goede spicec-x11: Work around a bug in xsel Although ICCCM 2.2. Responsibilities of the Selection Owner: http://tronche.com/gui/x/icccm/sec-2.html#s-2.2 Clearly states (about selection notify events): The owner should set the specified selection, target, time, and property arguments to the values received in the SelectionRequest event. xsel sets the selection notify event target member to the incr atom when it is going to send the clipboard data incremental, rather then setting it to the UTF8_STRING atom (which was the target of the SelectionRequest). Work around this (esp as it is likely other programs may get this wrong too) and accept the incr atom as a valid target in a selection notify event. This fixes Alon's test with running: python -c "print list(range(1000))" | xsel -i -b on the client. spicec-x11: Don't crash on apps sending bad atoms as TARGETS Some apps (bad xsel, bad!) send invalid Atoms in their TARGETS property, causing spicec to exit because of an XError. This patch makes spicec survive this scenario. For more info on the xsel bug, see: https://bugzilla.redhat.com/show_bug.cgi?id=690214 2011-03-23 Christophe Fergeau common/gl: remove unused variable clang static analyzer warned that 'len' was computed but never used in glc_vertex2d. glc_stroke_line_dash has side effects so we have to call it, but we don't need to save its return value since it's not used. opengl: fix compilation When OpenGL is enabled, build fails in DisplayChannel::create_surface because Canvas *canvas is declared twice. Remove the first declaration to fix compilation. 2011-03-22 Alon Levy server/tests: add test_playback configure.ac: fix message when missing SASL lib server: use -std=c99 Finds some bugs. python_modules/codegen.py: fix indent error in an unused function client/smartcard: use proper include delemiters 2011-03-11 Hans de Goede client: Don't handle hotkeys while sticky alt is active In some cases rhev-m changes the hotkey for releasing the mouse grab to ctrl + alt. This makes it impossible to send ctrl + alt + other-key to the guest, even when using sticky alt. What happens is: -press alt until sticky alt activates -release alt (but recorded state stays pressed due to sticky alt) -press ctrl -hotkey code sees ctrl+alt pressed, releases mouse grab -mouse grab release code does an unpress all -> end of sticky state. This patch makes it possible to atleast send ctrl + alt + del (or other key) using sticky alt. Note: even with this patch it is still a bad idea to use ctrl + alt as hotkey combi. 2011-03-08 Alon Levy 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). client/smartcard: handle the --smartcard-db option 2011-03-08 Arnon Gilboa client/windows: cleanup vcproj based on updated libs using updated windows libraries: http://www.spice-space.org/download/stable/wspice-x86_08032011.zip http://www.spice-space.org/download/stable/wspice-x64_08032011.zip -remove IgnoreDefaultLibraryNames="MSVCRT.lib", since pixman is now compiled using MT threading model similar to other libraries. It used to be mistakenly compiled with MD. -downgrade freetype lib to 2.3.11-7, which is the one used/tested with CEGUI 0.6.2 -pthread lib patched (InterlockedCompareExchange), so x64 client will no longer crash on SelectClipRgn, BitBlt etc. 2011-03-03 Marc-André Lureau server/input: avoid double free() of RedChannel on disconnect 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" 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 2011-03-02 Alon Levy server/red_worker: use red_channel_pipe_item_init replaces in file red_pipe_item_init. server/red_channel: move out_bytes_counter from Outgoing to RedChannel server/red_channel: split Incoming/Outgoing to callback and state 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_*_error server/red_worker: use red_channel_is_connected server/red_channel: add red_channel_disconnect, use in red_worker replace channel_release_res in red_worker with red_channel_disconnect. server/red_channel: reset send_data.item to NULL after release server/red_worker: remove RedChannel argument from add_buf_from_info It was unused. server/red_channel: add red_channel_{,no_}item_being_sent server/red_worker: complete removal of send_data.marshaller use server/red_worker: replace _send_ functions by _marshall_ 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_pending server/red_channel: add red_channel_all_blocked server/red_worker: cursor channel: replace _send_ with _marshall_ server/red_channel (all): add red_channel_get_header 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_socket 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_buf server/tunnel: pass SpiceMarshaller reference from send 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_stream use in config_socket, this makes the stream internal to the RedChannel implementation that will change later for multiple client support. ring: add RING_FOREACH{,_SAFE,_REVERSED} server/common: introduce common/spice_common.h 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_DATA 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). server/red_channel (all): add red_channel_get_marshaller For ussage in the send_item callback. It's only valid during this time anyway (should make it return NULL in other occasions?) No more direct usage of RedChannel.send_data.marshaller by channels. server/red_worker: use red_channel_destroy server/inputs_channel: s/PIPE_ITEM_INIT/PIPE_ITEM_INPUTS_INIT/ server/red_channel: move SET_ACK to red_channel server/red_channel: add more ack api server: use red_channel_get_message_serial server/red_channel (all): makes red_channel_reset_send_data private ready the way for handling ack messages in RedChannel. server/red_worker: use red_channel server/red_channe: make hold_item take a channel arg server/red_worker: introduce red_peer_handle_outgoing and OutgoingHandler From red_channel. server/red_worker: introduce common_channel_config_socket server/red_worker: line width fix server/red_worker: don't push to NULL channel (called from device input) server/red_worker: introduce red_channel_pipe_clear No more common_release_pipe_item server/red_worker: add red_channel_push server/red_worker: add send_item server/red_worker: red_channel renames The renames are part of refactoring red_worker's RedChannel to reuse red_channel.h's RedChannel at the end. s/red_send_data/red_channel_send/ s/red_pipe_get/red_channel_pipe_get/ s/recive_data/incoming/ s/red_receive/red_channel_receive/ s/channel_handle_message/red_channel_handle_message/ s/channel_is_connected/red_channel_is_connected/ s/red_pipe_add_type/red_channel_pipe_add_type/ server/red_tunnel_worker: use message_serial setter and getter fixes breakage in --enable-tunnel compilation. 2011-03-01 Hans de Goede x11: Use _exit rather then exit on X errors (rhbz#680763) This avoids us trying to restore the original resolution when we're fullscreen and an X error happens. As restoring fullscreen is a bad idea then as this involves making more X calls, which can get us stuck (in side an XLockDisplay call for example). 2011-03-01 Uri Lublin client: exit nicely for --controller with no SPICE_XPI_SOCKET (rhbz#644292) When starting spicec with --controller, SPICE_XPI_SOCKET environment variable must be defined so spicec and the controller can be connected. 2011-03-01 Hans de Goede Fix keyb modifiers not syncing from client to client os (rhbz#679467) 2011-02-28 Marc-André Lureau 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 server: add auth mechanism selection https://bugs.freedesktop.org/show_bug.cgi?id=34795 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 server: simplify and constify sync_write() + symplify, improving style of code using it. https://bugs.freedesktop.org/show_bug.cgi?id=34795 server: pull out reds_handle_link(), for future reuse + a couple of indent, style change https://bugs.freedesktop.org/show_bug.cgi?id=34795 build: add --with-sasl Using cyrus SASL library (same as gtk-vnc/qemu). https://bugs.freedesktop.org/show_bug.cgi?id=34795 common: add SpiceBuffer - based on qemu-vnc Buffer https://bugs.freedesktop.org/show_bug.cgi?id=34795 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 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 server/reds: remove the void* ctx field https://bugs.freedesktop.org/show_bug.cgi?id=34795 server: use the new reds_stream_{read,write} https://bugs.freedesktop.org/show_bug.cgi?id=34795 2011-02-27 Marc-André Lureau server: remove cb_free, not needed anymore https://bugs.freedesktop.org/show_bug.cgi?id=34795 server: use reds_{link,stream}_free() Be carefull removing the watch before, like __release_link https://bugs.freedesktop.org/show_bug.cgi?id=34795 server: use reds_stream_remove_watch() helper https://bugs.freedesktop.org/show_bug.cgi?id=34795 server: add reds_stream_{read,write,free,remove_watch}() https://bugs.freedesktop.org/show_bug.cgi?id=34795 server: s/RedsStreamContext/RedsStream https://bugs.freedesktop.org/show_bug.cgi?id=34795 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 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. https://bugs.freedesktop.org/show_bug.cgi?id=34795 2011-02-13 Arnon Gilboa client/windows: use SPICE_PROTOCOL_DIR in project include dirs instead of ..\..\..\spice-protocol. Relative path to another git tree is a bit ugly, since it requires spice-protocol to be in a specific location. SPICE_PROTOCOL_DIR should also be used in windows qxl and vdagent instead of SPICE_COMMON_DIR, which is an old and confusing name, due to the common directory in spice git repo. 2011-02-11 Alon Levy server/tests/basic_event_loop: fix bzero warning tests/migrate.py: refactor to allow importing for later use 2011-02-11 Hans de Goede Drop static_title.bmp from windows/Makefile.am 2011-02-11 Alon Levy server/red_worker: cursor_channel_send_item: don't downcast server/red_worker: match channel_release_pipe_item_proc to red_channel server/red_worker: introduce an outgoing struct around out_bytes_counter server/red_worker: renames to add channel_ prefix and consistent sig s/disconnect_channel_proc/channel_disconnect_proc/ s/release_item_proc/channel_release_pipe_item_proc/ s/handle_message_proc/channel_handle_parsed_proc/ Adds RedChannel* channel as first parameter to hold_pipe_item_proc server/red_worker: split cursor_channel_send_item Split from cursor_channel_push server/red_worker: use red_channel begin_send_message s/red_begin_send_message/red_channel_begin_send_message/ server/red_worker: add red_channel_init_send_data Changes semantics of send to always hold/release regardless of block, like red_channel. A hold is just a reference count increment or nop. server/red_worker: split display_channel_send_item Split it out of display_channel_push. server/red_worker: extract common_release_pipe_item from red_pipe_clear server/red_worker: use red_channel pipe add versions s/red_pipe_add/red_channel_pipe_add/ s/red_pipe_add_after/red_channel_pipe_add_after/ server/red_worker: shorten some lines using alias variables server/red_worker: introduce CommonChannel with everything (almost) not in red_channel's RedChannel As a result of CommonChannel a free cb is added to EventHandler, to take care of non zero offset for embedded EventHandler. server/red_worker: use ack_data struct start of move to red_channel based channels server/red_worker: change hold_item sig, drop the void* changed to PipeItem * 2011-02-09 Alon Levy update required minimal libcacard to 0.1.2 client/smartcard: libcacard dropped ReaderAddResponse uses VSC_Error with code==VSC_SUCCESS instead. This means that the VSC_Error message is overloaded. Instead of the other option of adding a message id, since the connection is TCP so no messages may be dropped or reordered, by having each message followed by a response there is no ambiguity. Still this commit adds a queue for messages that we only have one of which outstanding at a time, i.e. send, wait for response, send the next, etc. This further simplifies the logic, while not adding much overhead since only when spicec starts up it has a situation where it needs to send two events (ReaderAdd and ATR for Card Insert). server/smartcard: don't push our own error on reader add The device already sends one. There are actually two connections going on: server to client - this is the smartcard channel, it reuses the VSC protocol. server to device - this is an internal connection using VSC too. We generally just passthrough all messages from the client to the device, and from the device to the client. We only rewrite the reader_id because the device knows about a single id (it is actually a card id), and we may manage more then one in the future. Bottom line is that there was an extra VSC_Error message reaching the client. 2011-02-07 Alon Levy client/smartcard: ignore VSC_Init server/smartcard: ignore VSC_Init from client server/smartcard: print instead of assert on bad reader_id in smartcard_char_device_on_message_from_device server/smartcard: libcacard uses network byte order, so we must too client/smartcard: s/reader_id_t/uint32_t/ (libcacard changed) server/smartcard: libcacard removed ReaderAddResponse server/smartcard: s/reader_id_t/uint32_t/ (libcacard changed) server/red_channel: style fix in red_channel_init_send_data server/red_channel: red_channel_pipe_clear: assert on NULL channel server/red_channel: add TODO server/red_channel: export red_channel_send server/red_channel: add red_channel_waiting_for_ack small inline function to have the ack window logic. server/red_channel: protect red_channel_push from NULL server/red_channel: reset pipe_size on clear (from red_worker) server/red_channel: red_channel_event: push on blocked try to push either on signal (write available) or when blocked and read signaled. From red_worker, copied for compatibility when switching later to RedChannel in red_worker. Doesn't make a lot of sense (but works), see comment in patch. server/red_channel: use red_channel_receive server/red_channel: add empty handle of SPICE_MSGC_DISCONNECTING Simply ignored in red_channel_handle_message server/red_channel: add red_channel_receive (for red_worker) server/red_channel: unstatic red_channel_pipe_clear (for red_worker) server/red_channel: unstatic red_channel_push (for red_worker) server/red_channel: two 80 column fixes server/red_channel: add public red_channel_default_peer_on_error for later use in red_worker server/red_channel: add red_channel_pipe_add_after (from red_worker) server/red_channel: make client ack window configurable from red_worker server/red_channel (tunnel): change sig of red_channel_handle_message for later usage with red_worker server/red_channel: make MAX_SEND_VEC 100 MAX_SEND_VEC was 100 for DisplayChannel's RedChannel implementation which is being replaced with RedChannel in red_channel. So changing from 50 to 100 in red_channel (make this configurble?) - effectively increased memory usage by: (100-50)*sizeof(iovec)*(num_of_channels-2) ==(arch 64bit) 50*16*6 ~ 5k Not terrible. server/red_channel: reflect SpiceDataHeader fields in handle_parsed_proc server/red_channel: add red_channel_pipe_add_push server/red_channel: add hold_item (from red_worker) hold_item called on init_send_data, matching release. This is not the behavior of red_worker - we ref++ (==hold_item) when sending the item, and --refs when releasing it, instead of only holding if the send is blocked. Note 1: Naming: hold_pipe_item is the proc name, the variable is called hold_item, this is similar to release_item/release_pipe_item naming. Note 2: All channels have empty implementation, we later use this when red_worker get's RedChannelized. server/red_channel: add out_bytes_counter (unused) client: log subject-host mismatch, and raise ssl warnings to errors configure.ac: use AC_LANG_SOURCE in AC_COMPILE_IFELSE, silence remaining warnings server/red_worker: fix used but uninitialized warning (gcc 4.6.0) 2011-01-27 Uri Lublin spice-client migration: fix minor for old migration support. For not too old spice-migration, minor is 1. For older (ancient) spice-migration, minor is 0. Affects only VM migration while a spice client is connected. 2011-01-27 Alon Levy client/windows: don't allocate console unless required client: fix broken vs2008 build client: --help should not need platform initialization separate initialization into before command line parsing and after, call later only if command line parsing succeeds (in particular, it "fails" if --help is given). 2011-01-25 Alon Levy demarshaller/marshaller fix gcc 4.6.0 python_modules/demarshal.py and marshal.py fixes for gcc 4.6.0 warning about set but unused variables. The fixes disable creating of variables mem_size when they are not used (demarshall) and declaring a src variable when the message doesn't use it (marshal). You need to touch *.proto after applying this (should add a Makefile dependency). codegen: avoid creating out if not used (fix gcc 4.6.0 warning) client: gcc 4.6.0: two more unused variable fixes client/cegui: cegui 0.6.0 gcc 4.6.0 related fix cegui doesn't include stddef required for ptrdiff_t type, we include it for it. client/glz_decoder.cpp: gcc 4.6.0 unused fixes client/display_channel: gcc 4.6.0 unused fixes common/sw_canvas: remove unused error val This is the only unused var change I'll want to revisit eventually, I'm submitting anyway since it doesn't change current behavior. I'm talking about ignoring the return value from canvas creation. Adding a print is possible but I didn't test (may be too verbose, also preferable to be a debug print if so, and we don't have that option in the code atm - probably an environment variable will do, or adding some spice_server_set_logging_level api, maybe even spice_server_set_logging_fd?) common/canvas_base.c: remove unused variables 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. 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. 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-21 Hans de Goede Update license header for server/red_parse_qxl.c This one mistakenly had a GPL header rather then an LGPL header. Drop unnecessary X11 and alsa requires from spice-server.pc 2011-01-19 Hans de Goede server: remove dep on CEGUI 2011-01-16 Alon Levy server/red_channel: fix segfault on red_channel_destroy if peer already removed server/inputs_channel: use outgoing marshaller in red_channel/RedChannel 2011-01-15 Alon Levy tests/migrate.py: add a migration test server/main_channel: use red_channel (most code is pipe send/marshall separation) server/red_channel: no need for extra loop 2011-01-13 Alon Levy server/red_channel: go marshaller for outgoing (copied from red_worker) server/reds: don't remove agent if it's not connected server/reds: protect reds_update_mouse_mode when main_channel is disconnected server/reds: don't call close on NULL channel on atexit callback server/reds: fix possible segfault when accessing vdagent from reds_update_mouse_mode after vdagent set to NULL server/reds: s/reds_push_migrate_data_item/reds_marshall_migrate_data_item/ server: split main_channel from reds 2011-01-11 Alon Levy server: remove dep on libcacard Only the client needs this, and erronously using SPICE_REQUIRES results in libcacard dep in spice-server.pc, which is then dragged into qemu when linking, beeing used instead of the builtin libcacard. 2011-01-10 Alon Levy server/tests: split test_display_no_ssl to test_display_base, add streaming test server/tests/test_display_no_ssl: add update_area, COPY_BITS to tested functions, make a queue of QXLCommandExt waiting (cursor still with production at get_command) server/tests/test_display_no_ssl: add surface create/destroy test (commented out), and square mode (default) server/tests: fix timer reset to allow setting next call during callback server/tests/test_display_no_ssl: change color every circle server/tests/test_display_no_ssl: restart notify timer server/tests: basic_event_loop: reset timer after firing it server/tests/test_display_no_ssl: disable cursor test until it works correctly server/test/test_display_no_ssl: add beginning of basic cursor item test. doesn't actually show anything on client. also, leaks. server/tests/test_display_no_ssl: make window 320x320, two colored updates, one in notify batch 2011-01-07 Alon Levy server/red_worker: use 1, not 4 when lz_encoding a top down image 2011-01-06 Alon Levy client/cmd_line_parser: fix wrong reporting of bad argument in --bla=val case We use get_opt_long, which allows non ambiguous abbreviations, but since we didn't like that we have code that checks for abbreviations and issues an error. But that code only handled separate argument and key like: --bla value and didn't handle them in the same arguemnts, like: --bla=value This patch fixes that, and gives a slightly better error report (it still contains the =value part though) 2011-01-05 Alon Levy common, canvas_get_jpeg_alpha: let top_down be any value Allow top_down flag to have any value, only ASSERT it is positive when needs to be positive and zero otherwise. Allows older server bug of sending 4 instead of 1 in top down flag to not affect newer clients (previous patch fixes server). client: CEGUI: search for CEGUI-0.6 to work in F15 (rawhide) 2011-01-05 Thomas Tyminski Fixes compilation error of Spice Client (Linux/X11) with OpenGL enabled modified: client/x11/red_window.cpp 2010-12-30 Alon Levy mingw32: refix to build on mingw.. 2010-12-30 Marc-André Lureau client inputs: stop blinking keyboard when out of focus We could introduce another boolean to prevent changes, or just reuse _active_modifiers_event = true to prevent further update. Additionaly this patch restore the keyboard state when focusing out, which is fine when dealing with full remote desktop, but should be reconsidered if/when SPICE supports remote windows managed by client window manager for instance, imho. 2010-12-30 Tiziano Mueller jpeg_boolean is a mingw32-libjpeg specific thing. Use a define check rather than a version check. 2010-12-17 Hans de Goede server: Update SPICE_SERVER_VERSION Makefiles: fix server/tests/test_util.h not being included in make dist server: Update SPICE_SERVER_VERSION 2010-12-16 Hans de Goede spicec: Remove spice-client watermark (rhbz#662450) This patch stops us from drawing the spice client watermark at the top of the virtual machine view. We have had requests through several channels to remove this as it has little added value, and is seen as annoying by some. Given that we now also have a bugzilla for this I think it is time we really remove it. spicec-x11: Let the window manager place our window the 1st time (rhbz#662407) The problem is that RedWindow::show calls the XLib MoveWindow function on the window after it has been mapped, moving it to the location in _show_pos. This is seen by the window manager as the application saying I know exactly where I want my window to be placed, don't do placing for me. Which causes the client window to always be shown at pos 0x0, even though that may not be the best location. What this patch does is: 1) It makes RedWindow::show not call MoveWindow when a window is first created normally and then shown 2) It makes RedWindow::show still call MoveWindow when: -when the window has been shown before, and was hidden for some reason (controller interface), and is now being re-shown so that it ends up being re-shown at its old position -when the window is a fullscreen window (screen.cpp always calls move on the window before showing it to set its position) -when the user switch from windowed mode -> fullscreen -> windowed mode again, to make sure that the windowed mode window is shown in the same position as before switching to fullscreen mode spicec-x11: Add a class hint to our window managet hints This helps people who want to tell their windowmanager to do something special with spicec, like make it sticky, or whatever, see: https://bugzilla.redhat.com/show_bug.cgi?id=662452#c4 spicec: Add a --title cmdline option (rhbz#662452) 2010-12-16 Gerd Hoffmann move chardevs out of experimental While we are at it: There is no reason for chardev support to stay in the experimental area, so move it out. qemu should not need the "spice-experimental.h" file. move switch-host migration out of experimental seamless stays in the experimental area. comments updates too. 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. 2010-12-15 Alon Levy server/red_worker: fix worker->drawable_count drawable_count was becoming negative. It tracks the number of items in the worker->current_list ring. It was decremented correctly, but incremented only in several cases. The cases it wasn't incremented where: red_current_add_equal found an equivalent drawable by moving the increment to where the item is added to current_list, in __current_add_drawable, the accounting remains correct. This has no affect other then correct accounting, as drawable_count isn't used for anything. 2010-12-11 Alon Levy client/smartcard: external cac card library name and version changed 2010-12-09 Gerd Hoffmann 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. 2010-12-08 Alon Levy server/tests: fix for AM_LDFLAGS introduction 2010-12-08 Gerd Hoffmann mingw32 build: disable -fvisibility test for unsupported mingw32 target v2: only disable for os_win32 (Hans) 2010-12-08 Alon Levy mingw32 build: check for CXImage, disable if not found (only on mingw32) v2: + simplify (Hans) + also report presence of cximage for mingw32 target mingw32 build: use PRIu64 instead of ll mingw32 build: python_modules/marshal: use unsigned for for_loop index variable mingw32 build: various fixes mingw32 build: fix two functions mingw32 build: add missing switch flags (nop) mingw32 build: eol fixes mingw32 build: windows/Makefile.am: double NULL definition mingw32 build: missing linked files for spicec.exe mingw32 build: remove unused, initialize uninitialized, reorder constructor initializers mingw32 build: fix assignement as condition warning mingw32 build: fixed using -1 as uninitialized value for unsigned variables mingw32 build: fix signed/unsigned warnings as errors mingw32 build: fix configure.ac typo mingw32 build: fix various warnings 2010-12-08 Gerd Hoffmann mingw32 build: fix build errors mingw32 build: disable ms compiler pragmas for gcc 2010-12-07 Gerd Hoffmann mingw32 build: add client/windows/Makefile, tweak configure build: s/HUGE/INFINITY/ build: use jpeg_boolean with more recent libjpeg versions. build: only check for x11 extensions when building for x11 platform. build: alsa is needed on linux only. 2010-12-07 Alon Levy server/tests: Makefile.am: use AM_LDFLAGS instead of LDFLAGS server/inputs: return NULL on alloc_buf request for too large message server/red_channel: error channel if alloc_msg_buf fails (returns NULL) server/inputs_channel: better protection from channel disconnection on keyboard modifiers callback server/red_channel: add red_channel_is_connected server/inputs_channel: remove unused declaration in inputs_channel.h server/inputs_channel: s/inputs_channel/g_inputs_channel/ server/inputs_channel: initialize inputs_channel to NULL server: reds/inputs_channel: move some structs to inputs_channel server: inputs_channel: use red_channel server: red_channel: add optional parser and separate incoming/outgoing error handlers for later inputs/main channel usage server: inputs_channel: s/inputs_state/inputs_channel/ server: introduce inputs_channel, split from reds.c server/reds: fix typo 2010-12-07 Arnon Gilboa spicec: do not call connect_secure when connect_unsecure fails due to protocol version mismatch (v2) If connect_unsecure failed due to protocol version mismatch, don't try to connect_secure with the same version, but retry (connect_secure or connect_unsecure) with older version. catch (...) is handled by caller at RedChannel::run(). This solves the following bug: when "new" Spice client (protocol version 2) with given secure_port connects to "old" server which is not using the same secure_port (or not using a secure_port at all), the client exits immediately. In this scenario, the client first tries to use Spice protocol version 2 to connect the unsecure port, and altough this fails due to version mismatch, it tries to connect to the secure port with the same protocol version 2, which is a wrong behavior, fails due to socket error 10061 (WSAECONNREFUSED - Connection refused) and handled mistakenly by immediate exit, instead of retrying with protocol version 1. 2010-12-07 Alon Levy client/smartcard: add files to Makefile.am for make dist smartcard: configure option --enable-smartcard smartcard: server side (not enabled yet) smartcard: client: add keyboard shortcuts for remove/insert virtual card smartcard: client side (not enabled yet) smartcard: add to spice.proto server: add spice_server_char_device_remove_interface 2010-12-06 Alon Levy server: print subtype when adding CHAR_DEVICE interfaces server: add static to spice_server_char_device_add_interface spice codegen: fix copy-o, no such variable value server: fix print text on vdagent interface addition server: add char_device.h header, use in reds.c spice-experimental.h: add multiple include protection 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-02 Alon Levy server: add char_device.h to Makefile.am for make dist 2010-11-30 Alon Levy server/tests: add test_display_no_ssl updates taken from spice vga mode updates, i.e. non cacheable, glz compressed (depends on whatever settings you apply to the server) opaque draw operations. + completed the SpiceCoreInterface implementation (timers) v1->v2: removed test_util.c (Hans) replaced mallocz with calloc (Hans) server/tests: Makefile.am fixes * don't install tests on make install * don't forget anything for make dist tarball add .gitignore for tests 2010-11-25 Hans de Goede spicec: Don't show a white screen if guest resolution does not fit fullscreen Currently when going / starting fullscreen if the guest resolution for one of the monitors is higher then that monitor on the client can handle, we show a white screen. Leaving the user stuck (unless they know the fullscreen key switch combi) with a white screen when starting the client fullscreen from the XPI. This patch changes the client to fall back to windowed mode in this case instead. 2010-11-24 Arnon Gilboa spicec: fix ASSERT to accept size == 0 which is useful when calling RedClient::on_clipboard_notify(VD_AGENT_CLIPBOARD_NONE, NULL, 0); spicec-win: add image copy-paste support -currently png & bmp -using wspice libs cximage.lib & png.lib -jpg & tiff will follow 2010-11-23 Hans de Goede spicec-x11: Fix unhandled exception: no window proc crash (rhbz#655836) When XIM + ibus is in use XIM creates an invisible window for its own purposes, we sometimes get a _GTK_LOAD_ICONTHEMES ClientMessage event on this window. Since this window was not explicitly created by spicec, it does not have a Window Context (with the event handling function for the window in question) set. This would cause spicec to throw an unhandled exception and exit. This patch replaces the exception throwing with silently ignoring ClientMessage events on Windows without a Context and logging a warning for other event types. 2010-11-22 Hans de Goede spicec-x11: Fix modifier keys getting stuck (rhbz#655048) Currently modifier keys (ctrl, alt) can get stuck when using the x11 client. To reproduce under gnome: -focus the client window without causing it to grab the keyborad (click on the title bar not the window) -press crlt + alt + right arrow to switch virtual desktop -press crlt + alt + left arrow to switch back -notice ctrl + alt are stuck pressed What is happening here is: -We get a focus out event, caused by the hotkey combi key grab, focus event notify mode == NotifyGrab, and release all keys -> good -We get another focus out event, as we really loose the focus. notify mode == NotifyWhileGrabbed, which we ignore as we already lost focus before -We get a focus in event, as the focus is returning to us, but we don't really have the focus yet, as the hotkey combi key grab is still active (ie ctrl + alt are still pressed). We now sync the vm's modifier key state with the current X-server state, telling the vm ctrl + alt are pressed. Note we do this by directly reading the X-server keyboard status, we are not getting any key press events from the X-server -> bad -We get another focus in event, as we really get the focus back, notify mode == NotifyUngrab. We ignore this one as already have gained the focus before. If we were to sync the vm modifier state here, all would be well we would no longer see the modifier keys pressed, or if we would we would get a release event when they get released (testing has shown both). The solution here is to ignore the first focus in event, and do the modifier sync on the second focus in event, or more in general to ignore focus events where notify mode == NotifyWhileGrabbed. 2010-11-17 Hans de Goede spicec-x11: Add a few missing XLockDisplay calls (rhbz#654265) The XIM functions end up waiting for a reply from the server, so they need locking around them. Idem for the XLookupString call. 2010-11-09 Hans de Goede spicec: Don't show gui when connection info is specified on the cmdline Currently when compiled with the gui enabled if you specify a host to connect to on the cmdline the gui flashes by (show_gui gets called, then the connect handler calls hide_gui as soon as the connection is made). This patch removes this ugly flashing by of the gui. spicec: Remove empty show / hide gui functions When compiling without gui support just don't call show / hide gui, rather then making them stubs, this makes it easier to follow what is going on. spicec: Fix info layer sometimes not showing Currently we are calling show_info_layer from hide_gui in application.cpp, but there are 2 cases where this does not happen: 1) When compiled without gui support hide_gui is a complete nop, so we never show the info layer when compiled without gui support 2) When run with --controller we never show the gui, and hide_gui checks if there is a gui to hide as the first thing and if not returns resulting in show_info_layer not being called, and thus the info layer not showing when launched from the xpi This patch fixes both by adding a call to show_info_layer from on_visibility_start note that on_visibility_start also calls hide_gui, so in some cases show_info_layer may be called twice, this is not a problem as show_info_layer is protected against this. 2010-11-08 Alon Levy server/reds: zap unsetting of QEMU_AUDIO_DRV gitignore: add generated_*, vim temps, pyc reds: remove needless buffer in InputsState server: tests: add basic tests with working do nothing server 2010-11-08 Arnon Gilboa spicec-win: ignore MSVCRT.lib in x86 build Same as in x64 build, for using the updated wspice-0.6.3 2010-11-05 Hans de Goede spicec: Make cegui log to /cegui.log This stops the client from dropping CEGUI.log files into the cwd all the time, and stops it from crashing when the cwd is not writable (rhbz#650253). 2010-10-28 Hans de Goede spicec-x11: Listen for selection owner window destroy / close events too These rarely happen as most apps have the decency to do a SetSelectionOwner None before exiting. But some do not, so listen for these too. 2010-10-25 Alon Levy client: add verbose link error messages 2010-10-25 Arnon Gilboa spicec-tests: add controller_test (v2) use chars for title & menu instead of wchars spicec-win: remove redundent strdup & buggy free text refered a substr of item_dup and was used after free(item_dup). no need to strdup, we can destroy the resource string. 2010-10-25 Hans de Goede controller: Make menu text utf-8 We are making all text send over the controller socket utf-8, rather then having somethings as 8 bit (hostname) and others (title, menu) unicode16, this patch completes this change by converting the menu handling. spicec-x11: Do not set _NET_WM_USER_TIME to 0 on startup Setting _NET_WM_USER_TIME to 0 means we do not want focus, not good. 2010-10-25 Arnon Gilboa spicec-win: add x64 to vcproj & sln (v2) use CEGUI for x64 as well, no need for the SUPPORT_GUI hack spicec-win: map title string from utf8 to utf16 Fix win client broken by the utf8 patch. 2010-10-24 Arnon Gilboa spicec-win: add #ifndef _WIN64 for u/intptr_t typedefs spicec-win: Replace Set/GetWindowLong to LongPtr for x64 competability 2010-10-21 Hans de Goede Remove no longer used wstring_printf functions client: Interpret the title control message as utf8 instead of unicode16 The activex browser plugin is sending unicode16 text, where as the xpi one is sending utf8 text. After discussing this on irc we've decided that utf8 is what we want to use. So the client (this patch), and the activex will be changed to expect resp. send utf8 text as the title. spicec-x11: Change source of controller socket name, fixing CVE-2010-2792 The socket name used to communicate between the xpi browser plugin and the spicec was predictable allowing a non priviliged user on the same system to create the socket before spicec does and thus intercept the messages from the xpi to the client, including login credentials. This security vulnerability has been registred with mitre as CVE-2010-2792: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-2792 This patch changes the controller code to instead read the socket name from an environment variable which gets set by the xpi before executing the spicec, making the socketname private between the client and the xpi. Note that this means that the controller will only work with an xpi which has matching changes, the changes are present in the latest version of the xpi as available as update for / with RHEL-5.5 and RHEL-6.0 . 2010-10-18 Hans de Goede Release 0.6.3 Make the gui use Application::hide_gui rather then hide_me Now that Application::hide_me actually does what the name suggests (hide the entire client, ie all client windows), the gui using it to not show the gui layer leads to the entire client disappearing when one presses close in the GUI or dismisses a GUI dialog. This patch makes the GUI code call hide_gui instead of hide_me, fixing this. Bump version to 0.6.2 Update NEWS for 0.6.2 release spicec-x11: Fix window management under KDE There were 2 issues with window management under KDE 1) When an app does its own focus management like we do, kwin expects an explicit raise for the app to get to the top, so we did have focus, but would have other windows (partially) covering the client window -> do a raise after setting focus to ourselves 2) When switching from fullscreen <-> window, we unmap and remap our window, then set focus to ourselves. kwin thinks this means we're trying to steal the focus without the user asking for it. This patch makes us set the _NET_WM_USER_TIME property on our window, this helps kwin's focus stealing code to see that we are really not stealing the focus, just responding to a user event. client: change monitor mode setting <-> fullscreen window mode setting order 1) Make the order when starting up in fullscreen mode the same as when switching from window -> fullscreen: First set the mode, then make the window fullscreen 2) Change the order when leaving fullscreen mode, first restore the original monitor mode, then make the window non fullscreen. Changing the monitor mode in X11 causes the window manager to re-arrange windows, and if this happens while compiz is busy mapping the window it gets confused and maps the window with a maxmimized size. spicec-x11: Change WmSizeHints in fullscreen mode Some window managers will ignore the fullscreen hint, unless WmSizeHints allow them to resize the window so that they can give it the size of the roo-window. This fixes fullscreen mode in compiz. spicec-x11: Add missing XLockDisplay around XRRSet* calls XRRSet* calls wait for a XReply, so add a missing XLockDisplay, this fixes a hang (due to a race so not always) when switching between windowed and fullscreen mode. client: Do not try to send display_config until we've received the agent caps Currenty, we check the agent caps in RedClient::handle_agent_connected for VD_AGENT_CAP_DISPLAY_CONFIG and if present send display_config, but at this time we have not received the caps yet, so remove this. Also the send_agent_display_config call in on_agent_announce_capabilities lacks a check for _agent_disp_config_sent, and we send the display config before announcing that we may do so by sending our own caps, which seems inpolite. 2010-10-18 Arnon Gilboa spicec: add controller Spice client controller enables external control (e.g., by XPI or ActiveX) of the client functionality. The controller protocol enables setting parameters (host, port, sport, pwd, secure channels, disabled channels, title, menus, hotkeys etc.), connecting the server, showing and hiding the client etc. The controller is based on the cross-platform named pipe. spicec: add foreign menu Spice foreign menu enables external control of the client menu. The foreignmenu protocol enables an external application to: add a submenu, set its title, clear it, add/modify/remove an item etc. Foreign menu is based on the cross-platform named pipe. 2010-10-17 Arnon Gilboa spicec-win: move named_pipe defines spicec-win: fix menu id push to free_sys_menu_id spicec: enable multiple CmdLineParser instantiations Used by controller. One instance at a time, not thread-safe. Add basename() for win32. spicec: name host param spicec: add ProcessLoop::on_start_running() spicec: extract RedScreen::update_menu() spicec: add menu id & find_sub() 2010-10-16 Hans de Goede server: remove useless agent send_tokens We are keeping track of tokens for sending agent data to the client, but the client send an initial value of ~0, and never gives us new send tokens so this is all rather useless -> remove it. Note that it is kept in the migration data struct for compatibility reasons. 2010-10-15 Hans de Goede Call read_from_vdi_port() from vdi_read_buf_release() read_from_vdi_port(), called from vdagent_char_device_wakeup() may fail to consume all data because no buffers are available in the read_bufs ring. When this happens we would fail to ever read more data from the agent on the guest as the port is throttled and stays throttled until we've consumed all data from the current buffer. This patch re-enables the call to read_from_vdi_port() from vdi_read_buf_release(), so that we will try the read again when space becomes available in the read_bufs ring. Together with another nasty hack in the linux guest virtio_console driver, where it waits for a write to be acked by the host before continuing with the next one, this can lead to a linux guest getting stuck / hang (until the write is read by the spice-server which never happens becaus of the above issues). Note that even with this patch, the guest will still gets stuck due to a bug in watch_update_mask in spice-core in qemu, which causes writing to the client to never resume once it blocked. A patch for this has been submitted to qemu. server: always call read_from_vdi_port() in a while loop read_from_vdi_port() MUST always be called in a while loop until it returns 0. This is needed because it can cause new data available events and its recursion protection causes those to get lost. Calling it until it returns 0 ensures that all data has been consumed. Example scenario where we can fail to read the available data otherwise: - server/reds.c: vdagent_char_device_wakeup get called by hw/spice-vmc.c because data has arrived from the guest, - hw/spice-vmc.c: vmc_read get calls - If the vmc_read call depletes the current buffer it calls virtio_serial_throttle_port(&svc->port, false) - This causes vmc_have_data to get called, which if in the mean time another buffer has arrived causes vdagent_char_device_wakeup to gets called again (so recursively) - vdagent_char_device_wakeup is protected against recursive calling and ignores the second call (a nasty hack) - if no other data arrives, the arrived data will not get read Don't crash when a client disconnects while there were pending writes spicec-x11: add support for image copy and paste 2010-10-12 Alexander Larsson Replace epoll with select in X client The use of epoll in the client is totally overkill in terms of scalability, and its a problem for portability. The OSX port converts this to use select, but keeps some of the old complexities in the code. This new patch makes it simpler and look much more like the windows code. 2010-10-12 Gerd Hoffmann server: add channel notifications. This patch adds a channel event callback to the spice core interface. This new callback will be called for three events: (1) A new connection has been established. (2) The channel is ready (i.e. authentication is done, link message verification passed all tests, channel is ready to use). (3) Channel was disconnected. Qemu will use this to send notifications to the management app. 2010-10-11 Hans de Goede spicec-x11: Put locks around xlib calls which wait for a reply Since libX11-1.3.4 the multi-threading handling code of libX11 has been changed, see: http://cgit.freedesktop.org/xorg/lib/libX11/commit/?id=933aee1d5c53b0cc7d608011a29188b594c8d70b This causes several issues. One of them is the display inside the client not getting updated when there are no XEvents being generated, this is caused by the following part of the referenced commit message: Caveats: - If one thread is waiting for events and another thread tries to read a reply, both will hang until an event arrives. Previously, if this happened it might work sometimes, but otherwise would trigger either an assertion failure or a permanent hang. We were depending on the otherwise behavior and apparently were lucky. This can be seen by starting F14 in runlevel 3 and then doing startx and not touching the mouse / keyb afterwards. Once you move the mouse (generate an event you see the UI contents being updated but not before. Another thing both I and Alon (iirc) have seen are hangs where 2 threads are stuck in XSync waiting for a reply simultaneously. This might be related to libxcb version, according to the libX11 commit a libxcb newer then 1.6 was needed, and my system had 1.5 at the time I saw this after updating to libxcb 1.7 I can no longer reproduce. This patch tackles both problems (and is needed for the 1st one indepently of the 2nd one possibly being fixed) by adding XLockDisplay calls around all libX11 calls which wait for a reply or an event. 2010-10-11 Arnon Gilboa spice-win: handle multiple types on clipboard grab send & receive spice-win: remove clipboard_changer hack Instead of keeping a flag, we simply check wether the new owner is us or not spice-win: handle type VD_AGENT_CLIPBOARD_NONE in Platform::on_clipboard_notify() spice-win: remove windows-specific bitmap cut & paste support will wait until png comes in 2010-10-09 Hans de Goede spicec: Do not try to do accounting of pci memory Without this patch spicec reproducely hangs in GlzDecoderWindow::pre_decode_update_window(). When GlzDecoderWindow::will_overflow() returns true, GlzDecoderWindow::pre_decode_update_window(), waits for a call to GlzDecoderWindow::post_decode() to free up some memory This happens even though there still is pci memory available (otherwise the driver would not have been able to send an image to decode in the first place). The GlzDecoderWindow::post_decode() call never happens as the server is waiting for a reply to the decode of the hanging image, causing the client to hang for ever. This patch fixes this by simply removing the "attempted" pci memory accounting. As there is no need for that, as the driver already must keep track of pci memory usage. I've verified that both the old and new Xorg drivers take care of not overusing the pci memory themselves I would expect the same to be true for the windows driver. Note the calculating of the glz_window_size in red_client.cpp cannot be removed as the calculated value is send as part of the SpiceMsgcDisplayInit on connect. 2010-10-06 Hans de Goede spicec: only send display-config if the agent can handle it spicec-x11: Drop annoying useless warning Every time an events comes past where the Window is None (which happens about once every 5 minutes or so), this annoying "invalid window" message gets printed. Remove it! spicec: don't send agent messages directly from ClipboardListener callbacks ClipboardListener callbacks can run from another thread then the main channel loop thread, where agent messages are normally dispatched from. So they may not send agent messages directly, instead they should post events to the main channel loop. spicec-x11: Remove a race window in selection ownership release code Well almost remove it, it was possible that another x11 app would acquire selection ownership, and we would receive a release message from the agent before having processed the xselection ownership change event. Then we would set the selection owner to none, overriding the new owner. As the comment in the patch indicates there still is a minute window left where something similar can happen after this patch. Nothing we can do about that (I blame the libX11 selection API). spicec: Move setting of clipboard_owner to guest to platform code Atleast under x11 there is a race condition when setting the clipboard owner to guest from the RedClient code rather then doing it in Platform. After the XSetSelectionOwner() in Platform::on_clipboard_grab(), which runs from the main message loop thread, the x11 event thread can receive a SelectionRequest event from another x11 app, before the RedClient code has set the clipboard owner, which will trigger the owner != guest check in the SelectionRequest event handling code. By moving the setting of the owner in to Platform::on_clipboard_grab() it gets protected by the clipboard lock, which closes this tiny race. 2010-10-04 Hans de Goede spicec-x11: make get_clipboard_type handle the None Atom spicec-x11: protect against recursive incr properties spicec-x11: If the clipboard was large return the memory to the system spicec-x11: use malloc / free / realloc for clipboard data As we need a realloc function it is better to use malloc / free / realloc then to diy, esp. as realloc can grow the buffer without needing a memcpy. spicec-x11: Use a queue for XSelectionRequest events XSelectionRequest events must be answered in the order they were received. But for TARGETS request we can answer directly, where as other requests need to go through the agent. This causes us to handle things out of order, and this can cause us to have more then one requets outstanding with the agent, which is also not what we want. So this patch introduces a queue for XSelectionRequest events, causing us to handle them 1 at a time and always in order. spicec-x11: handle multiple types per grab And also handle many x11 targets (ie utf8 variants) to a single agent type mapping. spicec-x11: Add XFlush calls were needed Since we do not always "pump" libX11's event loop by calling XPending (we only call XPending when there is data to read from the display fd), we must always explictly flush any outstanding requests. This patch adds a whole bunch of missing XFlush calls. spicec-x11: Force processing of ownerchange event when releasing the cb Make sure we process the XFixesSetSelectionOwnerNotify event caused by us setting the clipboard owner to none, directly after setting the owner to none. Otherwise we may end up changing the clipboard owner to none, after it has already been re-owned because the XFixesSetSelectionOwnerNotify event to owner none is event is still pending when we set the new owner, and then changes the owner back to none once processed messing up our clipboard ownership state tracking. I saw this happening when doing copy twice in succession inside the guest. spicec-x11: Request targets from new clipboard owner Request targets from new clipboard owner, rather then assuming UTF-8 (not entirely complete yet, the last pieces will be in another patch). Atleast as important this code unifies the selection getting code for incr and non incr getting of selection data so that it can be used for both getting regular selection data and for getting targets selection data. This also fixes a big bug in the (I believe untested sofar) incr support code which was interpreting the contents of PropertyNotify events as XSelectionEvents rather then as XpropertyEvents which are completely differen structs! 2010-10-03 Hans de Goede spicec-x11: remove clipboard_changer hack Instead of keeping a flag, we can and should simply check wether the new owner reported in the event it us or not. Also check for the new owner being none and send a clipboard_release when that is the case (through set_clipboard_owner(owner_none)). 2010-10-02 Hans de Goede Keep track of clipboard ownership Given that all clipboard handling is async, it is possible to for example receive a request for clipboard data from the agent while the client no longer owns the clipboard (ie a VD_AGENT_CLIPBOARD_RELEASE message is in transit to the agent). Thus it is necessary to keep track of our notion of clipboard ownership and check received clipboard messages (both from other apps on the client machine and from the agent) to see if they match our notion and if not drop, or in case were a counter message is expected nack the clipboard message. Rename platform clipboard handling functions Rename the 4 platform clipboard functions which get called upon receival of an agent clipboard message to on_clipboard_* The old set_clipboard_* names were confusing as they suggest being a class property setter (like set_event_listener) rather then event handler, and set_clipboard_owner was causing a name conflict with the next patch in this series. Move checking for on demand clipboard cap closer to sending of agent messages This way the events will always get generated and other things (such as clipboard ownership administration, see the next patches) can be done in repsonse to the events, even though no message will be send. This patch also removes the !_agent_caps check from the capability checks, this is not needed as VD_AGENT_HAS_CAPABILITY checks _agent_caps_size which will be 0 when _agent_caps is NULL. 2010-10-01 Hans de Goede Respond to clipb request with an unsupported type with data with a none type Currently we send a VD_AGENT_CLIPBOARD_RELEASE when we receive a VD_AGENT_CLIPBOARD_REQUEST with a type which we do not support. This is not correct, as this means given up clipboard ownership while we may be able to answer requests with different types. The correct response is to nack the request by sending a VD_AGENT_CLIPBOARD (data) message with a type of VD_AGENT_CLIPBOARD_NONE. Change VD_AGENT_CLIPBOARD_GRAB to an array of types A clipboard owner can indicate that it can supply the data the clipboard owns in multiple formats, so make the data passed with a VD_AGENT_CLIPBOARD_GRAB message an array of types rather then a single type. Call intern_atoms() earlier We call XFixesSelectSelectionInput with the clipboard_atom, so we musr initialize the atoms before calling XFixesSelectSelectionInput. Set clipboard_event before calling send_selection_notify send_selection_notify used the clipboard_event, so set it before calling send_selection_notify. wrap XGetAtomName XGetAtomName() throws X11 errors when called on a None atom, so wrap it catching the None case. 2010-10-01 Arnon Gilboa client: support clipboard/selection-owner model (v2) -includes most of Hans' review fixes (up to the SelectionRequest comment [4]) & X11 wips sent by Hans (10x!) -use the VD_AGENT_CLIPBOARD_* types in the platform code -add ifs for VD_AGENT_CAP_CLIPBOARD_BY_DEMAND in both sides -support the GRAB/REQUEST/DATA/RELEASE verbs in both ways -pasting clipboard data is now "only-by-demand" from both sides (client and agent), whose behavior is symmetric -client and agent don't read or send the contents of the clipboard unnecessarily (e.g. copy, internal paste, repeating paste, focus change) -set client as clipboard listener instead of application -add atexit(cleanup) in win platform linux: -instead of clipboard atom selection instead of XA_PRIMARY -enable USE_XRANDR_1_2 and support clipboard in MultyMonScreen -send utf8 with no null termination, remove ++size -add xfixes in configure.ac & Makefile.am windows: -bonus: support image cut & paste, currently only on windows not done yet: -clipboards formats are still uint32_t, not mime types stores as strings -platform_win is still used, not the root window -not replaced the ugly windows CF_DIB in agent/winclient 2010-09-29 Alexander Larsson Bump version to 0.6.1 Update NEWS for release client: Avoid crash if platform_win is NULL This is a temporary fix as this will be fixed for real when the cut and paste patches land. client: Re-enable USE_XRANDR_1_2 This was disabled by mistake before. client: Don't hardcode -lrt -lrt is already included in SPICE_NONPKGCONFIG_LIBS if needed so no need to add it to the command line manually. client: Fall back to gettimeofday if clock_gettime not found client: Include config.h from common.h config.h should be availible everywhere, so move its inclusion to the top of common.h. client: Check for pthread yield function using autoconf Initialize variable to avoid compiler warning Seems the OSX gcc warns on saveRight not being initialzied. client: Include stdint.h for uint32_t client: Don't use basename for argv[0] in --help output This isn't what other apps do, and it had issues in the OSX port, so just remove this. Fix warning from OSX compiler The OSX compiler warns about uninitialized variable, so we change a bit how size is initialized. 2010-09-22 Alexander Larsson Handle surface images in DrawOpaque 2010-09-21 Alexander Larsson server: Handle self_image in localize_bitmap When drawing a drawable with a NULL src bitmap that means we should be using the previously generated self_bitmap. Not doing this causes a segfault due to accessing the NULL. server: Handle NULL image in red_update_streamable A NULL src bitmap means self_bitmap, which is not a stream, so abort. server: Use the right image size for self_bitmap The self_bitmap is the size of self_bitmap_area, not the bbox. This is especially important since we later copy the self_bitmap_area into the new bitmap, and if that is larger than bbox then we will overwrite random memory. server: Don't leak QUIC image chunks red_put_image() needs to free the chunks for QUIC images, as we allocate these when creating the image. Fix crash when resetting pixman image transform Resetting the transform is done by setting it to the identity transform, not passing in NULL. Passing in NULL causes a crash. 2010-09-20 Alexander Larsson server: Ensure we flush the release pipe after an oom We really need to flush the ring to ensure that we push something on the release ring. If we don't do this and the ring is not pushed for other reasons we will timeout in the guest driver waiting for the ring. Release more drawables on OOM We've changed how resources are released so they are now being freed continuosly, rather than on OOM, since we want to free as early possible to avoid fragmentation. So, OOM situations should be a bit less common now and signify a real memory shortage, so we should try to free up more resources. 2010-09-14 Gerd Hoffmann fix palette handling for 0.4 compat spice 0.4 guests pass 16bpp palette colors when running in a 16bpp video mode. Convert them to 32bpp. fix brush handling for 0.4 compat spice 0.4 guests pass 16bpp colors for brushes when running in a 16bpp video mode. Convert them to 32bpp. move command flags handling to the qxl parser Pass through command flags to the qxl parser, so we can hide all compat bits for spice 0.4 within the qxl parser. 2010-09-09 Hans de Goede spicec-x11: Fix going into a never ending loop upon xrandr event (#628573) (v2) When handling an xrandr event the event_listener->on_monitors_change() callback destroys and re-creates the monitor object(s) which results in the DynamicScreen or MultyMonconstructor being called, which triggers more xrandr events. This causes a never ending event handling loop making spicec hang, and eventually making the X-server crash as a backlog of events builds up and it oom's. This patches this by explictly processing the xrandr event caused by the constructor inside the constructor surrounded by the already present guard code against recursive xrandr events. 2010-09-02 Yonit Halperin server: avoid creating a stream from traces more than once for the same drawable could have caused ASSERT(!drawable->stream) in red_create_stream 2010-09-02 Alexander Larsson Add API to turn on backwards compatibility mode When upgrading a cluster of machines you typically do this by upgrading a set of machines at a time, making the new machines run the new software version, but in a fashion compatible with the old versions (in terms of e.g. migration). Then when all machines are upgrades, any new features in the new version can be enabled. This API allows qemu to limit the set of features that spice uses to those compatible with an older version, in order to do an upgrade like this. Right now it doesn't really do much, since we don't keep compat with 0.4.0 atm (although that may be added later). There is no guarantee that any future version of spice support being compatible with any previous version. However, we will always support compatibility with the previous major version so that clusters can be upgraded step by step. 2010-08-31 Alexander Larsson Bump version to 0.6.0 Require spice-protocol 0.6.0 Update NEWS for release Fix scaling with large magnification When scaling part of an image we need to specify the source coordinates in transformed coordinates. For large magnifications this means we will get pretty large values. Now, if e.g. src_x * transform is larger than 32765, then the coordinate ends up outside the pixman 16bit image size, so the rendering will not work. The fix is to make the src_x/y offset part of the transformation. This means its automatically transformed by the correct scaling, and the coordinates passed into pixman are not (typically) over 16bit. Revert "Fix scaling with large magnification" This reverts commit e13be77f33609cb3fdae354ce1f2686ae865f9e0. 2010-08-31 Alon Levy client: add default agent capabilities 2010-08-31 Gerd Hoffmann qxl parser: complete parsing of QXLCompatDrawable structs 2010-08-31 Yonit Halperin server: red_current_add_equal - don't push a drawable to the middle of the pipe if it depends on surfaces. This will prevent: 1) rendering problems (commands sent to the client in the wrong order) 2) sending commands for surfaces that haven't been created yet on the client side. 2010-08-31 Alon Levy server: when woken up by data ready to be read, don't call write. This used to be a callback for the vdi_port "data ready" interrupt, which did indicate either data ready to read or data ready to write, but this is no longer the case now that virtio-serial is used. This seemingly simple fix prevents a race that needs to be fixed with another patch, see freedesktop bz #29903 server: retry mouse send on queue full server: bugfix - make vdi_port_write_retry reiterate if write_queue still not empty The vdi_port_write_timer_started flag was not being reset, which prevented another vdi_port_write_timer_start from actually starting the timer. Fix is to change order of lines. This happens in the callback of the timer, so no chance of double timer set. client: add announce_capabilities server: add subtype to SpiceCharDeviceInterface, use for vdagent server: rename SpiceVDIPort* to SpiceCharDevice* 2010-08-30 Yonit Halperin server: fix red_current_flush to flush only the surface that was given as parameter A side effect of the previous red_current_flush, which flushed all the surfaces, and was called on a new display channel connection, was that red_handle_drawable_surfaces_client_synced sent the most updated surfaces images when needed. However, now, it should explicitly call red_current_flush. Moreover, since red_current_flush was called on a new display channel connection only if there was a primary surface, if the connection of the display channel occurred at the moment of no primary surface, red_handle_drawable_surfaces_client_synced was buggy. 2010-08-30 Alexander Larsson Fix scaling with large magnification When scaling part of an image we need to specify the source coordinates in transformed coordinates. For large magnifications this means we will get pretty large values. Now, if e.g. src_x * transform is larger than 32765, then the coordinate ends up outside the pixman 16bit image size, so the rendering will not work. In order to work around this we generate a "sub-image" of the pixman image such that the src_x/y values we have to specify are zero (or near zero). 2010-08-30 Gerd Hoffmann Bump versions. Update #define in server/spice.h in preparation for the 0.6.0 release. We also got some new functions, thus we have to increate the shared lib minor number for spice-server. Add config functions. A bunch of configuration functions where never ported forward from rhel-6 to upstream. Add them so we can add qemu config options for these settings. 2010-08-30 Alon Levy Merge commit 'ea298a14e1cde8b811baf6bd187287f18dde0dee' server: moved agent pipe headers to spice-protocol 2010-08-30 Yonit Halperin server: cleanups in destorying surfaces code server: really wait for a surface to be destroyed, when calling destroy_surface_wait Waiting till all the pipe items that are dependent on the surface will be sent. This was probably the cause for freedesktop bug #29750. server: consider also PIPE_ITEM_UPGRADE when searching for drawables in red_clear_surface_drawables_from_pipe 2010-08-27 Alexander Larsson canvas: Better coordinate rounding in scaling When scaling in pixman you give the source coordinates in transformed space rather than in the source coordinates. This is a bit problematic when both source and destination coordinates are at integer positions, but the scaling factor is not an exact 16.16 fixed point value. We used to calculate the transformed source based on the floating point transformation, which gave the wrong answer sometimes. Now we do the calculations based on the fixed point transform that we give pixman. However, even with this patch I can still sometimes see issues related to this, although they are less bad. server: red_send_image() - append image data to right marshaller The actual bitmap data was added to the main marshaller rather than the submarshaller that pointed to the SpiceImage part. This made us send too short messages failing demarshalling in the client. server: red_send_image() initialize bitmap.flags We're currently sending this to the network based on random memory. 2010-08-27 Gerd Hoffmann zap more unused bits. BufDescriptor isn't used at all. Two AddBufInfo fields (slot_id and group_id) are not used any more. red_get_cursor: avoid extra copy fix red_cursur_flush segfault zap dead typedefs zap dead qxl chunk code qxl parser: add cursor parsing 2010-08-26 Gerd Hoffmann qxl parser: complete QXL_SURFACE_CMD_CREATE parsing 2010-08-26 Alexander Larsson server: Fix alloc_lz_image_surface stride allocations All lz surfaces are not 4 bytes per pixel, calculate the right stride based on the pixman format. 2010-08-25 Yonit Halperin server: clean glz drawables when reseting qxl When the we reset qxl, we destroy all srufaces. Since surfaces and glz drawables are no longer dependent, we need to call red_display_clear_glz_drawables explicitly in order to clear all our drawables references in the server. 2010-08-25 Alexander Larsson server: Add missing break in switch case client: Handle async errors from xshm setup XShmAttach can fail asynchronously, so we need to check the errors in the x error handler during the XSync. 2010-08-24 Alexander Larsson client: Don't leak xshm segments Don't try xshm any more if it fails for a permanent reason This is copied from how Gtk+ detects Xshm failures. 2010-08-24 Yonit Halperin server: remove the no longer used glz drawables list that was maintained for each surface. server: remove unnecessary dependency between surfaces and Glz drawables Fixes freedesktop bug #28568 2010-08-23 Alexander Larsson Fix mismerge in last commit Remove USE_EXCLUDE_RGN define and !USE_EXCLUDE_RGN code Remove STREAM_TRACE define and !STREAM_TRACE code 2010-08-23 Yonit Halperin Limiting video streaming to the primary surface. freedesktop bug #28088. client: Fix for clipboard sending; It wasn't thread safe. client: fix - exit on bad display-effect argument 2010-08-18 Alexander Larsson Stride can be negative, so don't use size_t for it 2010-08-17 Alon Levy support python 2.5.4+ for marshaller/demarshallers Patch adds a "from __future__" import that doesn't affect newer python's but allows python 2.5.4 to run the code (tested under scratchbox, n900 build environment) 2010-07-29 Alon Levy client: Application::get_screen: fix double SpicePoint size, second hiding the first add arm and armv7 to configurable 32 bit variants in configure.ac (n900 and pc-z1 tested respectively) add eol after #ifdef in jpeg_encoder.h for n900 scratchbox compiler 2010-07-22 Alon Levy server: add vdi_port write retry timer. RHBZ 616772 2010-07-21 Alexander Larsson Don't do manual marshalling for input channel Fix typo in NEWS 2010-07-20 Alexander Larsson Update NEWS for 0.5.3 Require spice-protocol 0.5.3 or later Bump version to 0.5.3 server: Properly order rgb for 24bit bitmaps when sending to libjpeg SPICE_BITMAP_FMT_24BIT order is bgr, libjpeg wants rgb. This fixes freedesktop bug #28089 Swap red and blue when decoding 0.4 mjpeg streams There was an error in how this was encoded in 0.4, which we need to handle. There is still some issues with the old streams as the luminocity handling in 0.4 was not correct. demarshaller: Fix palette marshalling It turns out that using base + sizeof(struct) is not a good way to access an array at the end of a struct. For SpicePalette sizeof is 16, but offset of ents is 12. Using this calculation in the demarshaller breaks things badly, so now we use the actual array member. Don't send padding over the network with video data 2010-07-19 Alexander Larsson Fix uninitialized variable warnings Don't send CursorHeader if cursor_flags is NONE Send Clip.rects inline rather than using a pointer codegen: Allow @to_ptr to make inline structs demarshal as pointers codegen: Various cleanups Remove all uses of @end in the marshaller, instead just using the C struct array-at-end-of-struct. To make this work we also remove all use of @end for switches (making them C unions). We drop the zero member of the notify message so that we can avoid this use of @end for a primitive in the marshaller (plus its useless to send over the wire). We change the offsets and stuff in the migration messages to real pointers. codegen: Pass member to SubMarshallingSource rather than name This way we can check attributes on the member. codegen: Remove unused methos has_pointer() 2010-07-19 Alon Levy server vdi port: prevent recursive calls to read_from_vdi_port (required for spice-vmc) 2010-07-19 Arnon Gilboa client: add clipboard support * windows - untested * linux - small strings both ways, large implemented differently: * client to guest - support INCR * guest to client - we supply a single possibly very large property * requires server changes in next patch to work with spice-vmc 2010-07-19 Alon Levy fix typo DisplayModeListner -> DisplayModeListener 2010-07-19 Yonit Halperin client: command line arguments for setting windows guest monitors' color depth and disabling some display options (helpful on WAN) 2010-07-15 Yonit Halperin canvas_base jpeg_alpha: supply the correct size to jpeg_decoder Merge branch 'master' of git://git.freedesktop.org/git/spice/spice into spice_image 2010-07-14 Gerd Hoffmann add SPICE_SERVER_VERSION Allow to ifdef features which depend on a certain libspice-server release. update shlib minor commit c90183da944001e466f60acb58a5052c353995ca added two new functions, update shared lib minor version for that. 2010-07-14 Yonit Halperin server: enabling/disabling jpeg and zlib-over-glz via spice command line args 2010-07-13 Gerd Hoffmann red_glz_compress_image: lines isn't needed any more 2010-07-12 Yonit Halperin server: enabling/disabling jpeg and zlib-over-glz via spice command line args 2010-07-09 Alexander Larsson Don't marshall bitmap data as pointer, instead send inline Add --enable-werror and make it the default only for git builds Its not generally a good idea to have released tarballs build with -Werror, as later compilers may add warnings breaking old releases, etc. Use the right enum types for bitmap_data.type comparisons Add files i forgot to commit 2010-07-08 Alexander Larsson Update NEWS for release Disable tunnel by default on windows Make tunnel support optional in client too Make distcheck work Missed some misspelling fixes Fix various misspellings letancy -> latency compund -> compound SpicedSubMessage -> SpiceSubMessage modifaiers -> modifiers massage -> message outgoiong -> outgoing AlphaBlnd -> AlphaBlend remoth -> remote modifires -> modifiers secore -> secure Fix sign warnings from win32 compiler Fix inclusion of common files, no need for common/ part server: Remove unnecessary pci id/rev checks There is no need to check the pci ids or revisions. Thats a contract between qemu and the driver, and spice need not care, as long as we get the right data from qemu. Simplify spice_pixman_region32_init_rects with new types Don't manually of SpiceRects to pixman_box32_t now that they are compatible and SpiceRect is internal. Make all internal structures not be packed Remove unused method declarations Move SpiceChunks to mem.h Move in spice/draw.h from spice-protocol to common/ Handle the new QXLCursorHeader type Use QXLPHYSICAL, not SPICE_ADDRESS in qxl parser codegen: No SPICE_ADDRESS types left, drop @c_ptr Properly parse QXLLineAttrs.style 2010-07-08 Gerd Hoffmann remove QXLInterface->has_command() Not used any more, zap it before rolling up a release tarball. 2010-07-08 Uri Lublin server: add missing ifdef USE_OGL (red_worker.c) 2010-07-08 Gerd Hoffmann Properly parse QXLImage to the new-world SpiceImage SpiceImage now replaces RedImage and has all image types in it. All image data are now chunked (and as such not copied when demarshalling). 2010-07-08 Alexander Larsson codegen: support @chunk on non-pointer arrays This is similar to @as_ptr, but generates a single chunk of data. Add support for @chunk marshaller: Make get_nw_offset() handle deep member references Add spice_marshaller_add_ref_chunks Add spice_chunks_* helpers 2010-07-05 Alexander Larsson Convert SpicePath.segments to a pointer array Handle extra size for switch and array the right way Even for is_extra_size() we should calculate the mem_size for arrays, its just that the parent type (in this case switch) should request mem_size if the type is_extra_size. marshaller: Add some docs describing the types of sizes marshaller: Make @nonnull a propagated attribute This cleans up some stuff marshaller: Make @c_ptr a propagated attribute This simplifies some code marshaller: Add generic way to handle propagating attributes Also switches @ptr_array to use this 2010-07-02 Gerd Hoffmann Properly parse and marshall SpiceString 2010-07-01 Alexander Larsson Fix build on win32 Fix 32bit failure in demarshaller Due to a typo we always read offsets as pointers, never as SPICE_ADDRESS. Update for the SpicePath.segments type change 2010-07-01 Alon Levy Make CEGUI optional This makes the CEGUI dependency optional and off by default. Restoring previous behaviour of exiting on disconnect if disabled. 2010-07-01 Alexander Larsson client: Use ASSERT, not assert 2010-07-01 Alon Levy - fix for noopengl patch for server I still don't have commit access (can't ssh to anarchy) so if someone could commit this (alex) thanks, Alon Fix for no opengl patch - required to compile the server (fixes missing symbol gl_canvas_init). 2010-07-01 Yonit Halperin fix for not clearing the cursor ring when the primary surface is destroyed fixes a crash in qxl_soft_reset 2010-06-30 Alexander Larsson Simplify SpiceLineAttr by removing unsed stuff Also in new protocol don't send style data if not needed. Automatically marshall SpiceClipRects Automatically marshall SpicePath Support @marshall to automatically marshall pointers Store SpicePath segment count rather than size Internally and in the network protocol (for the new version) we now store the actual number of segments rather than the size of the full segments array in bytes. This change consists of multiple changes to handle this: * Make the qxl parser calculate num_segments * Make the canvas stroke code handle the new SpicePath layout. * Fix up is_equal_path in red_worker.c for the new layout * replace multiple calls to spice_marshall_PathSegment with a single spice_marshall_Path call * Make the byte_size() array size handling do the conversion from network size to number of elements when marshalling/demarshalling. * Update the current spice protocol to send the segment count rather than the size * Update the old spice protocol to use the new byte_size functionallity to calculate the size sent and the number of elements recieved Add spice_marshaller_set_uint32 With this function you can update an added uint32 after it being added. To make this possible all the spice_marshaller_add_add_foo functions now return a pointer that can be used as a reference when later setting a value. Update client and protocol to support the new SpiceClipRects demarshaller: Support @c_ptr attributes for pointers A @c_ptr pointer is stored in memory as a real pointer rather than a SPICE_ADDRESS. This is a temporary thing that will be removed again when all SPICE_ADDRESSes have been converted to real pointer. demarshaller: Don't parse @zero members These just write zeros at the right place in the network protocol typically for old back-compat things. We don't want to read these back in. 2010-06-30 Gerd Hoffmann qxl-abi: handle clip rect and path references. red_parse_qxl.c starts to follow QXLPHYSICAL references and build up data structures. Can zap a bunch of get_virt calls in red_worker.c, followed by cleanups. (de-) marshaller needs updates to deal with that. Also I suspect with the get_virt() calls being gone we can offload more work to generated marshaller code. client doesn't build. add qxl chunk parser 2010-06-29 Alexander Larsson server: Don't call opengl if not enabled If USE_OGL is not defined, really don't call or link in the opengl backend. 2010-06-29 Yonit Halperin client: add --include "common.h" for generated marshallers fixed unhandled destroy screen in Application:restore_screens_size detaching the screen when the primary surface is destoryed and closing the window if the primary surface is not recreated (the monitor has been detached). remove unnecessary send of SPICE_MSG_DISPLAY_RESET when SPICE_MSG_DISPLAY_RESET was sent, SPICE_MSG_DISPLAY_SURFACE_DESTROY had already been sent for all surfaces. It also caused a client crash since DisplayChannel::handle_reset assumes that screen exists. 2010-06-29 Gerd Hoffmann qxl abi: parse QXLRect. qxl abi: parse QXLPoint & friends. qxl abi: parse QXLCursorCmd. qxl abi: parse QXLSurfaceCmd. qxl abi: parse QXLMessage. qxl abi: parse QXLUpdateCmd. qxl abi: parse QXLClip. qxl abi: parse QXLLineAttr. qxl abi: parse QXLPattern. qxl abi: parse QXLBrush. qxl abi: parse QXLQMask. qxl abi: parse QXLBlackness+QXLInvers+QXLWhiteness. qxl abi: parse QXLText. qxl abi: parse QXLStroke. qxl abi: parse QXLRop3. qxl abi: parse QXLTransparent. qxl abi: parse QXLCopy + QXLBlend. Also adapt to tyops fix (s/rop_decriptor/rop_descriptor/). qxl abi: add missing QXLCopyBits qxl abi: parse QXLOpaque. Also adapt to tyops fix (s/rop_decriptor/rop_descriptor/). qxl abi: parse QXLFill. Also adapt to tyops fix (s/rop_decriptor/rop_descriptor/). qxl abi: parse QXLAlphaBlnd (+Compat) qxl abi: parse QXLCompatDrawable. qxl abi: parse QXLDrawable. improve memory slot error logging. 2010-06-28 Alexander Larsson Replace log4cpp with custom log function Also prints a simpler error to stderr for WARN or above so that we print something on the commandline if something go wrong. Fix build error due to member "SpiceMsgEmpty" same name as type 2010-06-24 Alexander Larsson spice.proto: surface_create.format is of type surface_fmt Use smaller size for enums and flags on the network This makes the protocol more compact. This was mainly done for the commonly used types. Some seldom used ones are still 32bit for future compatibility. Remove support for clip by path This is not supported currently anyway and was not generated before. 2010-06-23 Alexander Larsson spice.proto: No need for @ptr32 as that is now the default spice.proto: Don't use @fixedsize for Brush There is no reason to send the maximum size on the network, that is just a waste of space most of the time. Don't send zero data item for clips with no data Make pointers 32bit in new protocol format marshaller: Correctly determine if switches are fixed size Switches are fixed size only if all cases have the same size *and* it has a default case or all the valid cases are listed. Fix handling of @ptr32 network size Remove minor markup in unstable protocol as we're resetting minor to 0 2010-06-23 Gerd Hoffmann fix use-after-free in spice_marshaller_reset drop bogous get_virt_delta calls 2010-06-23 Alexander Larsson Fix version mismatch error on connect Protocol is 0 (auto), 1 (old), or 2 (new). This is (apart from 0) the same as the major number for the stable protocol. However, the current major is ~(-1) to signify it being unstable, so don't use the major number as source for setting or comparing protocol. Fix screen resolution changes on old servers * Correctly check for existing canvas 0 * Don't try to unlock the screen size if there is no active screen 2010-06-22 Alexander Larsson client: Support connecting to a major==1 server Implement display_mode message needed for backwards compat Generate marshaller/demarshallers for old protocol Add spice1.proto describing the 0.4 version of the network protocolx Add support for @virtual markup in spice protocol This means the member is not sent on the network at all. Instead its initialized to the attribute argument when demarshalled. This is useful for backwards compatibility support. Make internal generated marshaller functions static Support extra prefix in code generators This is require when we add a new spice.proto for the old (major 1) protocol description. Add more emacs mode headers Convert client to use indirect calls for message marshalling This is required to support multiple versions Support creating marshallers that are called indirectly This is needed if we want to switch marshallers depending on what major version the remote side has. Add destructor for demarshalled messages This is required because we don't want to free messages that just refer to the unparsed message (like SpiceMsgData). Also, in the future we might need it for more complex demarshalling. 2010-06-21 Yonit Halperin fix for not reseting client palette caches on migration Lossy compression of RGBA images (on WAN connection) The RGB channels are compressed using JPEG. The alpha channel is compressed using LZ. applying zlib compression over glz on WAN connection 2010-06-21 Alexander Larsson Make opengl optional, disabled by default The OpenGL renderer isn't really useful right now, its not quite up to date, its not really faster than software and it only supports a limited subset of drivers. So, lets disable it for now. Long term opengl rendering of the 2d part of spice is important if we want to combine 2d and 3d rendering (say if spice adds opengl support in the protocol). But until then this is isn't useful for normal use. 2010-06-18 Alexander Larsson Make generated marshallers build on win32 Add server/demarshaller.h Make sound data @as_ptr to avoid copying data Make ping data @as_ptr to avoid copying data Make cursor data @as_ptr to avoid copying data Support @as_ptr in demarshaller to avoid copying data unnecessary Make pointer types in messages be 64bit in memory Right now we always assume pointers are stored as SPICE_ADDRESS, i.e. 64bit, independent on the size sent on the network. This is required for 64bit architectures of course, but slightly overkill on 32bit architectures, so needs fixing when all SPICE_ADDRESS elements can be made internal. Don't pack the message structures Make all message structs internal to spice We move all message structs from spice-protocol to spice as we want to be able to change these as needed internally. The on-network format is no longer defined by these structures anyway, but rather by the spice protocol description. Allow multiple --include args Use generated demarshallers in server Generate demarshallers on server side Make tunnel_service_add members be of cstring array size Switch client to use generated marshallers Generate and link marshallers into client Re-enable cache freeing I don't know why this was disabled but it seems like a bad idea Convert reds.c to use SpiceMarshaller Convert snd_worker.c to use SpiceMarshaller and generated marshallers Convert red_worker.c to use SpiceMarshaller for marshalling Generate marshallers in server Use @ptr32 for 32bit offsets in spice.proto Add @nomarshal in a few places where we're marshalling manually spice.proto: add @outvar markup With this we can reference pointer member with no naming conflicts Add support for generating message and structure marshallers Add SpiceMarshaller for easy marshalling Generate demarshalling code on win32 too Client: Use the autogenerated demarshallers When a message has been read from the network we now pass it into the generated demarshaller for the channel. The demarshaller converts the network data to in-memory structures that is passed on to the spice internals. Additionally it also: * Converts endianness * Validates sizes of message and any pointers in it * Localizes offsets (converts them to pointers) * Checks for zero offsets in messages where they are not supported Some of this was previously done using custom code in the client, this is now removed. Generate demarshallers in client Add python code to automake system Initial import of spice protocol description and demarshall generator The "spice.proto" file describes in detail the networking prototcol that spice uses and spice_codegen.py can parse this and generate demarshallers for such network messages. Use the correctly spelled enum values from the new generated enums Use the new enums for keyboard modifier flags 2010-06-17 Alexander Larsson There are multiple line attribute flags enums, use only one Add spice_strnlen 2010-06-09 Yonit Halperin server: optimize red_pipe_replace_rendered_drawables_with_images (lossy bitmaps support related) init/destroy lossy surface region enabling jpeg on low bandwidth connection not using jpeg when sending a surface to the client (the whole surface) When a surface is sent to the client using red_send_surface_image, operations were already performed on it. Thus it may combine, especially if it is a primary surface, both "picture-like" areas and areas that are more "artificial". In order to avoid noticeable artifacts, such surface will be sent lossless. send qxl commands to client: support for resending lossy components when jpeg compression is enabled infrastructure routines for resending to the client part of surfaces that have been sent lossy. The code also handles cases in which the server doesn't hold anymore these surfaces parts, i.e., when it holds a more updated version of them. This scenario is handled by replacing commands that were rendered, with images. introducing lossy and lz compression in red_send_image lossy surface regions in the client: infrastructure for tracking and updating support for lossy images in the pixmap cache and fill bits 1) add an option to determine if a bitmap can be sent lossy to the client 2) when required, replacing lossy cache items with their correspending lossless bitmaps JPEG support: introducing jpeg encoding for spice bitmaps server: fix bitmap flags assignment in red_send_image 2010-06-09 Alexander Larsson client: Only invalidate on screen if drawing to the primary surface 2010-05-26 Gerd Hoffmann sound: code style fixups 2010-05-21 Alexander Larsson Fix some misspelled identifiers severty -> severity SpiceResorceID -> SpiceResourceID SpiceResorceList -> SpiceResourceList resorces -> resources ped_size -> pad_size postition -> position RedWorkeMessage -> RedWorkerMessage Fix spelling errors in comments and strings 2010-05-21 Gerd Hoffmann sound channels: restart audio on client reconnect. 2010-05-19 Alexander Larsson Use the new byteswap macros from spice-protocol Change leftover VD_INTERFACE_RECORD to SPICE_INTERFACE_RECORD Add missing backslash continuation in makefile 2010-05-19 Gerd Hoffmann Revert "[debug] migration troubleshooting" This reverts commit 08927fabe57c17086fe3bce3a9ca166e2309349e. complete NetWireInterface redesign, make red_tunnel_worker.c build. add spice-experimental.h Supposed to be used for work-in-progress bits, where interfaces are not finalized yet. Moved over vdi port interface, tunnel interface and spice client migration functions. zap vd_interface.h move over content to spice.h vd_interface.h cleanups. Drop leftover bits which are not used any more. Rename DrawArea to QXLDrawArea. NetWireInterface: redesign zap MigrationInterface Remove remaining MigrationInterface bits. migration: new api Add new API for migration, based on what RHEL-6 has. [debug] migration troubleshooting zap migration code Drop all code which depends on accessing the migration file handle. replace worker load/save with loadvm_commands, allow keeping surface content Add worker->loadvm_commands. qemu will uses this to send a series of commands needed to restore state after savevm/loadvm and migration. That will be one create-surface command per surface and one cursor-set command for the local pointer. The worker->save/load functions are not needed any more. Likewise the interface->{get,set}_save_data callbacks. Surfaces created via loadvm_commands *will* not be cleared. Also primary surfaces are not cleared any more (unconditionally, although we could do that conditionally on loadvm using the flags field in QXLSurfaceCreate). surface: keep metadata (aka create command) in device memory. With this patch applied the spice server will not release surface create commands for the whole lifecycle of the surface. When the surface is destroyed both create and destroy commands are released. This has the effect that the surface metadata (size, depth, ...) is kept in qxl device memory. This in turn makes it alot easier for qemu to handle savevm/loadvm. It just needs to do some minimal command parsing and maintain pointers to the create commands for the active surfaces. kill spice_server_set_mouse_absolute Not needed. Just register/unregister the tablet interface instead. vdi port: redesign. Pretty straight forward. One thing we should think about is if and how we are going to deal with multiple ports here? With vdi port using virtio-serial as communication channel to the guest it is easy to have multiple ports, i.e. we might want to use a second instance for clipboard data. That implies that we need support for multiple channels all the way through the stack ... constify SpiceBaseInterface SoundInterfaces: redesign TabletInterface: redesign QXL: redesign. MouseInterface: redesign KeyboardInterface: redesign. This is the direction I wanna take with all interfaces: Clearly separate interface (aka version information and function pointers) and state information. SpiceKbdInterface defines the interface, SpiceKbdInstance maintains per-instance state information. Keyboard hasn't much beside a pointer to SpiceKbdInterface, for other interfaces this very likely will be different. s/CoreInterface/SpiceCoreInterface/ VDInterface: redesign. VDInterface has been renamed to SpiceBaseInterface. Dropped base_version element, shlib versioning should be used instead. Dropped id element, it is passed to spice_server_add_interface() instead. Now SpiceBaseInterface has static information only, multiple interface instances can share it. Added SpiceBaseInstance struct for maintaining per-instance state information. Adapted spice_server_{add,remove}_interface() functions to the new world. shlib major minor timer interface cleanups. Make the timer interface largely look like the watch interface. Simliar naming convention for the functions (timer_*) and a opaque SpiceTimer type. new watch api: kill old api new watch api: switch channels new watch api: switch sound new watch api: switch migration new watch api: switch inputs new watch api: switch ssl accept new watch api: switch main channel new watch api: switch liasync read new watch api: switch listening sockets introduce new watch api This patch adds a new file handle watch interface to libspice, featuring three callbacks: (1) watch_add() -- create a new file watch. (2) watch_update_mask() -- change event mask. spice frequently enables/disables write notification. (3) watch_remove() -- remove a file watch. libspice users must implement these functions to allow libspice monitoring file handles. The old interface (set_file_handlers) doesn't explicitly express the lifecycle of a watch. Also it maps 1:1 to a qemu-internal function. In case the way qemu implements file watches changes (someone sayed QemuIONotifier?) this will break horribly. Beside that it is very bad style. Follwing patches will switch over users one by one to the new interface and finally zap the old one. fix visibility zap CoreInterface->{term_printf,log} Was used to print stuff to the qemu monitor. Fundamentally incompatible with QMP. Remove. zap qterm interfaces old way to handle monitor, obsolete. zap CoreInterface->(un)register_change_notifiers() spice_server_add_interface() and spice_server_remove_interface() can be used instead. zap CoreInterface->next() Interfaces must be registered after spice_server_init(). The "next" callback is used to discover interfaces registered before spice_server_init(). Which is a empty list and thus pretty pointless. Remove it. channel security cleanup - drop spice_channel_name_t enum, use spice-protocol defines instead. - switch spice_server_set_channel_security() channel parameter from enum to string. - drop spice_server_set_default_channel_security(), use spice_server_set_channel_security with channel == NULL instead. zap spice_parse_args + spice_usage_str First step to throw out the old interface. 2010-05-19 Alexander Larsson Minor whitespace cleanup Make it --enable-tunnel work 2010-05-03 Yonit Halperin server: fix invalid self loop in surfaces dependencies. Cyclic dependencies between surfaces mustn't occur. They can cause invalid rendering - recent drawables might be rendered before older ones. 2010-05-03 Dan Kenigsberg spice server: fix typo in private key error message 2010-05-03 Gerd Hoffmann Add C version of find_msb() This patch allows people to build the spice-client on any 32bit/64bit architecture. by Bryan Stillwell 2010-05-03 Alexander Larsson Remove all mentions of "cairo" from the code The command line option is renamed from "cairo" to "sw", and similarly all filenames and types from Cairo to Sw (and similar). 2010-04-30 Alexander Larsson Don't send alpha bytes for primary surface The framebuffer is not used as a source for alpha blends, so we never need to scan it for alpha bytes. 2010-04-29 Gerd Hoffmann iovec: add sanity check Adds sanity check to iovec setup. In theory this should never ever trigger. In practice guest driver bugs can make it trigger. This patch avoids qemu burning cpu in a endless loop, instead we'll print a message and abort. Not sure whenever there is a more graceful way to handle the situation ... fix worker->stop surface cleanup 2010-04-29 Alexander Larsson client: Report window format right for win32 client: Support 16bpp pixmaps on win32 win32 client: Remove unnecessary GDIImage type We just use pixman_image_t as the "information about image data" structure. 2010-04-28 Alexander Larsson Add support for SPICE_IMAGE_FLAGS_HIGH_BITS_SET Clear alpha in xRGB destination to avoid pixman setting it to 0xff Pixman sometimes sets the ignored high byte to 0xff during alpha blending. This is correct according to pixman specs, as the high byte is ignored. However its not what windows expects, and it causes unnecessary regions with non-zero high byte, causing us to send rgba data instead of rgb which compresses worse. So, we detect this and clear the high byte. Fix line lengths and tabs 2010-04-26 Gerd Hoffmann fix two warnings 2010-04-23 Alexander Larsson Remove surface format workaround now that win32 driver is fixed The win32 driver makes all 32bit surfaces be xRGB now, so we can remove this old workaround. Fix up win32 client with recent changes Win32 canvas fixes If we have alpha in a 32bit rgb surface, ensure we send that If we don't then alpha is lost which is problematic if the surface is later used as with alpha_blend and SRC_SURFACE_HAS_ALPHA. Support alpha surface sources and destinations Localize palettes for LZ PLT format This is needed since they always decode to 32bit mode. Server: Use the right image format when updating from a surface Make each surface its own depth/format Surface creation now specifies the exact format, not only the bit depth of each surface which is used for rendering. Additionally we now actually store the surfaces in that format, instead of converting everything to 32bpp when drawing or e.g. handling palettes. Client: Support pixmap format conversion in copy_pixels In order to be able to support 16bit canvases on 32bit screens and 32bit canvases on 16bit screens we need to handle format conversion when drawing RedPixmaps. The way this works now for X11 is that we only have one PIXELS_SOURCE_TYPE for pixmaps, which always has a pixman_image_t for the data, but additionally it has an XImage (shared mem or not) if the screen the pixmap was created for (i.e. an explicit one or the default screen) has the same format as the pixmap. When we draw a pixmap on a drawable we have two variants. If the pixmap has a XImage and it matches the format of the target drawable then we just X(Shm)PutImage it to the drawable. If the formats differ, then we create a temporary XImage and convert into that before drawing it to the screen. Right now this is a bit inefficient, because we always allocate a new temporary image when converting. We want to add some caching here, but at least this lets things work again. X11 client: Add helper for XImage construction Add utility functions to create XShm images Create screen composit area in same format as window This way we don't have to convert when drawing to it, or drawing it to the dc. Add helper to compare RedDrawable::Formats for copy compabible Being copy compatible means the format are identical except that some bits in the source may be ignored in the destination. Add RedDrawable::Format get_format() This is useful because we can e.g. create pixmaps in the same format as a window. Add XPlatform::get_screen_format for X11 Move RedPixmap::Format to RedDrawable::Format We need to know the format for other drawables too (like for instance the native format of a window), so we're pushing this down. This changes a bunch of references to be RedDrawable::, but not all. The the old RedPixmap:: references still work, but will be phased out. Make client canvas and pixmaps handle more formats and simplify We now support 16bit format pixmaps as well as the old ones. Including both 555 and 565 modes. We drop the palette argument for pixmap construction as it was only used for black/white anyway. Canvas creation is simplified so that there is no separate set_mode state. Canvases are already created in the right mode and never change. common: Add lookaside storage for pixman image format Ideally we should just read this from the pixman image, but there is no API to do so in stable pixman, so we store it. Add pixman utilities for bitmap to pixman_image_t conversion Add support for 16bit rop3 Add emacs modelines to more files Remove unused method canvas_surf_to_invers Make client start if screen is 16bpp The current glx code is looking for a rgb32 visual and always failing if there is none. This means not even software rendering starts up on e.g. 16bit visuals. This commit makes it pick software fallbacks on 16bit visuals. Long term we need to fix the gl implementation to do 16bpp too. Client: Don't die if XIM not availible Detect XShm extension sanely The previous way XShm detection worked failed at least for me, and is not the standard way. We now just use XShmQueryExtension and XShmQueryVersion. Detect big endian systems Fix warnings breaking win32 build 2010-04-14 Izik Eidus Merge branch 'master' of ssh://git.freedesktop.org/git/spice/spice spice: server: change update_area command The new command return dirty area to be used by users that want spice to render localy or into some framebuffer (sdl / vnc) 2010-04-14 Alexander Larsson Avoid unncessary buffer management in mjpeg decoder if possible 2010-04-13 Alexander Larsson Relicense everything from GPL to LGPL 2.1+ Fix A1 handling in RedDrawable combine_pixels. The previous code was just busted, as apparent on e.g. the cursor in MS Paint. 2010-04-12 Alexander Larsson Use upstream name for pthreads lib and new freetype version Fixed vs2008 warning Fix win32 build with pixman 0.18.0 Use fast DCT method for better jpeg compression performance 2010-04-12 Izik Eidus spice server: fix validate_chunk fix 16bpp support on cairo_canvas 2010-04-12 Alexander Larsson Always tread depth 24 (i.e. non alpha) as depth 32 when blitting When blitting we don't really care about alpha mismatches, we just copy bits anyway. 2010-04-09 Izik Eidus take the right lock when freeing glz stuff of surfaces this was noticed by Yonit. 2010-04-09 Alexander Larsson Split out the memslot stuff from red_worker.c to its own files This is required so that we can have code in other files that does address validation. 2010-04-09 Yonit Halperin server: fix race condition in lz global dictionary, in its image segments list 2010-04-09 Izik Eidus spice: win32 client: fix gdi locking While the fix could have been more effective, it seems like this patch stream better with the coding logic that was there..., maybe later we will want to change the locking into more effective way. (There is just the primary surface to protect in reiality) 2010-04-08 Alexander Larsson Remove leftover AutoVStreamInit class Initialize _kill_mark so we don't get spurious valgrind warnings Free the jpeg decoder with the stream Use libjpeg to decode mjpegs, not ffmpeg This is pretty straightforward, although there are two weird issues. The current encoder has two bugs in the yuv conversion. First of all it switches red and blue, due to something of an endianness issue. We keep this behavior by switching red and blue. Maybe we want to change this in the new protocol version since switching this may cause jpeg compression to be worse. Secondly, the old coder/decoder did rgb to/from yuv420 wrongly for jpeg, not using the "full scale" version of Y that is used in jpeg, but the other one where y goes from 16 to 235. (See jpeg/jfif reference on http://en.wikipedia.org/wiki/YCbCr for details.) The new decoder uses the full range in order to get better quality, which means old encoders will show slightly darker images. This completely removes all ffmpeg usage in the client Update project file to visual studio 2008 2010-04-08 Izik Eidus spice server: fix not sent depth size for surfaces 2010-04-07 Alexander Larsson Remove non-used lookup3.[ch] 2010-04-06 Yonit Halperin server configuration: make network redirection support optional By default it is disabled. To enable: configure --enable-tunnel. When active, requires libslirp. client: handling SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST disconnecting from the current host and connecting to the target host. client: fix unsafe access to an event member 2010-04-06 Izik Eidus spice server: try to be less brutal when changing res or when flushing the tree The idea is that we can try to defer some stuff to be later send in the pipe if the pipe is not fulled yet, moreover we will then walk on the pipe using: red_clear_surface_drawables_from_pipe() and will try to remove the uneeded objects of this surface Still some room to improvment but later... spice server: remove surface_id and surfaces_dest[3] from guest mem Validate the surface_ids just once and keep them in safe memory area Make things simpler 2010-04-05 Izik Eidus spice: common: gdi_canvas fix gdi objects leak BitmapMask was used by the draw_text function as well therefore we need to mark from_surface = 0 if we want it to release the boject... (Was evil, took me few hours to understand from where the leak come...) spice-server: when destroying a surface don`t send uneeded items Just skip the items of destroyed surface that are found in the pipe before we skip them, we check if they are needed by other users... spice-server: remove glz objects related to surface when destroying a surface make the surface released faster in the release ring as well as clean unneeded reference into the glz spice: reds: fix uninitlized pointer 2010-04-03 Yonit Halperin client: x11: fix a crash caused by a call to a destroyed window. Happens when a focused window is destroyed without a focus out event, and a focus-in event occurs on another window. 2010-04-03 Izik Eidus libspice: add off screens support spice server: surface create/destroy protocol support Now we can send commands from the server to the client to destroy surfaces (right now just the primary surface) Needed for offscreens support) Another patch`s on the way. 2010-03-24 Alexander Larsson Rename .so spice-server.so Also change include dir to "spice-server" for consistency. libspice.so conflicted with the tclspice package, and its also a clarification for when we create a spice client library. Add spice_strndup Also, make str(n)dup handle NULL correctly Get rid of more out-of-memory checks We already check this in spice_malloc now 2010-03-24 Yonit Halperin spice: server: Being more permissive in video identification In 'filter' video streaming mode, use a more permissive threshold for distinguishing 'realistic' streams from 'textaul'/'artificial' streams. The previous threshold classified streams that were scaled on the guest as artificial and thus they were not recoginized as videos. 2010-03-24 Alon Levy spice: client: fix handling of top down images in video streams Top down streams arrive from x11-qxl driver. 2010-03-24 Yonit Halperin spice: server: avoid video streaming of small images I added a lower limit to the size of images that are being streamed. The limit is only active in "filter" video streaming mode. This will prevent blurry animated icons. 2010-03-24 Alexander Larsson rename spice.pc to spice-server.pc configure.ac: client: replace $(top_srcdir) in x11/Makefile.am (subdir config) Replace all "$(top_srcdir)/common" with "$(SPICE_COMMON_DIR)" and all "$(top_srcdir)/client" with custom "$(CLIENTDIR)" This would (after following patches) enables building the client from either spice/ (top directory) or spice/client. 2010-03-24 Uri Lublin configure.ac: define SPICE_COMMON_SRCDIR, to be used by Makefile.am (subdir config) Note that SPICE_COMMON_SRCDIR may be overwritten by configure.ac.shared autogen: exit upon errors (subdir config) autogen: add possibly missing AUTOMAKE definition (subdir config) autogen: remove copied code - srcdir and ORIGDIR (subdir config) 2010-03-18 Alexander Larsson Fix uninitilized memory read in stroke_fill_spans() y2 was not initialized 2010-03-18 Gerd Hoffmann new libspice api: spice_server_add_get_{sock, peer}_info() new libspice api: spice_server_add_renderer() 2010-03-18 Yonit Halperin client: add command line support for ciphers, ca file, and host certificate subject 2010-03-17 Alexander Larsson Default opt flags to -O2 gcc -O3 has some code generation failures due to a combination of unaligned (packed) structs and vectorization that can cause a crash in canvas_localize_palette(). And its just safer to use -O2, which is the standard "trusted" optimization flags. Use nearest scaling for DRAW_ALPHA_BLEND since this is what win32 needs DrvAlphaBlend is the only current user of DRAW_ALPHA_BLEND, and its defined to do nearest (COLORONCOLOR) scaling, not bilinear. Fix up empty region checks in canvas operations We rely on not passing on empty rects to the drawing operations by checking for empty regions and exiting early. However the checks were wrongly using pixman_region32_n_rects(region) == 0, whereas we should be using pixman_region32_not_empty(). 2010-03-11 Søren Sandmann Pedersen Explicitly depend on various X libraries, and -pthread In Fedora 13, the linker doesn't pull in DT_NEEDED libraries anymore, so we have to list the things that we depend on explicitly. This affects several X extension libraries, and also the pthread library. 2010-03-11 Alexander Larsson Use spice allocator in server/ Use the spice allocator in common/ New memory allocators that exit on OOM and handle multiplication overflow Every place that does a regular malloc/calloc and aborts on failure should use spice_malloc/spice_mallo0 instead, which is leaner and cleaner. Allocations of dynamically sized arrays can use g_malloc_n or g_new etc which correctly handle multiplication overflow if some of the arguments are not trusted. 2010-03-10 Alexander Larsson Define __STDC_LIMIT_MACROS for c++ code to get SIZE_MAX We need SIZE_MAX for the malloc overflow code, and its not defined in C++ unless __STDC_LIMIT_MACROS is defined. Define GL_GLEXT_PROTOTYPES in CFLAGS not in random places in the source Revert "Fix possible quic_usr_more_lines_unstable() crash" This reverts commit 34e6a0a0d539fb49a03ec01bf11be505c88fcaa1. Turns out this wasn't needed and the crash was due to other changes. 2010-03-09 Alexander Larsson Update gdi canvas wrt latest changes ALIGN -> SPICE_ALIGN 2010-03-09 Gerd Hoffmann new libspice api: add spice_server_set_mouse_absolute() new libspice api: add spice_server_set_channel_security() new libspice api: make spice_channel_name_t part of the public api. new libspice api: add spice_server_{get, set}_image_compression() new libspice api: make image_compression_t part of the public api. new libspice api: configure listen addr, add ipv6 suppor new libspice api: configure tls new libspice api: zap function pointer indirection. Make register_*_notifier calls optional, long term they should go away entriely. Add direct library calls as replacement. new libspice api: configure port + ticket Add new functions to configure spice port and ticketing. Yes, this is incomplete, it includes just the most important bits to get something up'n'running. These functions are supposed to replace both spice_parse_args() and the monitor interaction via qterm interface. new libspice api: alloc, initi and free spice server instances. The implementation can't handle multiple spice server instances at the same time right now. The API allows this though, so if we fixup the implementation some day we don't have to change the API. Fix possible quic_usr_more_lines_unstable() crash quic_usr_more_lines_unstable() assumes it can allways copy a complete scanline. Well, it can't. In case the screen rectangle which needs updating has an x-offset greater than zero *and* includes the last scanline of the screen it will overflow the source buffer by x-offset * bytes-per-pixel bytes. 2010-03-09 Alexander Larsson Use macros from rather than duplicate them 2010-03-08 Alexander Larsson Move draw_rop3 to canvas_base Move canvas_draw_stroke to canvas_base Move most of the shared draw_xyz() methods from CairoCanvas to CanvasBase This adds a set of virtual methods for low-level operations. A subclass can choose to implement those and let the default CanvasBase implementations handle the highlevel stuff. Move canvas_region and group_start/end to canvas_base Move virtualization of canvas drawing into common/canvas_base Instead of having two virtualizations of the canvas we push the virtualization into the canvas code itself. This not only avoids the duplication of this code, it also makes the exposed API for the canvas much smaller (in terms of exported API). It also lets us use the virtualization to implement basic support for operations in canvas_base which is then overridden by each canvas implementation. Make virt mapping an interface Make glz_decoder non-optional canvas_base in canvas constructors It can still be NULL, but we simplify the headers by always including it. There is no practical performance difference here. Make canvas Glz decoder integration nicer We use a dynamic interface similar to e.g. SpiceImageCache instead of passing both function and opaque Fix colorkeying in pixman_utils.c We were masking out the alpha bit in the key color not int the source pixel, so colorkeying didn't work when the high byte was != 0. For instance in the shutdown dialog in XP. 2010-03-05 Alexander Larsson Fix up win32 build reference to pixman_utils.cpp It was pointing to the wrong directory for pixman_utils.cpp 2010-03-03 Alexander Larsson Only use AI_ADDRCONF if availible AI_ADDRCONF not availible on winXP, so this fixes windows build. 2010-03-01 Larsson@.(none) Update visual studio project for pixman changes Make gdi canvas build in the new pixman world Always include spice/types.h before pixman so standard int types exist Fix warnings from visual studio compiler Have only one copy of ROUND macro and cast to int explicitly 2010-02-27 Gerd Hoffmann spice client: add ipv6 support. spice client: fix dns lookup ignore lookup results which are not ipv4 2010-02-23 Alexander Larsson Remove qcairo dependency, only use pixman Remove cairo use in client Remove no longer needed CAIRO_CANVAS_CACH_IS_SHARED define and code Remove last cairo use from canvas_base Remove cairo_t from cairo canvas Covert cairo canvas put_image() to pixman Replace custom region implementation with pixman_region32_t pixman_region32_t is an efficient well tested region implementation (its the one used in X) that we already depend on via pixman and use in some places. No need to have a custom region implementation. Convert cairo canvas clear() to pixman Convert cairo canvas group_start/end to pixman Convert cairo canvas read_bits() to pixman Remove unused cairo helper functions Convert cairo canvas to use pixman for draw_stroke Convert cairo canvas draw_transparent to use pixman Convert cairo canvas draw_rop3 to using pixman Convert draw_blackness/whiteness/invers to using pixman Convert cairo canvas alpha_blend to using pixman Convert cairo canvas draw_text to using pixman Convert cairo canvas copy bits to pixman Convert cairo canvas draw_copy() to using pixman This is just identical to draw_blend(). Convert cairo canvas draw_blend() to using pixman Convert cairo canvas draw_opaque() to using pixman Convert cairo canvas draw_fill() to using pixman Add possibility to not invert bitmask in canvas_get_mask() This allows the pixman implementation to instead invert the (generally smaller) region instead of duplicating the bitmap to invert it. Use pixman_image_t instead of cairo_surface_t as the generic pixman container This allows us to use the simpler dependency of pixman outside of the cairo backend, and it later lets us move the cairo backend to using pixman only. Turn image and palette cache into c style dynamic interface Instead of passing a bunch of function pointer and an opaque pointer we make a real type and add a vtable pointer to it. This means we can simplify all the canvas constructors, etc. Add optional templated base class to Cache and SharedCache We want this for integration with C-style classes. Add pixman_image_t referencing the cairo_canvas bits This references the same data as the cairo surface and can be used for drawing to the surface using direct pixman calls instead. Add line rasterizer Add pixman utilities This includes: * pixman region from SpiceRects * rop2 enum * solid fill * solid fill with rop * tiled fill * tiled fill with rop * blit * blit with rop * copy rect Add emacs settings for indent according to spice styleguide 2010-02-10 Alexander Larsson Fix delete vs delete[] mismatches This fixes a bunch of valgrind warnings. 2010-02-04 Alexander Larsson Use standard int types and Revert automatic renames that were wrong Seems my rename script didn't handle C++ namespaces that well. Use the new header names I just ran: find -name "*.[ch]" | xargs sed -i -f ../spice-protocol/includes.sed find -name "*.cpp" | xargs sed -i -f ../spice-protocol/includes.sed Rename symbols that were changed in spice-protocol This is an automatic change using: $ find -name "*.[ch]" | xargs ../spice-protocol/rename-identifiers.sh ../spice-protocol/renames $ find -name "*.cpp" | xargs ../spice-protocol/rename-identifiers.sh ../spice-protocol/renames Remove headers that were moved to spice-protocol Depend on spice-protocol module This doesn't actually use the new module, just sets it up for use. Filter out XIM X events XIM ClientMessage events to an XIM internal window was triggering the check for a window message procs. We need to properly filter events with XFilterEvent to avoid this happening. 2010-01-28 Izik Eidus libspice: add surface 0 support This include alot of infestracture for off screens. 2010-01-11 Yaniv Kamay client: change rerror code to be positive client: add Platform::term_printf Platform::term_printf is a variant of printf that on windows dynamically opens console in order to have visible output during command line processing. client: fix logger init mix-up client: move log file to spicec appdata dir 2010-01-11 Yonit Halperin server,client: server authentication for secured channels. 3 available mechanisms: by public key, by host name, and by certificate subject name. In the former method, chain of trust verification is not performed. The CA certificate files are looked for under /spice_truststore.pem windows =%APPDATA%\spicec\ linux =$HOME/.spicec/ 2010-01-07 Arnon Gilboa spice: menu additons -functions: set_name, remove_command, remove_sub, clear -item state & enum -add state support in RedWindow insert_command & insert_menu 2010-01-06 Yaniv Kamay server: add new vd interface QTerm2Interface 2010-01-06 Arnon Gilboa spice: add missing break 2010-01-04 Yaniv Kamay client: use spice icon instead-of solidice icon 2009-12-30 Arnon Gilboa spice: PKG_CHECK_MODULES: CEGUI version spice: position mouse in primary monitor center after full screen toggle -move _focused & _pointer_in_window from RedWindow to RedWindow_p's -move shadow focus & cursor handling to sync() -add reset_cursor_pos() to Platform -Monitor set_mode()/restore() use virtual do_set_mode()/do_restore() spice: on_activate_screen generates on_key_down for any modifier pressed -call SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc...) only once, in RedWindow::init() -add Application::cleanup_globals() & RedWindow::cleanup() -cleanup LowLevelKeyboardProc() 2009-12-28 Yaniv Kamay client: let PreLoginDialog save and restore LoginDialog client: remove splash image client: add GUI infrastructure + functional login dialog client: add gui res files client: add soft renderer and cegui client: smiplify DisconnectedEvent client: move visibility change logic from screen to app client: wait for disconnect state in RedClient::connect() client: improve screen resizing Screen now have to modes locked and unlocked. In unlocked mode, the application can change screen size and so reduce resolution changing. The application can also choose to change window size while not in full screen mode. In locked mode the application must ewtain locker screen size setting. client: restore mouse capture state after screen resizing use spaces instead of tabs in bitmap_to_c and icon_to_c output 2009-12-24 Yaniv Kamay win client: change avcodec version to 51 2009-12-24 Izik Eidus spice: fix server crush in case connecting without qxl device 2009-12-23 Izik Eidus spice client: fix wrong gdi-canvas handling of blend_alpha 2009-12-23 Yaniv Kamay client: new static title image 2009-12-22 Izik Eidus spice: fix ssl compiling errors (openssl api was changed, so lets have ifdef to compile in all cases) spice: client: add checks to see if it is safe to use XShem. Beacuse that XShem internal checks wont fail when using the spice client from remote, we are adding check on the socket family to see if it is unix domain socket and fail in case it is not. 2009-12-21 Yaniv Kamay spice: sever: increase client timeout Increase client timeout in order to prevent unnecessary disconnecting of client while the connection is over WAN. Tested by changing WinXP resolution (with desktop background) while connecting over WAN (1.5Mbit 150Kbit) spice: sever: remove assert on nop copy bits 2009-11-30 Yonit Halperin spice server: heuristic for distinguishing between "real" videos and textual streams 2009-11-30 Yaniv Kamay client: KeyHandler now receive unicode char event in addition to RedKey events client: move scan code translation to InputsChannel remove unuse Application::is_cad_pressed() client: split inputs handler client: interactive screen layer 2009-11-23 Izik Eidus spice: server: add memslots support. 2009-11-18 Yaniv Kamay add missing alt_image.c to Makefile.am 2009-11-18 Arnon Gilboa spice: pass modifiers stroke events down the hook chain spice: add [pid:tid] to log lines spice: on toggle_full_screen, generate on_key_down if shift is still pressed 2009-11-17 Arnon Gilboa spice: show splash screen on disconnect only on debug 2009-11-16 Yaniv Kamay client: change jitter buffer size to 300ms 2009-11-15 Yonit Halperin spice client: sticky Alt activation when holding an Alt key: bug #505912. Additional changes that were required for the feature: 1) focusing on the pointed window in full screen mode 2) In X11 - handling events that occur during keyboard ungrabbing 3) In X11 - handling Leave/Enter Notify events that occur during keyboard grabbing/ungrabbing 4) In X11 - fix for focus events that are handled in the wrong order (happens when focus events occur during grabbing the keyboard) 5) In X11 - ignoring key release events during key holding 6) In Windows - synchronizing keyboard release events that occured during a modal loop 2009-11-09 Izik Eidus spice: client: gl: fix glx support. Just move around touch_context and untouch_context to be at the right places. client: fix colormap handling. 2009-11-09 Yonit Halperin spice client: tunnel channel - checking that the configuration pipe listener was created before deleting it spice client: calling the timers during modal loop in Windows spice client: fixed missing AutoRef spice client: remove timer interface from platform - use Application (via ProcessLoop interface). 2009-11-09 Izik Eidus spice server: fix gl red_worker: put invalidate at the right places 2009-11-09 Yonit Halperin spice client: cosmetic changes spice client: Transfer all channels run loop from EventsLoop class to ProcessLoop class spice client: creating a general process loop. The process loop is responsible for: 1) waiting for events 2) timers 3) events queue for actions that should be performed in the context of the thread and are pushed from other threads. The benefits: 1) remove duplicity: till now, there was one implementaion of events loop for the channels and another one for the main thread. 2) timers can be executed on each thread and not only on the main thread. 3) events can be pushed to each thread and not only to the main thread. In this commit, only the main thread was modified to use the new process loop. 2009-10-27 Yaniv Kamay fix win client copyright string fix bad initialization of XDisplay in case crt have more then one output 2009-10-26 Yaniv Kamay fix build on Debian 2009-10-25 Izik Eidus spice: move create and destroy of the canvas to new place work around for xlib threaded bugs spice xclient: move xsync() to be at the right place. 2009-10-18 Yonit Halperin tunnel 2009-10-14 Yaniv Kamay change development version to 0.5.0 fresh start