Commit Graph

601 Commits

Author SHA1 Message Date
Frediano Ziglio
3caedf3bc2 canvas_base: Rename blend to copy for canvas_draw_blend argument
SpiceCopy and SpiceBlend are typedefs of the same structure.
This to prove that canvas_draw_blend and canvas_draw_copy do
exactly the same thing.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2020-04-24 17:18:50 +01:00
Frediano Ziglio
a971c59166 canvas_base: Format canvas_draw_blend similarly to canvas_draw_copy
Just minor style changes.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2020-04-24 17:18:45 +01:00
Frediano Ziglio
05c0c26839 agent: Fix incompatibility with Visual Studio compiler
Flexible arrays cannot have other fields following, even
if the fields are from a containing structure.
To fix this use an union and put the additional field inside
other structure in the union.
The final layout is the same but the compiler is not complaining.
This works on both GCC and Visual Studio.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-24 09:42:46 +01:00
Frediano Ziglio
bb03ff099b Add helper code for agent messages
Add agent.h and agent.c to deal with some common agent job:
- checking message from network and fixing network order.
- send back file transfer status.

Code based on Linux agent and Windows agent.
AgentXxxx and agent_xxx are used to avoid conflicts with protocol.

See agent.h for more detail on how to use these APIs.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-24 09:42:46 +01:00
Frediano Ziglio
81f0331469 messages: Remove obsolete structure definition
This structure is not used by both spice-gtk and spice-server.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2020-04-07 11:07:23 +01:00
Frediano Ziglio
713a3e09fb build: Allow to build disabling code generation
Reduce dependencies if used by agents which do not need
marshallers/demarshallers code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-03 14:31:26 +01:00
Frediano Ziglio
365d7019d5 lz_common: Remove unused commented out define
The DEBUG macro is not used in lz code (or even spice-common).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-17 17:08:17 +00:00
Victor Toso
31a14b20d0 sound: remove celt support
Follow up of spice-protocol's deprecation of celt mode.
See: https://gitlab.freedesktop.org/spice/spice-protocol/-/merge_requests/15

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-17 16:38:10 +00:00
Kevin Pouget
ec4e44200a utils: add set_bitmap/test_bitmap functions
This patch introduces `set_bitmap` and `test_bitmap` + relevant
macros, adapted from `<qemu>/include/qemu/bitops.h`.

These functions differ from `set_bit`/`test_bit` as they can set/test
bits in bit arrays longer than scalar data-types.

Signed-off-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-04 16:43:48 +00:00
Frediano Ziglio
35f45282d4 snd_codec: Update field names in function documentation
in_data field was renamed to in_ptr.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-02-07 17:07:57 +00:00
Frediano Ziglio
ea864c70d9 lz_compress: Cleanup unused macros
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-02-07 15:27:03 +00:00
Frediano Ziglio
d5d1d5b0bf lz_decompress: Read "ctrl" inside loop
Remove code duplication

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-02-07 15:27:00 +00:00
Frediano Ziglio
a446b5b27b lz_decompress: Move variable declaration in nested scope
No need to compute these variable always, only if we have
a reference to a previous sequence.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-02-07 15:26:58 +00:00
Frediano Ziglio
08fafdbb33 lz_decompress: Reindented comment
Just space changes

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-02-07 15:26:56 +00:00
Frediano Ziglio
6595de58a2 lz_decompress: Simplify loop
The loop is always executed once so use a do {} while construct
to avoid the repetition.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-02-07 15:26:53 +00:00
Frediano Ziglio
109f6a4802 lz_decompress: Do not execute nested checks
Boundaries checks already done some lines above, no needs
to repeat for each pixel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-02-07 15:26:51 +00:00
Frediano Ziglio
ac4763bd89 lz_decompress: Constify some variable
Make clear they are not supposed to be changed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-02-07 15:26:34 +00:00
Frediano Ziglio
48944f6f41 marshallers: Avoid some useless pointers in SpiceMarshallerData
"buffers" and "marshallers" are always pointing to the static
buffers inside the same structure.
Use single array fields to avoid having initialize and have them.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-02-07 14:52:29 +00:00
Frediano Ziglio
87e2db9798 Reuse new spice_extra_assert macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-02-07 13:26:00 +00:00
Frediano Ziglio
e761c2d4de log: Add spice_extra_assert
This macro was suggested to simplify hot path expensive checks
which should be disable in production environments.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-02-07 13:24:45 +00:00
Frediano Ziglio
f3d6c5f322 snd_codec: Do not include not needed headers
Include headers required for implementation only in the
implementation file.
This remove dependency and avoid the user component having to
check for header flags (in this case HAVE_CELT051 and HAVE_OPUS).
This make easier integration in other components.
This also make compilation faster.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-02-06 19:26:21 +00:00
Frediano Ziglio
da6a405f25 snd_codec: Avoid some useless casts declaring struct type
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-15 21:24:27 +00:00
Frediano Ziglio
2561f62283 quic: Do not include quic_config.h in quic.h
quic_config is used only by the implementation so include it
only from the implementation file.
This remove dependency.
This make easier integration in other components.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-10 08:22:02 +00:00
Frediano Ziglio
34807c600c quic: Use G_UNLIKELY in some hot paths
The buffers provided should be big enough to avoid to ask
for more space much often.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-10 08:13:11 +00:00
Frediano Ziglio
5a31a3850d quic: Remove unused include header
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-11-26 13:38:07 +00:00
Kevin Pouget
f191053a8c build: Introduce the agent-interface as an alternative instrumentation library
The agent-interface is an experimental instrumentation library for
capturing and sharing Spice performance indicators with an external
agent.

    --enable-instrumentation=[recorder/agent/no]
             Enable instrumentation [default=no]

