Commit Graph

4164 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
b29f678984 build: Disable Celt support by default
We started disabling Celt support making the option required.
After 2 releases start making it disabled unless explicitly
enabled.

This makes https://gitlab.freedesktop.org/spice/spice/merge_requests/2
obsolete.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-06-13 09:42:12 +01:00
Frediano Ziglio
4394cc9733 ci: Add test for 32 bit CentOS 7
Make sure the project compile and pass tests without problems
on a 32 bit architecture.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-06-13 09:06:05 +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
177a7d3833 ci: Remove dependencies from copr build
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Snir Sheriber <ssheribe@redhat.com>
2019-06-13 08:05:28 +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
Frediano Ziglio
69c27d59be Update spice-common submodule
This brings in the following changes:

Frediano Ziglio (4):
      gitignore: Ignore auto generated generated_messages.h file
      Do not check for HAVE_CONFIG_H
      build: Remove unused git-version-gen file
      recorder: Update

Uri Lublin (1):
      codegen Makefile: add common/ to --include client_marshallers.h

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-06-12 14:52:15 +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
Thiago Mendes
6470b537d6 Converting Spice_for_newbies.odt to AsciiDoctor format
https://gitlab.freedesktop.org/spice/spice-server/issues/10

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-31 15:06:10 +01:00
Thiago Mendes
ddb2795b65 Converting Spice_protocol.odt to Asciidoc
https://gitlab.freedesktop.org/spice/spice-server/issues/10

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-31 15:01:54 +01:00
Thiago Mendes
b052fb73b6 Converting Vd_interfaces.odt to Asciidoc
https://gitlab.freedesktop.org/spice/spice-server/issues/10

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-31 15:01:37 +01:00
Frediano Ziglio
70f75c0f33 syntax-check: Add missing contributors names to AUTHORS
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-31 05:58:58 +01: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
Frediano Ziglio
5ee2af0fe5 docs: Remove obsolete paragraph
ClientCbs were removed, all is automated in RedChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-29 10:23:40 +01:00
Frediano Ziglio
c52b88c895 docs: Add some notes on event scheduling and threading
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-29 10:23:35 +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