Commit Graph

3205 Commits

Author SHA1 Message Date
Frediano Ziglio
0c2f386beb websocket: Fix updating remaining bytes to write in websocket_write
"len" is not always the full remainder (consider the case when
we are writing a partial frame).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:50 +01:00
Frediano Ziglio
9f1417c11f websocket: Propagate some variable
These were introduced moving code around.
No more reason to copy, just use directly structure fields.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:48 +01:00
Frediano Ziglio
6b41f3b542 websocket: Better variable types
"type" is just 8 bit.
"frame_ready" and "masked" as booleans.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:46 +01:00
Frediano Ziglio
007e009bc3 websocket: Detect and handle some header error
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:43 +01:00
Frediano Ziglio
55df5fa841 websocket: Better encapsulation
Move websocket structure declarations to C file.
Make some functions static as now not used externally.
Introduce a websocket_free function for symmetry.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:40 +01:00
Frediano Ziglio
a5c05ad845 websocket: New interface to create RedsWebSocket
Less coupling. This is a preparation for next patch.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:38 +01:00
Frediano Ziglio
b5f3ed1502 websocket: Make websocket_ack_close static
It's used only in websocket.c.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:36 +01:00
Frediano Ziglio
bbfb472154 websocket: Make websocket function more ABI compatibles with RedStream
Use same argument types as red_stream_* functions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:33 +01:00
Frediano Ziglio
98c183a6f6 websocket: Move RedsWebSocket to header
Intention is to make private in websockets.c and reduce
changes in red-stream.c

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:31 +01:00
Frediano Ziglio
26fad876a0 websocket: Simplify and fix constrain_iov
Use g_memdup instead of manual copy.
Trim the original iov if necessary.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:29 +01:00
Jeremy White
cd2a317096 Add support for clients connecting with the WebSocket protocol.
We do this by auto detecting the inbound http(s) 'GET' and probing
for a well formulated WebSocket binary connection, such as used
by the spice-html5 client.  If detected, we implement a set of
cover functions that abstract the read/write/writev functions,
in a fashion similar to the SASL implementation.

This includes a limited implementation of the WebSocket protocol,
sufficient for our purposes.

Signed-off-by: Jeremy White <jwhite@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-06-26 14:18:27 +01:00
Frediano Ziglio
214736dce6 reds: Fix SSL_CTX_set_ecdh_auto call for some old OpenSSL
SSL_CTX_set_ecdh_auto is not defined in some old versions of OpenSSL

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:25 +01:00
Frediano Ziglio
89b0a07c72 test-glib-compat: Fix G_PID_FORMAT definition for old systems
The G_PID_FORMAT constant is defined only if GLib does not support it.
The constant was wrongly defined.
Jessie Debian 32 shows this issue (printf format error).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jeremy White <jwhite@codeweavers.com>
2019-06-26 14:18:17 +01:00
Frediano Ziglio
11b0a58bbf dcc-send: Check some constants at compile time
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-06-24 09:41:35 +01:00
Frediano Ziglio
fce721cbe7 cache-item: Remove unused define
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-06-21 08:30:56 +01:00
Frediano Ziglio
94e1d52ff6 cache-item: Remove only written fields
cursor_cache_items and palette_cache_items where only written
but never used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-06-21 08:30:56 +01:00
Frediano Ziglio
bf968572d1 display-channel: Avoid potential crash from buggy guest driver
This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1582137.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Snir Sheriber <ssheribe@redhat.com>
2019-06-20 09:57:09 +01:00
Frediano Ziglio
1a3c0b1ee6 jpeg: Support big endian machines
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-06-19 10:36:10 +01:00
Frediano Ziglio
6412760873 Remove a warning on MIPS machine
The formula is here to make sure glyph is aligned to 4 bytes so
tell to the compiler to avoid a warning.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-06-19 10:30:06 +01:00
Frediano Ziglio
47cbfd4c59 Use SPICE_CONTAINEROF to avoid some possible alignment warnings on MIPS
This patch came from some experiments using an emulated MIPS machine.
On such architecture due to not supporting alignment access the
compiler is more strict about conversion complaining with some
pointer casts. Use different conversion to avoid these warnings.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-06-18 09:48:28 +01:00
Frediano Ziglio
f90f75e41c red-stream: Fix compilation on Fedora 30 for Windows using MingW
On Windows Fedora 30 reports these errors:

