Commit Graph

544 Commits

Author SHA1 Message Date
Christophe Fergeau
2ccf106920 proto: Rename image_compress to image_compression
Re-using the SPICE_IMAGE_COMPRESS_ prefix in newer spice-protocol
releases is going to cause issues as there will be clashing enum members
in older spice-server releases. Using SPICE_IMAGE_COMPRESSION_ as a
prefix sidesteps these backward compability issues.

(cherry picked from spice-protocol commit e857cd9a378cdf56805b64284491a12af93a7cbf)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2016-03-10 16:01:46 +01:00
Marc-André Lureau
487f914a5d codegen: simplify FdType
This patch is a left-over from the fd passing commit 267391c8fd as
suggested by Frediano Ziglio during review.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>

(cherry picked from spice-protocol commit 47076559628d71c128e14e11147ce36b92677885)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2016-03-10 16:01:42 +01:00
Marc-Andre Lureau
c5ed374a32 protocol: learn to describe fd passing in messages
Add a new type, "unix_fd", used to describe file descriptor sharing via
socket ancillary data (these messages are local only).

The marshaller/demarshaller can't serialize this in memory (consume_fd
implementation is empty), so it is the responsability of the marshaller
user to handle sending and receiving the handles, which are appended at
the end of the message with an extra stream byte (because some Unix
requires sending at least a byte with ancillary data).

Even if there is no fd to send (or if the fd is invalid etc), the
receiver side expects an extra byte anyway.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>

(cherry-picked from spice-protocol commit 267391c8fd7c90c067b3e4845ff0227a2580e2e2)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2016-03-10 16:01:42 +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
Marc-André Lureau
f06f699d78 test-logging: unset G_MESSAGES_DEBUG
This test is sensitive to G_MESSAGES_DEBUG variable. Make it insensitive
by unsetting the environment variable.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-10 14:47:39 +00: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
Pavel Grunt
6424c0baee Use lz4 if possible
Change the default option to "auto"

Acked-by: Victor Toso <victortoso@redhat.com>
2016-01-28 14:16:10 +01: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
df56d585cb log: Add test case for logging code
This gives us a baseline of how the SPICE/glib integration is supposed
to behave.

Everything goes through glib logging facilities, and is impacted by
G_MESSAGES_DEBUG/G_DEBUG=fatal-{warnings,criticals}

Messages in the SPICE_LOG_DOMAIN log domain (output either through
spice_log() or g_log()) will also consider the legacy SPICE_DEBUG_LEVEL
and SPICE_ABORT_LEVEL environment variables. Messages in other domains
will not be impacted by these legacy environment variables.

If spice-common is built without SPICE_DISABLE_ABORT,
spice_return_if_fail()/spice_critical() will abort the program.
g_return_if_fail()/g_critical() will not abort the program.
2016-01-26 15:58:43 +01:00
Christophe Fergeau
417dbedc0b tests: Always build tests
The next commit will introduce a test for log messages. As
libspice-common.la behaviour varies depending on whether
SPICE_DISABLE_ASSERT was defined at compile-time, this test will also
take into account this preprocessor define.
We are more likely to get a consistent build (SPICE_DISABLE_ASSERT being
the same when building libspice-common.la and the test) if both are
built at the same time.

This commit changes that, tests are now built (but not run) at 'make'
time rather than 'make check' time.
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
Pavel Grunt
c3f2d217af m4: Add macro for --with-sasl
It is not used by spice-common, but both server and client can use it.
Compared to current checks in spice-gtk and spice server this macro only
supports libsasl2.

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-12-18 13:57:58 +01:00
Lukas Venhoda
a78da942a7 Remove trailing whitespace 2015-12-18 11:41:15 +01:00
Lukas Venhoda
1118712c59 ppc: Fix alpha state checking on BE machines
The surface before conversion can be either LE or BE on a BE machine.
Check against both BE and LE color order on BE machine.
2015-12-17 16:03:22 +01:00
Lukas Venhoda
2493c60ff7 ppc: Fix colors on ppc when using jpeg
Fixes color order on PowerPC when using jpeg compression.
2015-12-17 16:03:20 +01:00
Lukas Venhoda
98f9097c49 ppc: Fix colors on ppc when using LZ4
Fixes color order on PowerPC when using LZ4 image compression.
2015-12-17 16:03:20 +01:00
Lukas Venhoda
d7719d3e60 ppc: Fix colors on ppc when using LZ
Fixes color order on PowerPC when using LZ image compression.
2015-12-17 16:03:20 +01:00
Lukas Venhoda
bdc9951049 ppc: Fix colors on ppc when using QUIC
Fixes color order on PowerPC when using QUIC image compression.
2015-12-17 16:03:19 +01:00
Lukas Venhoda
76a0c2fae8 ppc: Add support for bigendian color byte order
On LE machine, color order when creating surface will always be A/XRGB.
On BE machines the color order will sometimes be ARGB and sometimes BGRA/X.

