Commit Graph

403 Commits

Author SHA1 Message Date
Victor Toso
580ca81536 canvas-base: remove user data from CanvasBase
Neither Spice nor spice-gtk are using this since the
following commit in Spice "server: remove OpenGL"
c5c176a5c7718177f23b07981556b5d460627498

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-30 15:36:29 +01:00
Victor Toso
edaafa187d canvas-base: group ifdef and defined together
Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-24 15:51:05 +00:00
Victor Toso
2c34cf49b5 canvas-base: use helper to get surface
Moving out a big switch statement that sole purpose is to retrieve the
surface (pixma_image_t)

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-24 15:51:01 +00:00
Frediano Ziglio
31819a2424 Define a new SPICE_VERIFY macro
The verify macro used currently has some problem
as it raise a warning in RHEL6.
As suggested in verify.h use verify_expr macro
to avoid the warning.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-14 17:19:18 +00:00
Pavel Grunt
63e575d5fc silence -Wunused-parameter 2016-11-01 15:26:43 +01:00
Eduardo Lima (Etrunko)
62f3024f42 Use explicit path for inclusion
As client_marshallers.h is included outisde of spice-common, we need to
specify the path for generated_marsharllers.h so that builds out of the
tree don't fail.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2016-07-13 15:03:34 -03:00
Christophe Fergeau
073d064b86 codegen: Autogenerate client_marshallers.h
This commit adds autogeneration of a generated_client_marshallers.h
header, which is then included in client_marshallers.h

This allows to remove the SpiceMessageMarshallers struct from this file,
which has to match what the generated code expects.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-06-24 10:02:58 +01:00
Frediano Ziglio
15b8f28c14 Use a macro to simplify ring_get_length
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-06-21 12:52:27 +01:00
Christophe Fergeau
1d47225a8e Adjust verify.h licence
verify.h can be licensed as LGPLv2+ rather than GPLv3, see
http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=modules/verify;h=5216ce890dac58e596a27341e31258e5d6c0d702;hb=HEAD

A verify.h file with the appropriate licence can be generated from a
gnulib clone using:
gnulib-tool --lgpl=2 --import verify

This will fail if the 'verify' module is not licensed under a compatible
license.
2016-06-21 12:26:38 +02:00
Christophe Fergeau
62b996ffb0 Update verify.h to latest version 2016-06-20 15:03:44 +02:00
snir sheriber
4284011bdc Add LZ4 data compression and use it in spicevmc channel
Compressed message type is CompressedData which contains compression
type (1 byte) followed by the uncompressed data size (4 bytes-exists
only if data was compressed) followed by the compressed data

Update the required protocol to 0.12.12:

Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-06-13 23:00:28 +01:00
Frediano Ziglio
d0139f824e Remove a warning compiling under Windows
On Windows long is always 32 bit so under x64 the cast from pointer to
"unsigned long" cause a warning.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-13 18:38:25 +01:00
Frediano Ziglio
bbd8f9a5e2 Remove deprecated init functions
No need to keep API compatibility in spice-common.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Marc-André Lureau <mlureau@redhat.com>
2016-06-13 11:28:58 +01:00
Frediano Ziglio
73282208f0 simplify #ifdef code
Reduce conditional code

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-02 10:01:48 +01:00
Pavel Grunt
384698af37 Remove GL support
It is not needed since spice-server commit
c5c176a5c7718177f23b07981556b5d460627498

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-11 16:54:23 +01:00
Fabiano Fidêncio
74439e8e6e Use g_getenv() instead of getenv()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-04-25 09:09:17 +02:00
Fabiano Fidêncio
a8f756eabf coverity: remove structurally dead code
The loop (for (;;)) will be executed only once, so, no reason for
keeping it.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-04-25 09:09:17 +02:00
Fabiano Fidêncio
83b84428ec coverity: remove unused value
len is overwritten in the match label with the value from
"ip - anchor".

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-04-25 09:09:17 +02:00
Fabiano Fidêncio
657e1c5291 coverity: avoid division or modulo by zero
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-04-25 09:09:17 +02:00
Fabiano Fidêncio
3312a0f70b coverity: avoid dereference after null check
All decompress functions used after this check take into account that
encoder->palette is not NULL. So, if we already detected that the
palette is NULL, let's just return early.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-04-25 09:09:17 +02:00
Fabiano Fidêncio
89b902789b coverity: avoid resource leak
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-04-25 08:34:54 +02:00
Fabiano Fidêncio
bc73df4e47 coverity: avoid use after free
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-04-25 08:34:14 +02:00
Pavel Grunt
739a859d79 Define canvas_fix_alignment when is used
It is used in canvas_get_lz4() which is guarded by USE_LZ4, and
in canvas_get_lz() which is guarded by SW_CANVAS_CACHE.
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-04-19 13:49:50 +02:00
Frediano Ziglio
5603961ffa fix 16 bpp LZ image decompression
LZ image decompression was broken for 16 bpp:
- stride was computed not computed correctly (as width*4). This caused
  also a buffer underflow;