The former configuration option '--enable-recorder' is transformed
into '--enable-instrumentation=recorder'.

Signed-off-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-10-18 17:04:09 +01:00
Kevin Pouget
3331ad1a04 agent-interface: add configuration functions
agent_interface_start: this function allows launching the agent
interface (ie, its listening socket) on a given port.

agent_interface_set_on_connect_cb: this function allows passing a
callback function that will be triggered when a client (a Local Agent)
connects to the Agent Interface socket.

agent_interface_set_forward_quality_cb: this function allows SPICE to
provide a function that will forward Quality messages received by the
Agent Interface towards SPICE server, for a centralized processing of
the messages.

Signed-off-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-10-18 17:04:06 +01:00
Kevin Pouget
a16c7027c5 agent-interface: introduce the core of the Agent Interface
When initialized (recorder_initialization), the Agent Interface launch
a GThread (handle_communications) that opens a TCP server socket and
waits for Smart Local Agent connections. When a Local Agent connects
to the sockets, the communication is initialized
(agent_initialize_communication), the communication socket is stored
and the list of Recorders is sent. In return, the local agent
indicates which recorders to enable.

On the SPICE side, the Agent Interface handles the record() calls
(recorder_append*). When a record is received from SPICE, and if the
recorder is enabled, the record entry is sent through the TCP
connection. Otherwise, the record is dropped.

Signed-off-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-10-18 17:04:03 +01:00
Kevin Pouget
2640ff294a common/recorder.h: do not complain on unused (dummy) recorders
Signed-off-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-11 10:02:44 +01:00
Frediano Ziglio
cc109a83b6 recorder: Update
Pull version update and some features.
Version update changed copyright in files to LGPLv2, more
compatible with SPICE.
One of the feature is the support for absolute time.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-29 14:53:16 +01:00
Frediano Ziglio
4fc4c2db36 Do not check for HAVE_CONFIG_H
This should always be defined and including config.h is a requirement.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-05-02 09:33:05 +01:00
Frediano Ziglio
09fba0677d gitignore: Ignore auto generated generated_messages.h file
git.mk seems to have issues with Makefile rules generating multiple
files so add manually this file.
This avoid SPICE server to generate distribution files with
"-dirty" suffix.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-04-30 11:31:20 +01:00
Uri Lublin
5bcfa711d9 codegen Makefile: add common/ to --include client_marshallers.h
Fixes out-of-tree builds.

For example spice-gtk out-of-tree build fails with:
  ../subprojects/spice-common/common/generated_client_marshallers.h:19:10:
      fatal error: client_marshallers.h: No such file or directory
   #include "client_marshallers.h"
            ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-04-23 08:39:34 +01:00
Eduardo Lima (Etrunko)
47ba8e0f25 meson: Make targets list store dictionaries instead of lists
Access the items by names instead of indexes.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-04-04 18:07:32 +01:00
Frediano Ziglio
bfebdc5eb4 meson: Do not build generated files twice
spice-gtk and spice-server will use spice_common_client_dep
and spice_common_server_dep as dependencies.
However they will depend on both spice-common client/server
libraries and their sources causing the sources to be compiled
multiple times and causes linker errors on spice-gtk.
The issue can be observed doing a "find -name \*generated\*.o"
in Meson build directory.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-04-04 18:07:28 +01:00
Frediano Ziglio
f236c1ef94 meson: Fix dependency of generated files
All generated file depends on generated_messages.h which is
generated too.
So add an explicit dependency from all generated file
(except generated_messages.h generator) to generated_messages.h
generator.
This fixes compiling SPICE server where generated_messages.h
was not generated at all.
Add dependency to the include header to make Meson generate the
proper include flag.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-04-04 18:07:24 +01:00
Christophe Fergeau
4951c71553 log: Let gcc know about the logging macros which abort
This commit adds a SPICE_UNREACHABLE macro (courtesy of Frediano)
so that gcc does not think that code control can go past
spice_return_{val_,}if_fail(), spice_critical() and spice_error()

