Commit Graph

3537 Commits

Author SHA1 Message Date
Frediano Ziglio
c8bc09bcb3 red-qxl: Update header guard names
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-31 17:30:22 +01:00
Frediano Ziglio
d248714439 red-qxl: Reference RCC pointer in migration request
The message is asynchronous so to avoid the object to potentially
been released before being processed keep a strong reference to
it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-31 17:28:37 +01:00
Christophe Fergeau
b89bd9ef9a worker: Fix 'immediatly' typo in comment
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-31 15:51:57 +02:00
Christophe Fergeau
ab1348486d worker: Simplify flush_commands()
red_disconnect_display() is duplicating what red_channel_disconnect()
already does, so red_disconnect_display() and red_disconnect_cursor()
are actually identical code-wise. We can directly call
red_channel_disconnect() from flush_commands() rather than passing a
'red_disconnect_t disconnect' argument to that function.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-08-31 15:51:57 +02:00
Christophe Fergeau
becd0d30f6 cursor: Remove cursor_channel_disconnect()
cursor_channel_disconnect() calls
cursor_channel_client_reset_cursor_cache() on all CursorChannelClient
associated with the current CursorChannel before calling
red_channel_disconnect().

red_channel_disconnect() will iterate over all CursorChannelClient
calling red_channel_client_disconnect(), which will eventually call
CursorChannelClient::on_disconnect. This will in turn
cursor_channel_client_reset_cursor_cache(), so calling it in
cursor_channel_disconnect() before calling red_channel_disconnect() is
redundant.

cursor_channel_disconnect() can thus be replaced by a direct call to
red_channel_disconnect().

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-08-31 15:51:57 +02:00
Christophe Fergeau
54eb7716f0 channel: Allow NULL RedChannelClient::on_disconnect()
SoundChannelClient has a stub implementation of
RedChannelClient::on_disconnect(), this commit removes the need for it.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-08-31 15:51:57 +02:00
Christophe Fergeau
5dbfbb4d78 channel: Move RedChannel::on_disconnect to RedChannelClient
This vfunc only has a RedChannelClient * argument, and most of the time,
it operates on RedChannelClient, not on RedChannel. Moreover, the only
time it's used is from RedChannelClient. This commit moves the vfunc to
RedChannelClient, which seems like a better fit for it.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-08-31 15:51:57 +02:00
Frediano Ziglio
14aee7cd74 gstreamer: Check if ORC library can work
ORC library is used internally by GStreamer to generate code
dynamically.
If ORC cannot allocate executable memory, the failure causes
an abort(3) to be called.
This happens on some SELinux configurations that disable executable
memory allocation (execmem boolean).
Check that ORC could work before attempting to use GStreamer to
avoid crashes.
While this check is done, the ORC library outputs an error which will
be well visible in Qemu output.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-30 15:59:46 +01:00
Frediano Ziglio
20676792a8 Avoid to access data before a NULL check
If you are testing for NULL data this means that variable could be
NULL so avoid to access before the check to make sure the check is hit.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-30 15:56:43 +01:00
Frediano Ziglio
1fef2f507d main-channel: Fix multimedia time argument type
The multimedia time is defined as uint32_t.
Use the proper type instead of int.
Currently no arithmetic is done on this value but
just copies so considering that on the architectures
we support sizeof(int) == sizeof(uint32_t) there's
no change in the resulting machine code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-29 16:37:21 +01:00
Frediano Ziglio
975d10c9ef red-qxl: Avoid using dangling pointers to RedClient
A RedClient can be freed from the main thread following a main channel
disconnection (reds_client_disconnect). This can happen while another
thread is allocating a new channel client for that client.
To prevent the usage of a pointer which can be invalid
take ownership of the pointer.
Note that we don't need this when disconnecting as disconnection is
done synchronously (the dispatch messages are registered with
DISPATCH_ACK).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-29 16:28:47 +01:00
Frediano Ziglio
b496e4a037 worker: Add some loop statistics
Trace the number of loops done processing display commands
and the number of loops in which the queue was full.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-29 16:18:41 +01:00
Frediano Ziglio
23fd55948b red-worker: Remove small memory leak
If a DisplayChannelClient cannot be instantiated capabilities
are not released correctly.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-25 16:06:16 +01:00
Frediano Ziglio
d27c18e981 dcc: Reuse display variable
display variable already contains the DCC_TO_DC(dcc) value so
reuse it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-25 14:42:10 +01:00
Christophe Fergeau
9a54ddf459 RedChannelClient: Mark some private data as bool
Some RedChannelClient data members were marked as int when they only
hold booleans.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-25 14:41:34 +01:00
Frediano Ziglio
dcc9c18759 reds: Inline very simple function
reds_get_n_clients is a single line and is used only by
spice_server_get_num_clients.
The 2 functions have very similar names so inlining
reds_get_n_clients does not make code less readable.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-25 13:14:34 +01:00
Frediano Ziglio
8cdea23d1d display-channel: Check that all structure are destroyed during finalize
The leak detector we use currently is not enough to detect
some kind of leak in DisplayChannel so manually test.
These tests are enabled only when --enable-extra-checks is passed
to configure.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-25 09:37:17 +01:00
Frediano Ziglio
3a5007d18f red-channel: unregister channel in red_channel_destroy
Mostly of red_channel_destroy calls were preceded by
a call to unregister the channel.
The only exception was the main channel as this channel is
always present and its initialisation is a bit different.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-23 22:19:07 +01:00
Frediano Ziglio
c91fbc155b display-channel: push monitor configuration
RedWorker should not handle directly to client but
defer the job to DisplayChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-23 22:17:43 +01:00
Frediano Ziglio
1026a89b78 reds: use SpiceMouseMode for RedsState::mouse_mode
Make easier to understant the value to use in the code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-23 22:16:05 +01:00
Frediano Ziglio
930a1196e3 char-device: Allows to handle port events from any char device
From spice_server_port_event API you can send port events to
any char device. Although currently this is used only for "port"
devices implemented in spicevmc.c this will allow to support
such events using different objects.

