Commit Graph

1234 Commits

Author SHA1 Message Date
Frediano Ziglio
068bf4e83d prevent integer overflow on 32 bit
On 32 bit machine timespec->tv_sec (time_t) is 32 bit.
Also 1000 * 1000 * 1000 is 32 bit.
The multiplication of 2 32 bit integers gives a 32 bit integer, however
this can overflow.
Converting the first factor to 64 bit before the multiplication solves
the issue.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-08-26 15:24:09 +01:00
Frediano Ziglio
6001d8905e remove unused SAME_PIXEL macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-08-26 15:23:15 +01:00
Christophe Fergeau
09394e857f build-sys: Remove test_spice_version.h
This script was used at make distcheck time to verify consistency of the
version number defined in configure.ac and in spice-server headers.
Since commit ab12cf414c, these 2 version numbers can no longer be out of
sync, so we can drop this script.
2015-08-26 11:01:09 +02:00
Christophe Fergeau
2e88eb705b server: Readd spice-experimental.h
Commit 3c6b4e41 removed spice-experimental.h as this header was not
used, nor supposed to be used. However, QEMU had been including it
(without using any of its symbols) until commit v2.3.0-rc0~135^2~1

As this is fairly recent (Nov 2014), building older QEMUs with new
spice-server releases, or even bisecting QEMU will be broken as they
will be looking for a no-longer available header.

This commit readds a spice-experimental.h file, however it only contains
a #warning indicating this file is deprecated. This means older QEMU
will build now, but only if they were configured with --disable-werror.
2015-08-26 11:01:09 +02:00
Frediano Ziglio
3a5fb1c5e5 remove wrong statement terminator from preprocessor macro
Actually not causing problems as when used is always followed by another
terminator but better to fix the definition.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2015-08-25 16:26:49 +01:00
Frediano Ziglio
49c0d2e698 Use MAX macro to compute the maximum value
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-08-25 16:24:07 +01:00
Frediano Ziglio
66a4af75e3 replay: use plain pthread for mutex/condition
Mutex/conditional require Glib 2.32 which is not available in RHEL6.
Use plain pthread to make this module compatible with RHEL6.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidencio <ffidenci@redhat.com>
2015-08-25 11:17:42 +01:00
Frediano Ziglio
f01c462031 replay: fix check for QXL_SURF_FLAG_KEEP_DATA flag
A logical and (&&) was used instead of a bit one (&).
Was working just as is the only flag defined.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidencio <ffidenci@redhat.com>
2015-08-25 10:50:18 +01:00
Frediano Ziglio
a9e34bd27a worker: remove unused members from Drawable
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-08-24 13:40:18 +01:00
Alon Levy
622cb433a8 server/tests/spice-server-replay: introduce
usage: spice-server-replay -p <port> -c <client command line> <cmdfile>

will run the commands from cmdfile ignoring timestamps, right after a
connection is established from the client, and will SIGINT the client
on end of cmdfile, and exit itself after waiting for the client.

spicy-stats from spice-gtk is useful for testing, it prints the summary
of the traffic on each channel.

You can also run with no client by doing:
spice-server-replay <cmdfile>

For example, the 300 MB file (compressed to 4 MB with xz -9) available
at [1] produces the following output:

spicy-stats total bytes read:
total bytes read:
inputs: 214
display: 1968983
cursor: 390
main: 256373

You could run it directly like so:
curl http://annarchy.freedesktop.org/~alon/win7_boot_shutdown.cmd.xz | \
  xzcat | server/tests/spice-server-replay -p 12345 -c `which spicy-stats` -

Known Problems:
* Implementation is wrong. Should do a single device->host conversion
 (i.e. get_virt), and then marshall/demarshall that (i.e. RedDrawable).
* segfault on file read done resulting in the above spicy-stats not
 being reproducable (well, up to 1% yes).

[1] http://annarchy.freedesktop.org/~alon/win7_boot_shutdown.cmd.xz

Now based on glib including using an asyncqueue for reading the playback
file, and proper freeing of the allocated commands, with --slow,
--compression and a progress timer, and doesn't use more then nsurfaces.

Signed-off-by: Alon Levy <alon@pobox.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2015-08-22 12:36:37 +01:00
Alon Levy
510a6b8dca server/red_worker: record to SPICE_WORKER_RECORD_FILENAME
if the environment variable in the title is set and can be
opened for writing a log of all display commands (no cursor
commands yet) and any QXLWorker calls (particularily primary
create and destroy) will be logged to that file, and possible
to replay using the replay utility introduced later.

