Commit Graph

2214 Commits

Author SHA1 Message Date
Frediano Ziglio
f53093ee90 Include directly used header in dcc.h
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-10-18 18:10:00 +01:00
Jonathon Jongsma
bf7375d834 Improve MainChannel encapsulation
Encapsulate MainChannel a bit better in preparation for proting to
GObject.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-18 18:03:17 +01:00
Frediano Ziglio
530b22b7ec Be consistent with opaque type
vdi_port_read_buf_release is registered passing data as
RedVDIReadBuf*, not RedPipeItem*. Cast opaque to proper
pointer type to avoid the assumption that first field of
RedVDIReadBuf is a RedPipeItem.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-10-18 10:15:57 +01:00
Frediano Ziglio
5feb1d0379 Use a compatibility header to support GLib 2.28
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-10-18 09:52:28 +01:00
Frediano Ziglio
4121547ba8 Do not typedef DisplayChannel twice
Already defined in dcc.h.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-10-18 09:45:45 +01:00
Frediano Ziglio
bd322b68e6 Avoid to typedef twice CursorChannel
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-10-18 09:45:33 +01:00
Uri Lublin
44624ed8bf mjpeg_encoder_new: allocate memory after sanity check
This patch prevents a leak in case the function returns early

Found by coverity.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-17 10:49:41 +01:00
Uri Lublin
09b12a55d0 input-channel: add a comment to mark fallthrough in switch
Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-17 10:49:29 +01:00
Jonathon Jongsma
f9997e14f0 Add CommonGraphicsChannelPrivate struct
Encapsulate private data for CommonGraphicsChannel and prepare for
GObject conversion.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-14 19:17:40 +01:00
Pavel Grunt
40545d0403 rcc: Make OutgoingHandler private
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-14 15:00:23 +01:00
Pavel Grunt
4dd9e8a93c reds: Define openssl lock only if needed
Silence a warning:
 reds.c:150:25: warning: 'lock_cs' defined but not used [-Wunused-variable]
  static pthread_mutex_t *lock_cs;

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-14 13:01:42 +01:00
Francois Gouget
2ebd69c4c5 server: Remove a redundant IncomingHandler typedef
This fixes a compilation error with gcc 4.4.7 on RHEL 6.8.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-14 12:38:12 +01:00
Jonathon Jongsma
efe49fa275 Use macros for casting Channel types
In preparation for converting RedChannel to GObject, switch to using
RED_CHANNEL()-type macros for casting. For now they just do a regular
cast, but it helps reduce the size of the GObject patch to make it
easier to review.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-14 11:49:25 +01:00
Jonathon Jongsma
bcb8503659 Move CommonGraphicsChannel to a new file
Move out of red-worker.c. This requires a little bit of minor
refactoring to avoid accessing some RedWorker internals in the
constructor function, etc.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-14 11:49:12 +01:00
Francois Gouget
c5758b6890 server: Remove a redundant CursorChannelClient typedef
CursorChannelClient is already defined in cursor-channel-client.h.
This fixes compilation errors with gcc 4.4.7 on RHEL 6.8.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-10-14 10:41:12 +01:00
Jonathon Jongsma
b8080dbc21 Don't increment num_clients_mig_wait twice
When MainChannelClient was split to a separate file, the responsibility
for incrementing this field was supposed to belong to the MainChannel
function (main_channel_connect_semi_seamless()), but by mistake it was
incremented both there and in the client function
(main_channel_client_connect_semi_seamless()).

The bug was introduced in a11b785f19

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-13 16:45:50 -05:00
Pavel Grunt
ddf028569e Test agent message filter processing
Signed-off-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-11 13:49:15 +01:00
Pavel Grunt
dee20d8b43 Add agent message filter test
Test filter initialization and configuration

Signed-off-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-11 13:48:54 +01:00
Pavel Grunt
dfccfa7083 agent-msg-filter: Remove extra headers
Signed-off-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-11 13:41:37 +01:00
Frediano Ziglio
5193360594 Convert RedChannelClient hierarchy to GObject
Convert the RedChannelClient heirarchy into GObjects. Since the existing
constructors could fail and return NULL, I inherited the base channel
client from GInitable, which introduces a dependency on gio.

