Commit Graph

632 Commits

Author SHA1 Message Date
Frediano Ziglio
dde1fe3533 log: remove spice_static_assert macro
The macro was misused and not doing static check.
Spice have other working static check macros to use.
The macro is used only by spice-common so removing it
does not cause issues to other depending projects.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-06-22 11:34:19 +01:00
Frediano Ziglio
2ff5c77fff quic: constantify some variable
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-06-22 11:34:19 +01:00
Frediano Ziglio
f80b229e07 canvas-base: Do not attempt useless cast on stride adjustment
memmove already deal with any alignment so there's no
reason to have row byte pointer cast to uint32_t.
This also remove the confusing "dest" terminology used. The image
is aligned in place so the image bits are used for both destination
and source.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-06-21 12:57:52 +01:00
Christophe de Dinechin
858a0bfae9 Avoid clang warnings on casts with stricter alignment requirements
For example, something like this:
    uint8_t  *p8;
    uint32_t *p32 = (uint32_t *) p8;

generates a warning like this:
  spice-channel.c:1350:10: error: cast from 'uint8_t *' (aka 'unsigned char *') to
      'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to
      4 [-Werror,-Wcast-align]

The warning indicates that we end up with a pointer to data that
should be 4-byte aligned, but its value may be misaligned. On x86,
this does not make much of a difference, except a relatively minor
performance penalty. However, on platforms such as older ARM, misaligned
accesses are emulated by the kernel, and support for them is optional.
So we may end up with a fault.

The intent of the fix here is to make it easy to identify and rework
places where actual mis-alignment occurs. Wherever casts raise the warning,
they are replaced with a macro:

- SPICE_ALIGNED_CAST(type, value) casts value to type, and indicates that
  we believe the resulting pointer is aligned. If it is not, a runtime
  warning will be issued. This check is disabled unless
  --enable-alignment-checks is passed at configure time

- SPICE_UNALIGNED_CAST(type, value) casts value to type, and indicates that
  we believe the resulting pointer is not always aligned.

Any code using SPICE_UNALIGNED_CAST may need to be revisited in order
to improve performance, e.g. by using memcpy.

There are normally no warnings for SPICE_UNALIGNED_CAST, but it is possible
to emit debug messages for mis-alignment in SPICE_UNALIGNED_CAST
by configuring with CFLAGS=-DSPICE_DEBUG_ALIGNMENT.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
2017-06-20 11:33:45 +02:00
Frediano Ziglio
765652da1d Use SPICE_ATTR_PACKED instead of custom ATTR_PACKED
Reuse {start,end}-packed headers to specify packed structure.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-06-15 12:47:36 +01:00
Christophe de Dinechin
30a33922d8 Use space and not colon to separate log domains
According to https://developer.gnome.org/glib/stable/glib-running.html,
G_MESSAGES_DEBUG is a space-separated list of log domains for which
informational and debug messages should be printed