In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/openssl/crypto.h:29,
                 from /usr/x86_64-w64-mingw32/sys-root/mingw/include/openssl/bio.h:20,
                 from /usr/x86_64-w64-mingw32/sys-root/mingw/include/openssl/err.h:21,
                 from red-stream.c:31:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/openssl/x509.h:75:1: error: pasting "stack_st_" and "(" does not give a valid preprocessing token
 DEFINE_STACK_OF(X509_NAME)
 ^~~~~~~~~~~~~~~
/usr/x86_64-w64-mingw32/sys-root/mingw/include/openssl/x509.h:75:17: error: expected ')' before numeric constant
 DEFINE_STACK_OF(X509_NAME)
                 ^~~~~~~~~
...

This is due to missing X509_NAME definition by Windows headers.
Including the network header on Windows solves this problem.
This is consistent with reds.c file.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-06-13 12:53:37 +01:00
Frediano Ziglio
0002d1a93c Remove compile warnings on Linux 32bit system
Based on a patch from Hongzhi.Song <hongzhi.song@windriver.com>.

There are following compile errors on Linux 32bit system with -Werror
for gcc.

red-channel.c:207:73: error: format '%x' expects argument of type
'unsigned int', but argument 7 has type 'long unsigned int' [-Werror=format=]
|207| red_channel_debug(self, "thread_id 0x%" G_GSIZE_MODIFIER "x",
				~~~~~~~~~~~~~~~~~~~~~^
			self->priv->thread_id);
		~~~~~~~~~~~~~~~~~~~~~^

pthread_t is an opaque type so there is no easy way to make the printf
format string portable. However the type must be comparable in C so this
(excluding floating point which does not make sense) means an integral type
or a pointer.
Under *BSD this is a pointer so can be converted without loosing precision
to void*.
Under Linux this is a "unsigned long int" type, being Linux ILP32 or LP64
this means that the size of pthread_t is the same as size_t so can be
converted without loosing precision to void*.
Under MingW (the pthread port to Windows) this is a uintptr_t type that is
can be converted without loosing precision to void*.
On any potential future platforms if the integral type is smaller than a
uintptr_t type (which has the same size of void*) the cast should trigger a
warning and if not won't loose precision; the integral type is unlikely to
be bigger than a pointer and likely the cast would trigger a warning.

The cast on read_binary (red-replay-qxl.c) is safe, "*size" is a size_t
while "strm.total_out" is the number of written bytes in a buffer which
cannot be bigger than a size_t.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-06-13 09:04:01 +01:00
Frediano Ziglio
789e8ce2c6 red-channel: Remove unused declaration
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-06-13 07:44:10 +01:00
Frediano Ziglio
4235121f52 inputs-channel-client: Remove unused declarations
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-06-13 07:44:10 +01:00
Frediano Ziglio
d623b275bd smartcard-channel-client: Fix some typos in a comment
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-06-13 07:38:50 +01:00
Christian Ehrhardt
19f9f454e0 test: fix test-qxl-parsing on ppc64el and armhf
On ppc64el and armhf the handling of "1 << mem_info.memslot_id_shift"
will end up beign a zero which breaks the test.

Marking the implicit value 1 as a 64 bit value (to match the uint64_t
target) fixes the issue.

Fixes #31

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-06-12 14:47:15 +01:00
Francois Gouget
d4251bac5f utils: Remove the LL suffix from NSEC_PER_MILLISEC
This constant fits in a regular 32 bit signed integer so it does not
need the suffix.
It is also not used in expressions that may overflow.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-06-12 10:16:12 +01:00
Francois Gouget
476f19a3c8 gstreamer-encoder: Document get_maximum_frame_size()
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-06-12 10:09:54 +01:00
Frediano Ziglio
581a2d0f68 char-device: Reuse macros to scan GList
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-06-10 13:44:07 +01:00
Frediano Ziglio
e624795747 common-graphics-channel: Avoid closing server if client send huge messages
The Cursor/DisplayChannel is not expecting large messages (which are
protocol violations).

