Commit Graph

3740 Commits

Author SHA1 Message Date
Frediano Ziglio
7cbc80ed04 build-sys: Remove useless definition
The default LDADD already include libserver.la.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-12-12 06:59:25 +00:00
Uri Lublin
ee87a36e95 test-stream: initialize msg.msg_flags
Coverity complains the field is not initialized.
That's true but man recvmsg specifies that this
field is set by recvmsg.

To make coverity happy, initialize this field.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-12-11 10:16:11 +00:00
Uri Lublin
1a16419431 reds_init_socket: do not leak slisten on error
Found by Coverity.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-12-11 10:15:13 +00:00
Christophe Fergeau
7ff434b104 ssl: Drop support for older OpenSSL versions
SSL_OP_NO_COMPRESSION was introduced in OpenSSL_0_9_8k, which is no
longer supported. This commit raises the minimum OpenSSL version to
1.0.0, which is also out of support.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-12-08 15:22:26 +01:00
Christophe Fergeau
dd8e205aaf worker: Remove unneeded include
Nothing seems to be using openssl in red-worker.c

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-12-08 15:22:16 +01:00
Christophe Fergeau
1170282cec build: Use $(srcdir) when it makes sense
There are a few places which use $(top_srcdir) when $(srcdir) would be
equally valid.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-12-08 14:30:51 +01:00
Christophe Fergeau
c9b9a5fd35 build: Rebuild shared library when symbol file changes
At the moment, changing spice-server.syms to add/remove a new symbol to
be exported does not regenerate spice-server.so. This commit added the
needed dependency for this to work.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-12-08 14:30:45 +01:00
Frediano Ziglio
e030f87cf0 Do not compute stream_id more that necessary
Reuse already computed value and avoid to compute in every
iterations.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-12-07 16:11:46 +00:00
Frediano Ziglio
fb85723433 reds: Remove RedVDIReadBuf pooling code
Originally this pool was used to avoid allocation/deallocations.
However the introduction of GList cause the code to do dynamic
allocations in order to update the list making this pooling
something useless.
The buffers limitation is now implemented with a simple counter.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-12-07 16:04:10 +00:00
Frediano Ziglio
7569ff3cc8 test-vdagent: Remove useless MIN definition
Already defined by GLib headers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Maybe this check should just be removed?
2017-12-05 10:54:09 +00:00
Frediano Ziglio
60d8389bcd Handle SPICE_MSGC_DISCONNECTING message in RedChannelClient
There's no reason to handle this message in a different
way in MainChannel and InputsChannel, the default handling
will return true in any case.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Maybe this check should just be removed?
2017-12-05 10:54:09 +00:00
Frediano Ziglio
89c5d062d6 reds: Fix wrong assert
RedVDIReadBuf::data is a static allocated buffer so checking for
NULL on it is useless. It would be NULL only if RedVDIReadBuf
pointer would be the opposite, in value, of the offset of
data field into it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-12-05 10:54:09 +00:00
Frediano Ziglio
ecd9968e91 main-channel: Put all migration message handling together
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-12-05 10:54:09 +00:00
Frediano Ziglio
57e20c1a2d main-channel: Remove brackets if not needed
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-12-05 10:54:09 +00:00
Frediano Ziglio
3fa1623482 main-channel: Remove useless check
If there is a channel client there's surely a related channel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-12-05 10:54:09 +00:00
Frediano Ziglio
fc8e55b77b reds: Remove leak of agent_dev
This object was not freed.
Also free object buffers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-12-05 10:54:03 +00:00
Frediano Ziglio
967876d27d reds: Use GLib memory functions for RedVDIReadBuf
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-12-05 10:51:37 +00:00
Jonathon Jongsma
a337808fa4 StreamDevice: assert preconditions in parsing functions
Be a bit more defensive about handling incoming messages from the stream
device. This also makes these functions consistent with
handle_msg_format(). These assertions are only enabled if
ENABLE_EXTRA_CHECKS is defined.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-12-05 09:00:34 +00:00
Frediano Ziglio
0b9e5e87e1 inputs-channel: Prefer channel core over global core interface
Potentially a channel can run with a different core interface
than the global one attached to RedsState so instead of calling
reds_core_* functions use the code interface attached to the
channel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-12-01 22:53:05 +00:00
Frediano Ziglio
a73357f33e inputs-channel: Encapsulate SpiceTabletState
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-12-01 22:51:05 +00:00
Frediano Ziglio
ddf7b366b1 Use verify instead of G_STATIC_ASSERT
verify guarantee that the condition is always a compile
time constant.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-12-01 22:49:46 +00:00
Frediano Ziglio
8e276278e5 tests: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-12-01 22:31:52 +00:00
Frediano Ziglio
9872e7b8e5 Reduce dependencies from red-qxl.h
This header is mainly exporting functions to handle public
interface for the QXL devices.
Avoid spreading its inclusion including this header in other
headers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-12-01 22:19:31 +00:00
Frediano Ziglio
a891d53a4c red-channel-client: Rename item_in_pipe to item_sent
The name is more consistent with the value of the flag and
the function red_channel_client_wait_pipe_item_sent where
the MarkerPipeItem structure is used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-12-01 22:15:16 +00:00
Frediano Ziglio
1ebe2e6d28 stream: Remove unused display parameter
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-12-01 16:51:44 +00:00
Jonathon Jongsma
cac9629409 DisplayChannel: Use NSEC_PER_MILLISEC
Instead of using 1000*1000

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-11-30 13:52:09 -06:00
Jonathon Jongsma
0975b92ba7 Rename RedStreamClipItem to VideoStreamClipItem
Avoid confusion with RedStream which is a totally unrelated object.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-11-30 13:51:51 -06:00
Jonathon Jongsma
5ea0f68263 Rename StreamAgent to VideoStreamAgent
Just to avoid confusion between different uses of the word Stream (e.g.
RedStream) clarify that it's related to video streams

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-11-30 11:51:09 -06:00
Jonathon Jongsma
2e08354ce1 Rename Stream to VideoStream
To prevent confusion between Stream (a video stream) and RedStream (a
generic data stream between client and server), change the name to
VideoStream to be more explicit about what it is.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-11-30 11:51:09 -06:00
Frediano Ziglio
8e06a57649 red-channel-client: Simplify red_channel_client_wait_pipe_item_sent
Currently, red_channel_client_wait_pipe_item_sent() inserts a MarkerItem
which will sent after the item we want to wait for: the tail of the
queue is the first item to send, and the function uses
red_channel_client_pipe_add_after_pos(). Then, if the marker has been
successfully sent, the function calls
red_channel_client_wait_outgoing_item to wait for 'item' to be sent.