This is because we actually create the surface two times on BE machines.
Once with BE order, and then again with LE order. Copying data inbetween
theese two surfaces will byteswap the colors automatically.

This change introduces cases for BGRA/X color byte orders on BE machines.
2015-12-17 16:03:19 +01:00
Lukas Venhoda
fc1f511bb8 pixman_utils: Use PIXMAN_LE_ constants in spice_bitmap_try_as_pixman()
After the previous commit, spice_bitmap_try_as_pixman() can be
simplified as its #ifdef WORDS_BIGENDIAN exactly match what the
PIXMAN_LE_ constants do.
2015-12-17 16:03:19 +01:00
Lukas Venhoda
2ee5cb522e pixman_utils: Add macros for color byte ordering
When using image compression on PowerPC architecture, colors are in
wrong order ARGB -> BGRA.

This commit introduces macros, that will change the color order
according to machine endianness.

Theese macros are similar to QEMU macros in qemu-pixman.h
2015-12-17 16:03:19 +01:00
Christophe Fergeau
02c82b468c test: Use _LDADD rather than _LDFLAGS
This allows libtool/automake to correctly add a dependency from
libspice-common.la to test_marshallers. With _LDFLAGS, the binary won't
automatically get rebuilt/relinked when the lib changes.
2015-12-16 15:03:53 +01:00
Christophe Fergeau
d13fdd7fa9 m4: Fix SPICE_WARNING on el6
autogen.sh fails on el6 unless the second argument to
AC_DEFUN([SPICE_WARNING]) is enclosed in []
2015-12-14 15:30:41 +01:00
Christophe Fergeau
47122befcd ssl-verify: Don't leak GInetAddress
GInetAddress is a GObject, so we must unref anything we create with
g_inet_address_new_*
2015-11-27 17:50:02 +01:00
Christophe Fergeau
9057e0aef3 ssl-verify: Handle NULL return from g_inet_address_new_from_string()
It will return NULL if the string we pass it cannot be parsed.
2015-11-27 17:50:02 +01:00
Marc-André Lureau
f8db887eb0 Use new libcacard.h if possible
libcacard.h requires 2.5.1. Keep compatibility for older versions until
the transition in distros to the standalone version is done.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[ Christophe: add < 2.5.1 fallback ]
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2015-11-25 15:16:35 +01:00
Marc-André Lureau
56a0cf2dad Fix make distcheck
Fix make distcheck both with standalone spice-common and with spice
server.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2015-11-25 14:05:42 +01:00
Lukas Venhoda
401801b5ba canvas_base: Remove redundant switch case block 2015-11-24 08:29:28 +01:00
Francois Gouget
f471022453 build-sys: Add SPICE_CHECK_GSTREAMER_ELEMENTS()
This makes it possible to warn the developer that the GStreamer elements
needed at runtime are missing and give him a hint on how to fix the
issue.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-11-16 16:31:06 +01:00
Francois Gouget
437b817f49 build-sys: Add SPICE_CHECK_GSTREAMER()
This simplifies checking for GStreamer modules by setting all the
variables we normally need.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-11-04 10:34:19 +01:00
Francois Gouget
899a7c75e3 build-sys: Add the SPICE_WARNING() and SPICE_PRINT_MESSAGES m4 macros
A call to SPICE_WARNING() anywhere in the configure file results in the
warning being printed at the end of the configure run where it will be
be visible. This makes it possible to keep the SPICE_WARNING() calls
together with the related feature checks instead of having to put a
separate AC_MSG_WARN() call near the end.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-11-04 10:34:19 +01:00
Christophe Fergeau
304a16fdad build-sys: Add missing # to comment
SPICE_CHECK_SMARTCARD documentation ends with a '-------' comment, but
the # to start the comment is missing, causing a warning message when
running configure.
2015-11-02 12:30:09 +01:00
Christophe Fergeau
d8c3568a31 build-sys: Rename SUPPORT_GL to HAVE_GL
The other conditionals are using the HAVE_ prefix, using HAVE_GL rather
than SUPPORT_GL improves consistency.
2015-10-23 14:05:39 +02:00
Christophe Fergeau
f77805773f build-sys: Set automake conditional in SPICE_CHECK_SMARTCARD
spice-server will use this.
2015-10-23 14:05:39 +02:00
Christophe Fergeau
986ad88c28 build-sys: Fix error in SPICE_CHECK_LZ4 description
This macro does not define a SUPPORT_LZ4 automake conditional.
2015-10-23 14:05:23 +02:00