Commit Graph

418 Commits

Author SHA1 Message Date
Fabiano Fidêncio
6b4c036bdb Do not compress bitmaps on UNIX socket
On UNIX socket do not perform unnecessary image compression
2015-02-25 17:18:29 +01:00
Javier Celaya
10c78a0197 LZ4: Send the original format with the compressed data 2015-02-03 10:39:16 +01:00
Javier Celaya
16412aa101 LZ4: Do not reverse bottom-up images
Reversing the bottom-up images in the server is not needed since Pixman,
in the client, is able to deal with them. As a result, the previous code
was more complex and wrong. This commit fixes and cleans it.
2015-02-03 10:39:16 +01:00
Javier Celaya
d6f22b2787 LZ4: Limit LZ4 to RGB formats
Currently, the LZ4 encoding only (partially) supports RGB images, so
we must check the image format before using it. In the future, indexed
formats may be implemented too, but their use is usually very small
compared to RGB.
2015-02-03 10:39:16 +01:00
Javier Celaya
b532ef0866 Add LZ4 compression support.
- Add lz4 encoder to compress an image of type LZ4 (see spice_common).
- Add code in red_worker to use LZ4 when it is enabled, and the client
  supports it through its display capability, or fallback to LZ.
- Add enable_lz4 switch in the configure script. Show LZ4 support at the
  end.
2014-12-02 19:41:17 +01:00
Marc-André Lureau
c541d7e29d Remove guest side video time-stamping
The multimedia time is defined by the server side monotonic time [1],
but the drawing time-stamp is done in guest side, so it requires
synchronization between host and guest. This is expensive, when no audio
is playing, there is a ~30x/sec wakeup to update the qxl device mmtime,
and it requires marking dirty the rom region.

Instead, the video timestamping can be done more efficiently on server
side, without visible drawbacks.

[1] a better timestamp could be the audio time, since audio players are
    usually sync with audio time)

Related to:
https://bugzilla.redhat.com/show_bug.cgi?id=912763
2014-11-27 14:27:41 +01:00
Marc-André Lureau
c9685014e7 Validate RedDrawable before allocating drawable
Avoid unnecessary allocation (and possibly leaking) if the RedDrawable
is not valid.

Related to: rhbz#1135372
2014-11-25 15:37:45 +01:00
Christophe Fergeau
e270edcbfd Validate surface bounding box before using it
It's possible for a buggy guest driver to pass invalid bounding box
dimensions in QXL commands, which would then cause spice-server to
segfault. This patch checks the size of the bounding box of the QXL
command right after it has been parsed.

This fixes rhbz#1135372
2014-09-18 14:06:55 +02:00
Christophe Fergeau
2cc42d9358 Fix 'abberiviations' typo in comment 2014-09-18 14:06:55 +02:00
Marc-André Lureau
1898f3949c Fix crash when clearing surface memory
The beginning of the surface data needs to be computed correctly if the
stride is negative, otherwise, it should point already to the beginning
of the surface data. This bug seems to exists since 4a208b (0.5.2)

https://bugzilla.redhat.com/show_bug.cgi?id=1029646
2014-08-07 11:38:02 +02:00
Wang Qiang
e7db94d833 Fix make failed when uncommented COMPRESS_STAT in red_worker.c
https://bugs.freedesktop.org/show_bug.cgi?id=79246
As a developer, I maybe want to see the detail compress stat of spice, like this:
Method   	  count  	orig_size(MB)	enc_size(MB)	enc_time(s)
QUIC     	     846	       948.02	      147.22	        7.51
GLZ      	    2895	       594.90	       26.60	        1.33
ZLIB GLZ 	       0	         0.00	        0.00	        0.00
LZ       	       1	         3.15	        0.01	        0.00
JPEG     	       0	         0.00	        0.00	        0.00
JPEG-RGBA	       0	         0.00	        0.00	        0.00
----------------------------------------------------------------------------
Total    	    3742	      1546.07	      173.83	        8.84

But when I uncommented the COMPRESS_STAT and COMPRESS_DEBUG in red_worker.c and make.
I got some error(in Bugzilla). This error because of some simple syntax errors.
Commit this patch to fix this issue.