Instead of doing this, we can add the MarkerItem to the queue so that
it's sent after 'item' (ie, insert it _before_ 'item' in the queue).
This way, when the marker is marked as having been sent, we'll also know
that 'item' has been sent.

This avoids having to call red_channel_client_wait_outgoing_item and
possibly the case where the item was not queued and
red_channel_client_wait_outgoing_item returning TRUE even if the item
was not sent as required.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-29 16:56:50 +00:00
Frediano Ziglio
35e9a9d435 red-channel-client: Simplify red_channel_client_wait_pipe_item_sent loop
Avoid repeating the same code twice.

red_channel_client_send sends the pending item (or a part of it). If
there are no item pending, the function does nothing (so checking for
blocked channel is useless). Also red_channel_client_send is already
called from red_channel_client_push which has a check for blocked
channels, so having calls to both red_channel_client_send() and
red_channel_client_push() is redundant.

The function on its overall tries to wait for a given item to be sent.
The call for red_channel_client_receive is mainly needed to support the
cases were to send data messages from the client should be processed
(like if "handle-acks" is requested).

Moving the loop iteration check inside the for loop instead allows to
avoid some duplication.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-29 16:54:48 +00:00
Frediano Ziglio
b2fa6ec66c red-channel-client: Avoid weird memory references using MarkerPipeItem
Instead of having MarkerPipeItem pointing to an external variable with
the possibility to forget to reset it and have a dangling pointer, this
commit takes a reference on the item to keep it alive after it was sent.
This item is placed into the queue to understand when it was sent. The
current implementation detects the unqueue when the item is destroyed so
we currently store a pointer to an external variable in the item, this
way we can use a variable which will still be alive after the item is
released/destroyed.
This change updates the variable (stored in the item) when we try to
send the item, rather than at destruction time. The destruction happened
at the end of red_channel_client_send_item(), so we don't mark
item_in_pipe much earlier than before.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-29 16:49:24 +00:00
Frediano Ziglio
8a9c51bd4f mjpeg-encoder: Fix some typos
unexected -> unexpected
esitimation -> estimation

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-29 11:17:21 +00:00
Frediano Ziglio
529ab49382 ci: Detect if code compile with SASL disabled
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Snir Sheriber <ssheribe@redhat.com>
2017-11-28 08:36:46 +00:00
Frediano Ziglio
137d9ec8e9 test-stream-device: Check incomplete reads of StreamMsgFormat
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-11-27 21:38:02 +00:00
Jonathon Jongsma
61aa6ac8aa StreamDevice: Handle incomplete reads of StreamMsgFormat
This is currently unlikely to happen since we communicate over a pipe
and the pipe buffer is sufficiently large to avoid splitting the
message. But for completeness, we should handle this scenario.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-11-27 21:37:53 +00:00
Uri Lublin
49234be2dd red-stream: fix build without SASL
put red_stream_disable_writev in an #ifdef HAVE_SASL block.
red_stream_disable_writev is only called from functions
that are already in an #ifdef HAVE_SASL block.