- stride in pixman is always multiple of 4 bytes (so for 16 bpp is
  ALIGN(width*2, 4)) so image decompressed by lz_decode as some missing
  bytes to be fixed.

The alignment code is reused from LZ4 function.

This fix also https://bugzilla.redhat.com/show_bug.cgi?id=1285469.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-04-15 14:25:58 +01:00
Christophe Fergeau
2a4bf49edd log: Make sure glib threading is initialized
While testing spice-server on EL6, I was getting random crashes in the
glib logging code because g_logv was called recursively even though this
was not visible in a backtrace.

It turns out on older glib versions (EL6 has 2.28), g_logv is not
thread-safe unless g_thread_init() is called first. If g_thread_init()
is not called, the GMutex/GPrivate calls g_logv makes are turned into
no-ops, which is going to cause the recursion issue I was seeing.

This commit adds a call to g_thread_init() for these older glib
versions.

(gdb) bt
    0x7fff9f9fb110 "item.type: 114", unused_data=0x0) at gmessages.c:863
    format=0x7ffff50e72ac "item.type: %d", args1=0x7fff9f9fb640) at gmessages.c:517
    SPICE_LOG_LEVEL_DEBUG, strloc=0x7ffff50e72ba "dcc.c:1652", function=
    0x7ffff50e7320 "release_item_before_push", format=0x7ffff50e72ac "item.type: %d", args=
    0x7fff9f9fb640) at log.c:163
    SPICE_LOG_LEVEL_DEBUG, strloc=0x7ffff50e72ba "dcc.c:1652", function=
    0x7ffff50e7320 "release_item_before_push", format=0x7ffff50e72ac "item.type: %d") at log.c:195
    at dcc.c:1652
    at dcc.c:1719
    at dcc-send.c:2450
    at red-channel.c:578
    at red-channel.c:1587
    at event-loop.c:122
    0x7ffff4fb2ef2 <watch_func>, user_data=0x7fff980244e0) at giounix.c:166
    0x7ffff86ec770) at gmain.c:3092
2016-04-05 15:38:18 +02:00
Christophe Fergeau
8473d0ae71 log: Use SPICE_CONSTRUCTOR_FUNC
This was done through a GOnce called every time spice_log() is called,
now it will always be called at spice-server startup.

This means the unit test needs to be updated as SPICE_DEBUG/ABORT_LEVEL
must now be set before the process starts up rather than before the
first spice_log call, and the deprecation warning these environment
variables trigger cannot be caught using g_test_expect_message() as
they are output before g_test_init() is called.
2016-04-05 15:38:17 +02:00
Christophe Fergeau
6a65f470d1 log: Clamp SPICE_DEBUG_LEVEL if it's too high
This matches how SPICE_DEBUG_LEVEL behaved before switching to glib
logging.
2016-04-05 15:38:16 +02:00
Frediano Ziglio
5b6be16b37 use macro to define constructor function
Avoid having to call function at runtime to inialize static.
Old functions are defined as deprecated for compatibility.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-03-23 15:06:08 +00:00
Frediano Ziglio
2505f9ac96 define SPICE_CONSTRUCTOR_FUNC and SPICE_DESTRUCTOR_FUNC macros
Allow to define functions executed at program/shared object initialization
or close.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-03-17 17:16:30 +00:00
Frediano Ziglio
53ee80bd7d Cap logging level to the valid bounds
Avoid overflows using its values.
The patch was originally written by Christophe Fergeau