When using private structs with GObject, there's a maximum size of (I
think) 64k, which was exceeded by some of the private structs. To avoid
this limitation I changed some members to dynamically allocated.
2016-10-07 14:46:37 -05:00
Frediano Ziglio
32aa710d22 Split RedCharDeviceSmartcard and SmartCardChannelClient 2016-09-30 13:14:03 +01:00
Frediano Ziglio
3e51627991 Cache field to make code easier
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-09-30 13:10:27 +01:00
Frediano Ziglio
696efb98ac Add a comment for marshaller field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-29 10:08:19 +01:00
Jonathon Jongsma
c96f8c9f9b Generate GTypes for spice-server enums
The GType will be useful to allow these enums to be used as GObject
properties.

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 15:27:05 +01:00
Frediano Ziglio
5d04ad7359 Rename red_surface to surface
Attempt to use consistent naming.
Usually we use surface name for RedSurface.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 14:30:16 +01:00
Frediano Ziglio
05150fbe34 Rename surface argument to surface_cmd
Attempt to use consistent naming.
Usually we use surface name for RedSurface so make sure
code reader do not get confused using a different name
for RedSurfaceCmd.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 14:29:39 +01:00
Frediano Ziglio
a874ebadff Rename detach_stream to stream_detach_drawable and removed unused argument
This function deal only with Stream.
Also the name was misleading and was not clear if it detached the stream
from the DisplayChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 14:25:43 +01:00
Frediano Ziglio
ae01c6d4bc Removed only written roundtrip_stat field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 14:22:04 +01:00
Frediano Ziglio
693a6b8fd9 Removed unused stat field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 14:21:07 +01:00
Frediano Ziglio
c2f0b00fde Use enum value returning invalid value
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 13:25:50 +01:00
Frediano Ziglio
fd888a0bfd Check client is using unix sockets in dcc_gl_draw_item_new
Currently this is simply avoided by the fact that Virgl with 3d means
Unix socket. Once you enable (in Qemu) tcp sockets this message will
be added to all clients (supposing multiple clients) so potentially
will be in all queues. The same check is done for dcc_gl_scanout_item_new.
dcc_gl_scanout_item_new is called when Qemu calls spice_qxl_gl_draw_async.
Technically a client can support SPICE_DISPLAY_CAP_GL_SCANOUT but server
cannot send the DRM prime directly as this require a unix socket so
if the test for SPICE_DISPLAY_CAP_GL_SCANOUT is done here it make sense
to do the check for the socket type too.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 11:16:54 +01:00
Frediano Ziglio
46a4543d9d Reuse VD_AGENT_HAS_CAPABILITY macro for bit array
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-26 13:46:59 +01:00
Frediano Ziglio
435daaffdb worker: RedCompressBuf optimization
Move large buffer field at the end of structure.
Due to the way machine address memory this usually can reduce code size
and make program sligthly faster.
Actually reduce size by 100 bytes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-26 10:27:58 +01:00
Frediano Ziglio
b009a7ff34 Prevent setting invalid image compression values
In case of invalid value the original compression is unchanged.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-26 10:11:47 +01:00
Frediano Ziglio
1cf2b16c42 replay: Update pointer in allocated list
Avoid to free invalid pointer.

Reported-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-22 17:00:06 +01:00
Frediano Ziglio
c51203ab16 Small comment on structure checking
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-22 16:50:03 +01:00
Frediano Ziglio
a9d6b72959 Remove unused fields
These fields were added in a32e90257e
as part of the multiple client support and were never used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-22 16:47:36 +01:00
Frediano Ziglio
b74fe03f00 Capitalize option documentation
All other options are documented using initial capital case letter.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-22 09:37:18 +01:00
Frediano Ziglio
07f1e3a296 Simplify serial sending packets
serial was the future serial to send while last_sent_serial was the
last sent.
serial sent started from 1.
To make sure sequence variable is updated just before sending the
message, not every message prepared.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-22 09:14:02 +01:00
Frediano Ziglio
d06fd6a2f9 worker: Do not check surface twice
validate_surface already do the same checks.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-22 09:10:05 +01:00
Frediano Ziglio
d3357a5a88 replay: Use unsigned in formatting
Avoid negative syntax. Also could prevent some memory problem is number
get too big.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 18:04:02 +01:00
Frediano Ziglio
e211f5dbe1 replay: Use proper formatting for scanf family
Currently on Linux PRIu64 and SCNu64 are the same but just to make
sure in the future use the correct macros.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 18:03:05 +01:00
Frediano Ziglio
a931713902 replay: Propagate error correctly in replay_fread
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 18:00:09 +01:00
Frediano Ziglio
0e5464f152 replay: Move error check
Do the check after replay_fscanf to make sure everything
is fine before calling red_replay_compat_drawable or
red_replay_native_drawable.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 17:57:59 +01:00
Frediano Ziglio
6c5ea7311a replay: Detect errors from red_replay_data_chunks
Change the return to ssize_t to be able to distinguish from
empty buffer to error.
Check result returned and avoid continuing potentially
deferencing NULL pointers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 17:57:57 +01:00
Frediano Ziglio
1c8a01e58d replay: Handle errors reading strings from record file
To check fscanf read all needed information a dummy "%n" is appended
to any string and the value stored there is tested. This as scanf family
could return a valid value but not entirely process the string so
adding a "%n" and checking this was processed make sure all expected
string is found.
The code to check for a specific string is now a bit more complicated
as replay_fscanf use a macro which append a constant string.
The "error" field is used to mark any error happened, so in most cases
there is no explicit check beside when this could cause a problem
(for instance results of replay_fscanf used which would result in
uninitialised variable usage).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 17:57:19 +01:00
Frediano Ziglio
98557452bc replay: Record allocations in a GList to handle errors
Allocations are kept into a GList to be able to free in case some
errors happened.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 17:56:00 +01:00
Frediano Ziglio
6d4db4f0bf Base FOREACH_DCC on GLIST_FOREACH
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:24 +01:00
Frediano Ziglio
9b5f93d1a7 Base FOREACH_CLIENT on GLIST_FOREACH
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:22 +01:00
Frediano Ziglio
3fa2f12c1f Use proper FOREACH_DCC instead of FOREACH_CLIENT
FOREACH_DCC should be more DisplayChannel related.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:20 +01:00