For an example file (4 MB download, 300 MB after unpack with xz,
these 300 MB are themselves reduced from 1.2GB using zlib compression
for any chunk):

(old file without a header)
http://annarchy.freedesktop.org/~alon/win7_boot_shutdown.cmd.xz

Signed-off-by: Alon Levy <alon@pobox.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2015-08-21 09:38:44 +01:00
Alon Levy
3c7026b180 server/red_{record, replay}.[ch]: introduce
Currently hand crafted with some sed scripts and alot of vim macros from
red_parse_qxl after considering the logger in qemu/hw/qxl-logger.c and seeing
it was incomplete. The only problem with logging from the server and
not from qemu is that it requires coordinated shutdown to avoid half a message.

Should be automatically generated from a declarative syntax, i.e. qxl.proto.

Note: zlib compression is introduced in a disabled state, see ZLIB
define

Now with a simple versioned header and generated ids by the server
instead of based on the recorded file, and doesn't use more then 1024
surfaces (configurable).

Signed-off-by: Alon Levy <alon@pobox.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2015-08-21 09:38:44 +01:00
Alon Levy
865455cf32 server/dispatcher: add extra_dispatcher, hack for red_record
Signed-off-by: Alon Levy <alon@pobox.com>
2015-08-20 17:47:24 +01:00
Marc-André Lureau
f3179ef791 tests: use glib main loop 2015-08-20 17:47:24 +01:00
Alon Levy
87c4def087 Remove use of INLINE
It's #define'd to 'inline', and only used in the GLZ encoder.
2015-08-20 17:10:49 +01:00
Christophe Fergeau
5acc017638 build-sys: Remove spice-protocol submodule
It's seeing regular releases and is API stable, so we don't need to
bundle it with spice-server
2015-08-20 12:30:55 +01:00
Victor Toso
bdeef8b292 mjpeg and jpeg encoder: fix alignment warnings
As the input line could be uint8_t*, uint16_t* or uint32_t*, changing
the default from uint8_t* to void* seems the correct choice to deal with
upcasting warnings.

Regarding chunks->data allocation, I quote Frediano explantion:
"Lines came from spice_bitmap_get_line. This function assume that bitmap
data is split among chunks each containing some lines
(always full lines). If chunk->data is allocated using malloc or similar
SHOULD (not 100% sure) be 4 bytes aligned so in our cases
(8, 16, 24 or 32 bit images) should be aligned enough.

All the casts unfortunately came from the fact we compute based on
pixel bytes to make it generic so we use uint8_t*."

and

"Looking at code looks like these chunks came from the virtual machine.
So the question is... why should the virtual machine give use some
not-pixel align data?
I would put a large comment to state that we assume VM send aligned
data, would be stupid for the VM to not align it!"

clang output:
jpeg_encoder.c:109:26: error: cast from 'uint8_t *'
(aka 'unsigned char *') to 'uint16_t *' (aka 'unsigned short *')
increases required alignment from 1 to 2 [-Werror,-Wcast-align]
  uint16_t *src_line = (uint16_t *)line;
                       ^~~~~~~~~~~~~~~~