This avoids this kind of warnings:

fallthrough.c:

 #include "log.h"

int main(int argc, char **argv)
{
    switch(argc) {
        case 1:
            spice_critical("foo");
       default:
            return 0;
    }
}

$ gcc  -c    $(pkg-config --cflags --libs glib-2.0 spice-protocol)
       -I common   -Wimplicit-fallthrough=5 ./fallthrough.c
In file included from ./fallthrough.c:1:
./fallthrough.c: In function 'main':
common/log.h:73:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
   73 |     spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, "" format, ## __VA_ARGS__); \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./fallthrough.c:8:25: note: in expansion of macro 'spice_critical'
    8 |                         spice_critical("foo");
      |                         ^~~~~~~~~~~~~~
./fallthrough.c:9:17: note: here
    9 |                 default:
      |                 ^~~~~~~

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-04-01 17:33:17 +01:00
Frediano Ziglio
bbb5163e61 recorder: Update
Pull some fixes and features.
One of the feature is the support for @output setting to redirect
log output.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2019-03-29 17:58:21 +00:00
Christophe Fergeau
1fbac71c84 quic: Fix QUIC_VERSION definition
QUIC_VERSION_MINOR is never used.. Set QUIC_VERSION_MINOR to the same
version as QUIC_VERSION_MAJOR to avoid breaking backwards compatibility,
and fix the QUIC_VERSION macro.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-29 16:58:20 +01:00
Christophe Fergeau
a294cad01c build: Update verify.h to latest version
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-29 16:58:14 +01:00
Christophe Fergeau
5ef652b7e3 build: Add missing G_GNUC_PRINTF annotations
They were suggested by gcc when using -Wsuggest-attribute=format

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-29 16:58:07 +01:00
Christophe Fergeau
2f64e2edbb lz: Don't try to print uninitialized variable
encoder->type is only going to be set by lz_set_sizes() after the
error() call. We can use 'type' directly which is what encoder->type is
going to be set to.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-29 11:29:25 +01:00
Christophe Fergeau
187df0cfdb backtrace: Add missing include
This fixes a warning about missing prototype for backtrace()

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-29 11:29:25 +01:00
Christophe Fergeau
79a9fad3a2 canvas_base: Fix variable shadowing warning
canvas_base.c is #included by spice-common users. They currently don't
enable this warning, but if/when they do, we don't want code from
spice-common to trigger it.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-29 11:29:25 +01:00
Frediano Ziglio
bd75d3f934 Generate automatically most C message declarations
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-18 13:02:03 +00:00
Frediano Ziglio
5f1f369e41 Allow to generate C declarations for spice.proto
Generate and include C declarations.
Next patch will use this facility.
Since none of the spice.proto types are decorated with @declare,
adding the #include in messages.h won't have any bad consequences.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-18 13:02:01 +00:00
Frediano Ziglio
dac34baaab codegen: Generate headers while generating code
Python script generates code and header together however allowed
to save only one of them.
Allows to save both of them together to reduce number of time
we call Python script.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-18 13:01:52 +00:00
Frediano Ziglio
fce4486755 build: Remove snd_codec.h from EXTRA_DIST
The file is already distributed as included in the source list.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-13 10:58:28 +00:00
Frediano Ziglio
302e30ff43 codegen: Remove support for --ptrsize
This option was used in protocol 1 to generate 64 bit pointers.
A pointer in the protocol is an offset in the current message.
This allows the possibility to have messages with pointers with more
than 4GB. This feature was removed and not used in protocol 2.
The reason this feature was correctly removed in protocol 2 is that
having 64 bit pointers in the protocol would require messages larger
than 4GB which would cause:
- huge latency as a single message would take more than 4 seconds
  to be send in a 10Gb connection;
- huge memory requirements.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-08 11:09:02 +00:00
Frediano Ziglio
92d5dfd4bf messages: Remove fields not used by the protocol
These fields are not used by the protocol (not in spice.proto, nor
will be used in the generated (de)marshallers).
Avoid spice-gtk and spice-server to use them by mistake.
This can cause memory errors (data_size is not used or is not set
correctly) and useless code (spice-gtk uses the pub_key* fields but
these fields are not sent to the server as the protocol does not have
them).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-07 21:07:18 +00:00