Acked-by: Victor Toso <victortoso@redhat.com>
2016-03-11 10:16:22 +00:00
Christophe Fergeau
8af947e7b2 Remove 2 unused vfuncs from client_marshallers.h
The AudioVolume and AudioMute messages are not sent by the client, so
they do not need to appear in SpiceMessageMarshallers in
client_marshallers.h
2016-03-11 09:55:09 +01:00
Marc-André Lureau
1cd26b87c1 Revert "Remove files moved to spice-protocol"
This reverts commit 7665dcf1bb.

Also revert the related build-sys changes to fix the build.

codegen generated code depends on spice-common code (marshaller,
messages etc), it makes more sense to keep the generator along
this. Otherwise a newer protocol release will fail to build older
projects.

*.proto files are required as well, since it generates code that parent
modules depend on unconditionnaly.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2016-03-10 16:01:36 +01:00
Frediano Ziglio
fd9ba72f1a marshaller: fix uninitialized field usage
has_fd was not initialized.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Marc-André Lureau <mlureau@redhat.com>
2016-02-03 11:48:43 +00:00
Marc-Andre Lureau
472e563591 marshaller: track if add_fd() was given -1
In some cases, it might be worth to be able to send a message with a -1
fd, has the protocol permits. Change add_fd/get_fd in order to track
if the caller wanted to send -1.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-02 12:38:54 +00:00
Frediano Ziglio
75cb2701d3 Use code to compute a bit mask
Code is in the slow path, this reduce space needed for data+code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-27 18:39:06 +00:00
Frediano Ziglio
580adf7c36 Avoid to call ceil_log_2 twice with same value
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-27 18:39:04 +00:00
Frediano Ziglio
6e04b94751 Constification
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-27 18:39:02 +00:00
Frediano Ziglio
daf406a179 zeroLUT has same content of lzeroes
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-27 18:39:01 +00:00
Frediano Ziglio
07b3150cb1 common: constify some declarations
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-27 18:38:43 +00:00
Frediano Ziglio
7790dacfd3 small spice_strdup optimization
avoid to compute the string length twice and use memcpy instead of
strcpy which is faster not having to check for terminator.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-26 17:17:08 +00:00
Frediano Ziglio
5376f1d88c remove wrong statement terminator from preprocessor macro
Actually not causing problems as when used is always followed by another
terminator but better to fix the definition.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-26 16:45:32 +00:00
Christophe Fergeau
0a6580d2e6 log: Kill spice_warn_if
It's redundant with spice_warn_if_fail(), and can even be confusing.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-26 15:58:43 +01:00
Christophe Fergeau
efd1d3cb4d log: Use glib for logging
spice-common has been duplicating glib logging methods for a long while.
Now that spice-common is depending on glib, it's more consistent to use
glib logging too. However, the code base is still using spice logging
functions.
This commit aims to make spice logging go through glib logging system,
while keeping the same behaviour for the SPICE_ABORT_LEVEL and
SPICE_DEBUG_LEVEL environment variables. They are deprecated however in
favour of the glib alternatives (G_DEBUG and G_MESSAGES_DEBUG).

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-26 15:58:43 +01:00
Christophe Fergeau
2ff25b7567 log: Remove unneeded #ifdef/#endif
If header guards are working as expected, there should not be multiple
definitions of these macros. If they are redefined somewhere else, this
is a bug we want to fix.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-26 11:49:14 +01:00
Christophe Fergeau
838596a257 log: Use more glib macros
No need to have our own SPICE_STMT_BEGIN/END and SPICE_STRINGIFY

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-21 11:10:39 +01:00
Pavel Grunt
93cd2f6836 draw: Add spice_image_descriptor_is_lossy
It will be used in the server code

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-20 15:56:00 +00:00
Marc-Andre Lureau
b61f43f228 Add GL scanout structures
See related protocol changes.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-14 11:49:25 +00:00
Marc-Andre Lureau
a18bed136f marshaller: learn to describe fd passing in messages
The marshaller can't serialize fd in memory stream. Instead, append the
fd to the marshaller structure. The marshaller user is responsible for
sending the fd when the message is sent. The fd to send can be retrieved
with spice_marshaller_get_fd().

Note: only a single fd is supported with this API, supporting multiple
fd is left for the future if it becomes necessary.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-14 11:46:58 +00:00
Frediano Ziglio
80cc3f680a ring: use NULL instead of 0 for null pointers
This is consistent with the rest of the code making clear
fields are pointers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-01-07 16:46:19 +00:00
Victor Toso
397eb47816 Remove headers that are included in spice_common.h
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-07 12:46:42 +01:00