jpeg_encoder.c:144:26: error: cast from 'uint8_t *'
(aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *')
increases required alignment from 1 to 4 [-Werror,-Wcast-align]
  uint32_t *src_line = (uint32_t *)line;
                       ^~~~~~~~~~~~~~~~

mjpeg_encoder.c:260:23: error: cast from 'uint8_t *'
(aka 'unsigned char *') to 'uint16_t *' (aka 'unsigned short *')
increases required alignment from 1 to 2 [-Werror,-Wcast-align]
  uint16_t pixel = *(uint16_t *)src;
                    ^~~~~~~~~~~~~~~
2015-08-20 11:22:59 +01:00
Victor Toso
2413484305 glz: WindowImageSegment lines lines_end as void*
Instead of using uint8_t* which can cause several warnings on casting as
the example below:

./glz_encode_tmpl.c:321:29: error: cast from 'uint8_t *'
(aka 'unsigned char *') to 'rgb16_pixel_t *' (aka 'unsigned short *')
increases required alignment from 1 to 2 [-Werror,-Wcast-align]
 ref_limit = (PIXEL *)(seg->lines_end);
              ^~~~~~~~~~~~~~~~~~~~~~~~~
2015-08-20 11:09:00 +01:00
Victor Toso
fd75632a8f migration_protocol: use SPICE_MAGIC_CONST
spice-protocol has a new define to create the magic constants, let's use
that.
2015-08-20 10:54:56 +01:00
Victor Toso
94e55bce42 red_parse_qxl: Do not compute abs unsigned int
SpiceBitmap's stride is uint32_t.

from clang:
red_parse_qxl.c:452:41: error: taking the absolute value of unsigned
type 'uint32_t' (aka 'unsigned int') has no effect

bitmap_size = red->u.bitmap.y * abs(red->u.bitmap.stride);
                                ^
2015-08-12 12:29:52 +02:00
Alon Levy
a5ec6a2923 server/inputs_channel: Cope with NULL keyboard in release_keys()
This fixes a test_display_no_ssl segfault on client disconnect when
the keyboard was never initialized.
2015-08-12 10:28:57 +02:00
Victor Toso
648808e282 red_parse_qxl: remove unused variable 2015-08-11 17:24:38 +02:00
Jonathon Jongsma
a58e123c4b Remove unused struct RedsOutItem 2015-08-11 17:24:36 +02:00
Jonathon Jongsma
73fafae5c7 RedChannel: remove unused BufDescriptor struct 2015-08-11 17:24:36 +02:00
Christophe Fergeau
4243d2a645 Remove unused snd_get_playback_compression() method 2015-08-11 17:24:36 +02:00
Christophe Fergeau
295dadbf94 Fix typo in comment in char_device.h 2015-08-11 17:24:36 +02:00
Jonathon Jongsma
3c39371b57 Fix typo in comments 2015-08-11 17:24:36 +02:00
Jonathon Jongsma
ff97799487 Move RedsMigSpice to main-channel.h
This is the place that needs the complete type definition. If it is
defined in reds.h, it can create circular references.
2015-08-11 17:24:36 +02:00
Jonathon Jongsma
0eaf34c04b Cleanup: move static function declarations out of header
It doesn't make much sense to have static function declarations in a
header, even a private header. So move them down into the source file.
2015-08-11 17:24:36 +02:00
Marc-André Lureau
e4bbdc3391 worker: remove unused preload_group_id 2015-08-11 17:24:36 +02:00
Marc-André Lureau
26dc05edc4 channel: minor simplification 2015-08-11 17:24:36 +02:00
Marc-André Lureau
6a38af37fc server: remove unused CursorData 2015-08-11 17:24:36 +02:00
Marc-André Lureau
3da1e1ed0c server: use more const CoreInterface 2015-08-11 17:24:36 +02:00
Marc-André Lureau
e3187ebd29 worker: move red_init_*() functions
There is a red_init() methods, we can group all the red_init_*() calls
in it rather than calling red_init() followed by all these calls in our
main function.
2015-08-11 17:21:59 +02:00
Christophe Fergeau
de66161c6e Adjust to new SpiceImageCompress name
This has been renamed to SpiceImageCompression in order to avoid clashes
with older spice-server in the SPICE_IMAGE_COMPRESS_ namespace. This
commit is a straight rename of SpiceImageCompress to
SpiceImageCompression and SPICE_IMAGE_COMPRESS_ to
SPICE_IMAGE_COMPRESSION_
2015-07-29 17:40:48 +02:00
Jeremy White
04d9d79013 Add libraries such as -lm and -lpthread to the tests build line.
This prevents a compile error on Debian Jessie, from git, such as this:
/usr/bin/ld: test_playback.o: undefined reference to symbol 'sin@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line

This is fairly subtle, and Debian specific.  It only happens when you use
autoreconf to generate a new libtool script.  Debian patches that script
to require an explicit setting to link with all dependent libraries.

It should be harmless on other distros, and it does save us Debian guys some
hassle.
2015-07-28 10:12:46 -05:00
Frediano Ziglio
40537f6a3e reds: Assure we don't have stale statistic files before trying to create a new one
If a previous Qemu executable is not able to delete the statistic file
on the next creation with same name (statitics file are based on pid
numbers so if pid get reused for another Qemu process you get the same
name) it fails as you can't open a file with 0444 permissions (these
are the permission used to create these files).
This patch assure there are no stale file trying to remove it before the
creation of the new one. As file is based on pid and name used for spice
you are not deleting another file.