Signed-off-by: Wang Qiang <wangqiang.hunan@gmail.com>
2014-05-26 18:51:36 +02:00
소병철
3cb746329e Use PRI macros in printf to keep compatibility between 32/64bit system
gcc's some integer type definitions are different between 32/64bit system.
This causes platform dependency problem with printf function. However,
we can avoid this problem by using PRI macros that supports platform
independent printf.
2014-05-15 14:45:58 +02:00
Christophe Fergeau
8b347a641c Add reds_stream.[ch]
Gather common RedsStream code there rather than having it
in reds.c
2014-01-20 12:15:41 +01:00
Christophe Fergeau
df96538e1f Fix 'recive' typo throughout the code base
'receive' was mispelt 'recive' in multiple places.
2013-10-08 19:07:42 +02:00
Christophe Fergeau
394fd0e6b7 Namespace RECEIVE_BUF_SIZE 2013-10-08 19:07:41 +02:00
Marc-André Lureau
b18d867b31 server: handle red_get_surface_cmd() error explicitely
Don't ignore red_get_surface_cmd() error, and explicitely interrupt and
free cmd before processing.
2013-10-07 16:33:21 +02:00
Marc-André Lureau
1f12fa72cc server: plug some leaks on error
Plug what looks like memory leaks, that could be potentially be
triggered by a misbehaving guest.
2013-10-07 16:33:21 +02:00
Marc-André Lureau
9a485b64ea server: remove unused fill_rects_clip
Unused since 62d0c076eb.
2013-09-30 13:58:47 +02:00
Yonit Halperin
90a4761249 red_worker: disconnect the channel instead of shutdown in case of a blocking method failure
rhbz#1004443

The methods that trigger waitings on the client pipe require that
the waiting will succeed in order to continue, or otherwise, that
all the living pipe items will be released (e.g., when
we must destroy a surface, we need that all its related pipe items will
be released). Shutdown of the socket will eventually trigger
red_channel_client_disconnect (*), which will empty the pipe. However,
if the blocking method failed, we need to empty the pipe synchronously.
It is not safe(**) to call red_channel_client_disconnect from ChannelCbs
, but all the blocking calls in red_worker are done from callbacks that
are triggered from the device.
To summarize, calling red_channel_client_disconnect instead of calling
red_channel_client_shutdown will immediately release all the pipe items that are
held by the channel client (by calling red_channel_client_pipe_clear).
If red_clear_surface_drawables_from_pipe timeouts,
red_channel_client_disconnect will make sure that the surface we wish to
release is not referenced by any pipe-item.

(*) After a shutdown of a socket, we expect that later, when
red_peer_handle_incoming is called, it will encounter a socket
error and will call the channel's on_error callback which calls
red_channel_client_disconnect.

(**) I believe it was not safe before commit 2d2121a170 (before adding ref
count to ChannelClient). However, I think it might still be unsafe, because
red_channel_client_disconnect sets rcc->stream to NULL, and rcc->stream
may be referred later inside a red_channel_client method unsafely. So instead
of checking if (stream != NULL) after calling callbacks, we try to avoid
calling red_channel_client_disconnect from callbacks.
2013-09-26 13:58:43 -04:00
Yonit Halperin
bcf9e64f13 red_channel: cleanup of red_channel_client blocking methods
(1) receive timeout as a parameter.
(2) add a return value and pass the handling
    of failures to the calling routine.
2013-09-26 10:48:40 -04:00
Yonit Halperin
6c2ff9864d red_worker: cleanup red_clear_surface_drawables_from_pipes
(1) merge 'force' and 'wait_for_outgoing_item' to one parameter.
    'wait_for_outgoing_item' is a derivative of 'force'.
(2) move the call to red_wait_outgoing_item to red_clear_surface_drawables_from_pipe
2013-09-26 10:48:40 -04:00
Yonit Halperin
d0a1346fda red_worker: fix call to dump_bitmap (too many args) 2013-08-22 16:12:07 -04:00
Alon Levy
ee382109a6 server: split spice_image_cache from red_worker 2013-08-14 12:08:04 +03:00
Alon Levy
1bbce9ba05 server/red_worker: s/image_cache_eaging/image_cache_aging/ 2013-08-14 12:08:04 +03:00
Alon Levy
7241cc9544 server: move surface_format_to_image_type to spice_bitmap_utils 2013-08-14 12:08:04 +03:00
Alon Levy
9b8ff04284 server: s/red_wait_all_sent/red_channel_wait_all_sent/ 2013-08-14 12:08:04 +03:00
Alon Levy
bc50ff0767 server: move three functions to red_channel
Three blocking functions, one was split to leave the display channel
specific referencing of the DrawablePipeItem being sent inside
red_worker, but the rest (most) of the timeout logic was moved to
red_channel, including the associated constants.

Moved functions:
red_channel_client_wait_pipe_item_sent
red_wait_outgoing_item
red_wait_all_sent