Note that the equivalent code in spice-util.c gets it right.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-06-09 09:56:29 +01:00
Frediano Ziglio
1d7acdcf57 log: Use GLib logging levels directly
As we moved toward GLib logging instead of having to convert
every time the log level from the old system to GLib use
directly GLib constants.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-06-09 09:46:35 +01:00
Frediano Ziglio
31ebe7c6d5 fix indentation on previous patch
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-06-01 10:12:34 +01:00
Frediano Ziglio
564635e3c1 log: Check log level from spice_logv
This was suggested by Christophe de Dinechin as an optimisation.
Most of the messages won't be processed for formatting.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-05-31 10:20:58 +01:00
Frediano Ziglio
a607077883 log: Optimise glib_debug_level check
Use INT_MAX for invalid value to remove a test in code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-05-31 10:20:56 +01:00
Frediano Ziglio
f4a4d52702 log: Do not check impossible function return
spice_log_level_to_glib never returns 0 so don't check
for this value.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-05-31 10:20:50 +01:00
Frediano Ziglio
36fd7325e5 codegen: Fix license name
License reported for MIT was indeed a BSD 3-Clause license,
not a MIT one (https://opensource.org/licenses/BSD-3-Clause).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-05-18 16:40:36 +01:00
Christophe de Dinechin
5faba1e860 Style adjustment - Making code match surrounding style
Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-05-18 16:37:21 +01:00
Frediano Ziglio
1d527e21d5 codegen: Allows to specify license of generated files
Some headers for spice are distributed using MIT licenses.
Allows to generate such headers if needed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-05-08 09:54:10 +01:00
Christophe Fergeau
af682b1b06 log: Follow spice style guidelines for #include in log.h
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-31 12:14:02 +02:00
Christophe Fergeau
0996c33d6d log: Add missing stdio.h include
This is needed because spice_printerr uses fprintf/stderr

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-31 10:37:28 +01:00
Marc-André Lureau
1fd73d0a98 build-sys: don't dist spice-protocol.html
The HTML file is not built by default.
This fixes make distcheck in spice-gtk.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-28 14:57:50 +02:00
Frediano Ziglio
4423ea5d2a region: Avoid possible memory corruption
pixman_region32_copy assume that destination (first argument)
is initialized and can use a pointer inside based on different
conditions.
As intersection is not initialized this can cause different
memory problems.
This resulted in memory leak detection from address sanitizer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-02-28 15:26:54 +00:00
Sebastian Andrzej Siewior
ab7cae45bc ssl: Use ASN1_STRING_get0_data instead of ASN1_STRING_data
The latter is deprecated, so might be removed at  some point in the
future. This also adds a compatibility wrapper for OpenSSL < 1.1.0.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-16 16:40:52 +01:00
Jonathon Jongsma
c9ecd0e29e Document REGION_TEST_* bitmasks
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-03 11:07:32 -06:00
Frediano Ziglio
30e8237934 protocol: Add support for VP9 video codec
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-01-31 08:51:33 +00:00
Victor Toso
6439bec0de protocol: add preferred video codec message
Client might want to choose a preferred video codec for streaming for
different reasons which having hardware decoder support being the most
interest one.

This message allows the client to send an array of video codecs in
order of preference.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-01-06 12:20:47 +00:00
Frediano Ziglio
86dcd22d33 marshaller: Remove deprecated replacement functions
spice-common has no stable ABI/API.
Also these function caused linking problems as these functions
were defined multiple times.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-12-08 13:49:13 +00:00
Jonathon Jongsma
adb36c6185 Marshaller: rename _add_ref() to _add_by_ref()
The spice_marshaller_add_ref() family of functions is confusing since it
sounds like you're incrementing a reference on the marshaller. What it
is actually doing is adding a data buffer to the marshaller by reference
rather than by value. Changing the function names to _add_by_ref() makes
this clearer.

The old functions are deprecated and are simply inline functions that
call the new functions.

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-06 11:21:55 -06:00
Victor Toso
a5871c80a9 sw-canvas: remove unused defines
Including CANVAS_SINGLE_INSTANCE that was bounded to CanvasBase user
data which was removed in previous commit

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-30 15:36:29 +01:00
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
Pavel Grunt
5f241e655b spice-deps: Set python version based on modules availability
Building spice or spice-gtk from git requires python modules pyparsing
and six. Search for them in the both Python versions and set
the Python version accordingly.
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-29 11:43:25 +01:00
Frediano Ziglio
6b409c4a79 Detect LZ4_compress_fast_continue function
Newer lz4 headers give deprecated warning using LZ4_compress_continue
instead of LZ_compress_fast_continue so detect this function
to allow usage and avoid the warning.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-28 18:36:21 +00:00
Pavel Grunt
48da2c6654 spice-deps: Make LZ4 check depending on function
LZ4 changed versioning scheme from r131 to v1.7.3 making our configure
fail with (1.7.3 < 129).

Switch from version checking to checking that the necessary function
is available.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-25 14:01:04 +00:00
Pavel Grunt
de1dee75c2 spice-deps: Fix accidently deleted comment
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-24 15:54:09 +00: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
Victor Toso
215b7571d4 Fix gitignore with new docs folder
The generated spice_protocol.html file and the Makefile were not
included in gitignore. This patch fixes it.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2016-10-27 18:05:12 +02:00
Frediano Ziglio
e5a03766ec Add protocol documentation for "channel" and "protocol"
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-10-18 14:57:13 +01:00
Frediano Ziglio
ced5c55925 Fix BNF notation in documentation
Definition names have no angular brackets.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-10-18 14:57:13 +01:00
Frediano Ziglio
4673a61cce More work on attribute protocol documentation
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-10-17 11:43:49 +01:00
Frediano Ziglio
7773c0d59b Extended protocol documentation
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-10-17 11:43:47 +01:00
Frediano Ziglio
89426e491e Start writing some documentation on protocol
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-10-17 11:43:45 +01:00
Frediano Ziglio
3983097ed5 Start adding protocol file documentation
The protocol file is not documented and people have to read code to
understand the specification.
This can lead to unexpected or not optimal results so it's better
to have it documented.
The m4/spice_manual.m4 came from spice server and is meant to be
reused.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-10-17 11:43:26 +01:00
Victor Toso
642308ecec build-sys: requires liblz4 129 or newer
LZ4 data compression on spicevmc channel uses LZ4_compress_default()
API introduced in 129 release (see commit bellow)

[0] https://github.com/Cyan4973/lz4/commit/1b17bf2ab8cf66dd2b740e

Acked-by: Pavel Grunt <pgrunt@redhat.com>
Reported-by: Fabio Fantoni <fantonifabio@tiscali.it>
2016-08-09 16:40:00 +02:00
Francois Gouget
38047fb46f codegen: Fix compatibility with Python 2.6
Python 2.6 does not have a flags parameter.
This is needed for RHEL 6.8.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-07-30 08:57:05 +01:00
Pavel Grunt
22f8dd18f0 codegen: Do not generate extra null check
Spotted by coverity

Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-07-26 10:16:31 +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
0eb567e6fb codegen: Improve header guard generation
Until now, the same header guard was used for all generated .h files.
Now the header guard name is based on the name of the file being
generated so that it's different for each .h file.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-06-24 10:02:06 +01:00
Christophe Fergeau
806d3273fa codegen: Use "" rather than <> for cmdline includes
Includes specified on the command line are currently #included with <>
rather than "". However, they are usually spice-common headers, so it
makes more sense to include them using ""

Acked-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-06-24 09:36:49 +01:00
Christophe Fergeau
3029eae630 codegen: Fix 'registred' typo
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-06-24 07:47:41 +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