Fixes: rhbz#1177326

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-07-20 11:19:28 +02:00
Francois Gouget
660bee0e93 server: spice_debug() messages don't need a trailing '\n'.
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-07-20 11:15:55 +02:00
Francois Gouget
212ee28a64 server: Weakly try to get a better latency value for the bandwidth test.
NET_TEST_WARMUP_BYTES is 0 so the warmup ping is the same as the one we
use to measure the latency. Even if it was not, the actual latency would
be the MIN() of both anyway so we might as well use both roundtrip times
to ward off latency jitter a bit.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-07-20 11:15:55 +02:00
Francois Gouget
1a8a7df286 server: Don't reset the latency before showing it in the invalid net test error message.
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-07-20 11:15:55 +02:00
Pavel Grunt
071647780d Use desired image compression for the first image
red_marshall_image() allows to use other than QUIC compression only
when auto_lz or auto_glz image compression is set. Other images don't
have the problem because they are compressed using red_compress_image()
2015-07-13 11:52:09 +02:00
Javier Celaya
c914e96fb4 Handle preferred image compression messages 2015-06-30 16:49:29 +02:00
Javier Celaya
22c40b9d1f Use image compress constants from spice-protocol 2015-06-30 16:49:29 +02:00
Francois Gouget
aa22138d05 server: Remove the rate_control_is_active field from MJpegEncoder.
It is redundant with the corresponding callbacks.
2015-06-29 18:04:12 +02:00
Francois Gouget
a45ff74b3d server: Fix an incorrect time calculation.
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-06-29 17:50:26 +02:00
Sandy Stutsman
e4a42e50c2 Lock the pixmap image cache for the entire fill_bits call
Locking the individual calls that access the pixmap cache in fill_bits is
not adequately thread safe.  Often a windows guest with multiple monitors
will be sending the same image via different threads.  Both threads can
be in fill_bits at the same time making changes to the cache for the same
image.  This can result in images being deleted before all the client
channels are finished with them or with the same image being send multiple
times.  Here's what can happen with out the lock in fill_bits

On the server in red_worker.c:fill_bits
 Thread 1 calls pixmap_cache_hit for Image A and finds it isn't in cache
 Thread 2 calls pixmap_cache_hit for Image A and finds it isn't in cache

 Thread 1 adds Image 1 to pixmap_cache (1x)
 Thread 2 adds Image 1 to pixmap_cache (2x)

On the client
 Channel 1 adds Image A to image_cache (1x)
 Channel 2 replaces Image A in image_cache (1x)

On server
 Thread 1 sends Image A rendering commands
 Thread N removes Image A from pixmap_cache (image remains - 1x)
 Thread 2 sends Image A rendering commands

On client
 Channe1 renders from Image A
 Channel N removes Image a from image_cache (image is completely removed)
 Channel2 render command hangs waiting for Image A
2015-06-29 13:21:14 +02:00
Frediano Ziglio
6d4e58f70d server: allows to set maximum monitors
spice-server will attempt to limit number of monitors.
Guest machine can send monitor list it accepts. Limiting the number sent
by guest will limit the number of monitors client will try to enable.
The guest usually see client monitors enabled and start using it so
not seeing client monitor won't try to enable more monitor.
In this case the additional monitor guest can support will always be
seen as heads with no attached monitors.
This allows limiting monitors number without changing guest drivers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-06-26 16:17:42 +02:00
Francois Gouget
f017d7a421 mjpeg: Convert rate control checks to asserts in encoder
The checks would lead the reader to think these functions can be called
when bit rate control is off when in fact they are only called when it
is active.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-06-22 19:47:58 +02:00
Francois Gouget
03af3f382d server: Refresh the input fps every 5 second, without a timer.
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-06-22 19:47:58 +02:00
Marc-André Lureau
55bc82f070 reds: increase listening socket backlog
With a TCP socket, the backlog doesn't seem to matter much,
perhaps because of latency or underlying protocol behaviour. However,
on UNIX socket, it is fairly easy to reach the backlog limit and the
client will get an EAGAIN error (but not ECONNREFUSED as stated in
listen(7)) that is not easy to deal with: attempting to reconnect in a
loop might busy-loop forever as there are no guarantee the server will
accept new connections, so it will be inherently racy.

Typically, Spice server can easily have up to 15 concurrent incoming
connections that are established during initialization of the session.
To improve the situation, raise the backlog limit to the default maximum
system value, which is 128 on Linux.
2015-06-17 15:58:56 +02:00