This fixes https://gitlab.freedesktop.org/spice/spice-server/issues/11.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-06-10 13:44:01 +01:00
Frediano Ziglio
a84d9c653e spicevmc: Reuse "sin" variable
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Snir Sheriber <ssheribe@redhat.com>
2019-06-02 14:46:08 +03:00
Frediano Ziglio
a9af580a6e char-device: Fix some comments
Some function names where changed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Snir Sheriber <ssheribe@redhat.com>
2019-06-02 14:44:58 +03:00
worldofpeace
b4a6c1abcc meson: correct some things
We can get source_root from meson, and doing [3]
can give you an out of bounds error in certain cases.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-29 13:14:24 +01:00
Francois Gouget
3d7f1cc512 mjpeg: Pull more code in get_min_required_playback_delay()
This reduces code duplication and passing the MJpegEncoder object
makes it possible to modify the playback calculation without adding
more arguments.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-21 09:05:50 +01:00
Francois Gouget
7515a0ac57 mjpeg: Constify some MJpegEncoder* parameters
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-21 09:05:47 +01:00
Francois Gouget
a8faddf653 gstreamer-encoder: Constify some SpiceGstEncoder* parameters
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-21 08:51:53 +01:00
Francois Gouget
ba4bcd5174 gstreamer-encoder: Return the average frame size as a 32 bit int
It makes no sense to expect average frame sizes anywhere close to 2GB.
But then make sure to avoid arithmetic overflows.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-21 08:48:49 +01:00
Francois Gouget
cfe98800a0 gstreamer-encoder: Show the source fps when the system is too slow
The source framerate is as important as the resolution when trying to
understand if the system should be fast enough to encode the video
stream in real time.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-21 08:46:27 +01:00
Frediano Ziglio
148203a5d2 spice-experimental: Remove obsolete file
This header was removed in 2014 (3c6b4e415) as deprecated and added again
in 2015 (2e88eb705) as causing some issue with former Qemu versions.
After 4 years remove again, now there should not be any usage of it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Snir Sheriber <ssheribe@redhat.com>
2019-05-20 10:11:41 +01:00
Francois Gouget
5ee001a5b0 gstreamer-encoder: Include encoding time in get_min_playback_delay()
This way all the minimum delay calculation is in one place and this
makes gstreamer's implementation closer to the mjpeg one.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-16 08:26:18 +01:00
Francois Gouget
a9c5bb974a mjpeg: Remove the unused MJPEG_LOW_FPS_RATE_TH constant
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-16 08:23:05 +01:00
Francois Gouget
d09c9b43e0 reds: Enable mm_time adjustments on startup
This reinstates the reds_enable_mm_time() call in do_spice_init()
that was removed by commit c541d7e29d.

We send mm_time adjustments to the client whenever there is no audio
playback. There is no audio playback on startup. Therefore
mm_time_enabled must be true on startup. QED.

This fixes adjusting the client mm_time whenever playing a silent
video (or full desktop stream) when no sound has been played before
such as when using Xspice, booting an OS with no startup or login
jingle, or possibly when migrating a VM (per commit 1c154ea5ec).

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-16 08:23:00 +01:00
Frediano Ziglio
07adcce16e dcc: Avoid usage of not aligned GlzEncDictRestoreData structure
Copy to/from unaligned field to avoid potential unaligned access.
Although it adds a copy it's not in a hot path (migration) and
the structure is pretty small.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-05-13 14:15:19 +01:00
Frediano Ziglio
753ebc0e7c test-display-base: Use SPICE_CONTAINEROF to avoid alignment warning
This change prevent a warning issued by GCC 9 and potentially
other compilers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-05-13 14:13:21 +01:00
Frediano Ziglio
d417a0bdfd Disable recording filtering for Windows
Although this feature can be ported to Windows doing so would
require the usage of g_spawn_async_with_fds, which is only available
in GLib 2.58 or some specific Win32 code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:14:33 +01:00
Frediano Ziglio
9a07eb6582 red-stream: Fix SSL connection for Windows
Set correctly errno to make callers handle correctly encrypted
traffic.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:14:31 +01:00
Frediano Ziglio
fd90a9d084 tests: Exclude tests that cannot work on Windows
test-stream test is passing file descriptor using Unix socket.
test-stat-file needs some porting work of mmap feature.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:14:28 +01:00
Frediano Ziglio
d0ae7f157d dispatcher: Port to Windows
Replace poll call with select.
As socket is set to non-blocking we must support it so if
we detect an EAGAIN error wait for data.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:14:26 +01:00
Frediano Ziglio
524acca643 windows: Disable code not working on Windows
- global signals;
- CLOEXEC flag;
- mmap and statistics;
- IPTOS_LOWDELAY flag;
- Unix sockets;
- sharing file descriptors through Unix sockets;
- TCP_CORK flag.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:14:22 +01:00
Frediano Ziglio
c8ab3c2c98 test-channel: Use socket compatibility layer
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-07 10:14:20 +01:00