This will be used for instance for a streaming device which
will be a specific SpicePort implementation.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-23 16:11:49 +01:00
Jonathon Jongsma
7498675c1d Avoid leaking memory on invalid cursor commands
When a RedCursorCmd is passed to cursor_channel_process_cmd(), it
constructs a new CursorItem which takes ownership of that command. If
the cursor_cmd->type falls through to the default case of the switch
statement, we will print a warning and return without freeing the
CursorItem (and thus the RedCursorCmd).

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-08-23 08:56:13 +01:00
Frediano Ziglio
e3bff1eea4 Remove iterator from list iteration macros
Avoid to have to declare iterator and pass as an argument.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-08-21 12:54:47 +01:00
Frediano Ziglio
5acda5a35d red-client: Do not compute channel if client is not connected
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-08-21 11:26:59 +01:00
Frediano Ziglio
ddf38d1d1b red-client: Minor space fixes
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-08-21 11:26:34 +01:00
Frediano Ziglio
1592866b6b Remove call to red_channel_client_push outside RedChannel
Now the push is done automatically when a PipeItem is added
(cfr commit 5c460de1a3
"worker: push data when clients can receive them"),
forcing a push cause only network fragmentation and is required
only if you are handling data in a loop instead of using the
default loop.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-08-15 13:19:23 +01:00
Frediano Ziglio
e7cf7befd5 build: Update spice-common
This include some Quic changes, particularly a compile fix
if no optimizations (-O0) are used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-12 08:20:57 +01:00
Frediano Ziglio
7a7e01cf03 ci: Fix recent GitLab failures
Recent GitLab CI jobs are failing to run valgrind checks
(like https://gitlab.com/spice/spice/-/jobs/25220999).

This as recent distro changes cause valgrind not to find some
symbols required to detect some GLib suppression errors.

Adding debugging information for GLib solve the problem.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-07-28 15:06:04 +01:00
Frediano Ziglio
b84db435bd README: Add missing optional dependencies
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-28 10:33:57 +01:00
Frediano Ziglio
72fe9d28bc README: Fix minor dependency
Cyrus-SASL is not mandatory

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-28 10:33:54 +01:00
Frediano Ziglio
2f2217392f README: Remove OpenGL dependency
OpenGL dependency was removed by Marc-André Lureau in 2015
(0dc98956).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-28 09:57:07 +01:00
Frediano Ziglio
30a51a943c README: Remove obsolete GUI dependencies
Remove old dependencies used by obsolete client code.
This code was removed from the git repository by
Christophe Fergeau in 2014 (18769714).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-28 09:57:05 +01:00
Frediano Ziglio
4dbe66b342 README: Update link to GIT
Really minor change, just use canonical URL using secure
HTTP instead of normal one.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-28 09:57:03 +01:00
Frediano Ziglio
9885cea213 README: Update required protocol version
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-28 09:56:58 +01:00
Frediano Ziglio
991f55a782 README: Fix typo (dependancies -> dependencies)
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked by: Christophe de Dinechin <dinechin@redhat.com>
2017-07-28 07:23:08 +01:00
Christophe Fergeau
34dff543be Prepare for 0.13.90 release
Update NEWS and soname.
2017-07-26 17:04:36 +02:00
Christophe Fergeau
4b956164ef build: Update spice-common
Christophe Fergeau (3):
      log: Follow spice style guidelines for #include in log.h
      log: Define G_LOG_DOMAIN as early as possible
      canvas: Don't try to unref NULL pixman_image_t

Christophe de Dinechin (3):
      Style adjustment - Making code match surrounding style
      Use space and not colon to separate log domains
      Avoid clang warnings on casts with stricter alignment requirements

Frediano Ziglio (14):
      codegen: Allows to specify license of generated files
      codegen: Fix license name
      log: Do not check impossible function return
      log: Optimise glib_debug_level check
      log: Check log level from spice_logv
      fix indentation on previous patch
      log: Use GLib logging levels directly
      Use SPICE_ATTR_PACKED instead of custom ATTR_PACKED
      canvas-base: Do not attempt useless cast on stride adjustment
      quic: constantify some variable
      log: remove spice_static_assert macro
      quic: Fix typo in function names
      log: Forbid the usage of obsolete SPICE_LOG_DOMAIN
      log: Force format in log macro to be a string
2017-07-26 17:04:34 +02:00
Uri Lublin
8e593b55cf init ssl connection: return quickly if link is null
Under error: 'link' fields are being accessed, so it's
wrong to goto error with link == NULL.

Instead, return immediately.

Found by coverity.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-07-19 15:56:20 +03:00
Uri Lublin
94725f1ca8 red_replay_image_free: do not free QUIC qxl twice
If qxl->descriptor.type is QUIC, red_replay_data_chunks_free
frees qxl (data), so no need to free it again at the bottom
of the function.

Found by coverity.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-07-19 15:56:20 +03:00
Frediano Ziglio
fbbcdad773 reds: Avoid buffer overflows handling monitor configuration
It was also possible for a malicious client to set
VDAgentMonitorsConfig::num_of_monitors to a number larger
than the actual size of VDAgentMOnitorsConfig::monitors.
This would lead to buffer overflows, which could allow the guest to
read part of the host memory. This might cause write overflows in the
host as well, but controlling the content of such buffers seems
complicated.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2017-07-11 10:40:27 +02:00
Frediano Ziglio
571cec91e7 reds: Avoid integer overflows handling monitor configuration
Avoid VDAgentMessage::size integer overflows.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2017-07-11 10:40:27 +02:00
Frediano Ziglio
111ab38611 reds: Disconnect when receiving overly big ClientMonitorsConfig
Total message size received from the client was unlimited. There is
a 2kiB size check on individual agent messages, but the MonitorsConfig
message can be split in multiple chunks, and the size of the
non-chunked MonitorsConfig message was never checked. This could easily
lead to memory exhaustion on the host.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2017-07-11 10:40:27 +02:00
Christophe Fergeau
fa85fbf880 build-sys: Improve portability of appending to COMMON_CFLAGS
This is currently done through += in configure.ac, this commit switches
to using COMMON_CFLAGS="$COMMON_CFLAGS ..." for better portability.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-07-07 17:03:56 +02:00
Victor Toso
31fb967f1a display-channel: introduce display_channel_get_nth_stream()
To help avoid stream.c and dcc.c to access display-channel private
structure to get the nth Stream structure pointer.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-06-30 12:28:30 +02:00
Victor Toso
970cb2a1d3 stream: use display_channel_get_stream_id()
As we have a function for that, don't do the math elsewhere.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-06-30 12:28:13 +02:00
Michal Privoznik
7254169f7f tests: Initialize all members of SpiceBaseInterface struct
When compiling, -Werror=missing-field-initializers is enabled.
However, some gcc versions (like Gentoo 4.9.4 one) fail to see
that all the members of the SpiceBaseInterface struct are
initialized:

test-display-base.c:844:5: error: missing initializer for field
'description' of 'SpiceBaseInterface'
[-Werror=missing-field-initializers] .base.description   = "test
spice virtual channel char device",

The solution is to initialize .base member as a structure at once
instead of multiple times per each member.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-06-23 10:09:50 +01:00
Frediano Ziglio
71e53cda84 gitignore: Reduce html files exclusion
Limit html files ignored only to autogenerated ones.
Can happen that you are working on some html files on your main
spice-server directory and it's not desirable to ignore them.
For instance this can happen if you download a patch from patchwork.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-06-20 11:41:58 +01:00
Frediano Ziglio
a1387f036e log: Do not print function name twice during logging
spice_error/spice_warning already print location information
so don't print them twice.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongmsa <jjongsma@redhat.com>
2017-06-18 09:53:27 +01:00
Frediano Ziglio
0903a84b8c log: remove not widely used logging domain usage
As discussed recently the usage of domain for logging has
different issues (they are not filtered and handled coherently)
and are not widely used in the code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-06-16 07:53:00 +01:00
Christophe Fergeau
429958f7d4 reds: Free client_monitors_config in spice_server_destroy()
This was not done until now, and it's only going to be needed if we receive
a partial ClientMonitorsConfig message.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-06-15 18:26:29 +02:00