Currently when building with SASL disabled, I get:
  CC       red-stream.lo
red-stream.c:441:13: error: 'red_stream_disable_writev'
           defined but not used [-Werror=unused-function]

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-11-27 10:13:11 +00:00
Frediano Ziglio
9575713dfb inputs-channel: Remove reds argument from inputs_channel_set_tablet
All other inputs_channel_set_* functions do not have this
parameter and get it from the channel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-11-27 10:11:53 +00:00
Frediano Ziglio
d61fce91ee inputs-channels: Remove leak using tablet device
Current code does not free allocated tablet resources.
When a tablet is added some resources are allocated.
Resources should be released either removing the tablet or
freeing spice server object.
Added a test to check these conditions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-22 16:44:09 +00:00
Frediano Ziglio
cb1211a6ca reds: Do not get time if not needed
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-22 13:59:51 +00:00
Frediano Ziglio
d57b61a584 tests: Add a test for streaming devices
Currently create device, open it and pass some messages checking
they are handled.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-21 10:02:50 +00:00
Frediano Ziglio
223bfed649 Reuse SPICE_DECLARE_TYPE macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-21 08:38:44 +00:00
Frediano Ziglio
de5b166b71 Remove common/mem.h includes
common/mem.h contains mainly memory allocation functions.
As we decided to move to Glib calls directly avoid to include
function declaration we should not use anymore.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-21 08:27:09 +00:00
Frediano Ziglio
fb3e061a8e utils: Check we list all channel names
This prevent future problems supporting new channels.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-11-09 10:58:13 +00:00
Frediano Ziglio
3269451ae6 Use constant variables for image operations
This reduce the attack surface moving some data into read-only
sections.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-08 15:23:49 +00:00
Frediano Ziglio
ef166f3158 build: Update spice-common submodule
Frediano Ziglio (6):
      Make the compiler work out better way to write unaligned memory
      test-marshallers: Use unaligned structure
      test-marshallers: Test demarshalling
      ring: Remove __ring_remove function
      ring: Remove short living temporary variable
      canvas_base: Allow to specify constant operations

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-08 15:23:43 +00:00
Frediano Ziglio
ece4263055 utils: Fill in all possible channel names
Missing some names cause some debugging messages to be
generated and some of our tests to fail.

This patch was written by Christophe Fergeau.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-08 11:33:43 +00:00
Frediano Ziglio
7dda006c98 ci: Install python3 packages to fix compile on new Fedora
Fedora 26 removed dependency from python-pyparsing/python-six
to python but we require the executable to run some scripts

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-11-07 17:32:03 +00:00
Jonathon Jongsma
1980dd5dd1 StreamDevice: Fix incomplete header reads
The code for reading a StreamDevice message from the streaming agent has
code to handle a situation where you only read a part of the header. If
we've read only a part of the header, we will try to read the remaining
n bytes of the header within a loop until the full header is read.
However, when we try to read the last n bytes, we store it at beginning
of the header struct, which will overwrite the first part of the header.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-31 09:19:43 +00:00
Jonathon Jongsma
3165247886 Make stream-channel.h self-contained
Include protocol header file defining StreamMsgFormat which is used in a
function signature in this header.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
Reviewed-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-30 12:01:24 +01:00