Introduces red_time.h & red_time.c for a small helper function dealing
with time.h
2013-08-14 12:08:04 +03:00
Alon Levy
fe38ddf724 server: move bit set/clear utilities out of red_worker.h 2013-08-14 12:08:04 +03:00
Alon Levy
376264b009 server: move dump_bitmap to separate file 2013-08-14 12:08:04 +03:00
Alon Levy
ff672924ca server/red_worker.c:red_process_drawable: rename item to drawable 2013-08-14 12:08:04 +03:00
Alon Levy
3a25c20704 server/red_worker.c:red_process_drawable: rename drawable to red_drawable 2013-08-14 12:08:04 +03:00
Alon Levy
478a1906b0 red_worker: mark DRAW_ALL as broken
setting DRAW_ALL define doesn't produce correct rendering. Using
update_area instead of red_draw_qxl_drawable will work but it shouldn't
be required. This is not work I intend to do right now, so marking it
for anyone looking at this in the future.
2013-08-14 12:07:50 +03:00
Yonit Halperin
6ced0f6985 red_worker: decrease the timeout when flushing commands and waiting for the client.
150 seconds is way too long period for holding the guest driver and
waiting for a response for the client. This timeout was 15 seconds, but
when off-screen surfaces ware introduced it was arbitrarily multiplied by
10.
Other existing related bugs emphasize why it is important to decrease
the timeout:
(1) 994211 - the qxl driver waits for an async-io reponse for 60 seconds
    and after that, it switches to sync-io mode. Not only that the
    driver might use invalid data (since it didn't wait for the query to
    complete), falling back to sync-io mode introduces other errors.
(2) 994175 - spice server sometimes doesn't recognize that the client
             has disconnected.
(3) There might be cache inconsistency between the client and the server,
and then the display channel waits indefinitely for a cache item (e.g., bug
977998)

This patch changes the timeout to 30 seconds. I tested it under wifi +emulating 2.5Mbps network,
together with playing video on the guest and changing resolutions in a loop. The timeout didn't expired
during my tests.

This bug is related to rhbz#964136 (but from rhbz#964136 info it is still not
clear why the client wasn't responsive).
2013-08-06 14:28:34 -04:00
Alon Levy
51511a51cf server/red_worker.c: remove unused pipe_item_remove 2013-07-24 14:56:54 +03:00
Uri Lublin
d6092f11b6 syntax-check: remove trailing whitespaces
Only whitespace changes in this commit.
2013-07-16 23:37:29 +03:00
Uri Lublin
cf905b7b68 red_worker: use a generic SAFE_FOREACH macro
Introduce SAFE_FOREACH macro

Make other safe iterators use SAFE_FOREACH
2013-07-16 23:37:26 +03:00
Uri Lublin
6c95bb3c59 red_worker: delete unused CCC_FOREACH 2013-07-16 23:37:26 +03:00
Uri Lublin
57dba5615e red_worker: make DRAWABLE_FOREACH_DPI safe 2013-07-16 23:37:26 +03:00
Uri Lublin
2af81e96f5 red_worker: use only DRAWABLE_FOREACH_GLZ_SAFE 2013-07-16 23:37:25 +03:00
Uri Lublin
b1330fcd5d 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.
2013-07-16 23:37:25 +03:00
Uri Lublin
e4029833da red_worker: reuse DCC_FOREACH in WORKER_DCC_FOREACH
The only thing that is needed is to get the channel out of the worker.
2013-07-16 23:37:25 +03:00
Uri Lublin
255abf0a57 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-16 23:37:25 +03:00
Yonit Halperin
b83c0fbf7f 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-25 14:13:13 -04:00
Yonit Halperin
648117544f red_worker: improve stream stats readability and ease of parsing
also added start/end-bit-rate and avg-quality to the final stream stats.
2013-06-24 15:23:34 -04:00
Alon Levy
3ace9a3333 server/red_worker: simplify monitors_config update 2013-05-17 11:06:34 -04:00
Alon Levy
f844a995bb 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.
2013-05-17 11:06:34 -04:00
Alon Levy
97459ddfdb server/red_worker: s/driver_has_monitors_config/driver_cap_monitors_config/ (plus small comment) 2013-05-17 11:06:29 -04:00
Yonit Halperin
c09faf2382 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-09 17:05:55 -04:00
Yonit Halperin
20cc956764 red_worker: fail handle_migrate_data instead of aborting when there is an error during restoration of surfaces 2013-05-08 11:26:57 -04:00
Yonit Halperin
f50827e527 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 <marcandre.lureau@redhat.com>
2013-05-08 09:41:04 -04:00