Commit Graph

626 Commits

Author SHA1 Message Date
Qiang Yu
ebf052d051 marshaller: suport multi fd
For sending multi plane gl scanout.

Signed-off-by: Qiang Yu <yuq825@gmail.com>
2025-03-25 15:58:15 +08:00
Vivek Kasireddy
bb8f66983a common: Add a udev helper to identify GPU Vendor
Given that libudev is widely available on many Linux distros, we
can use the relevant APIs to iterate over all the devices associated
with the drm subsystem to figure out if a specific vendor GPU
is available or not.

This capability (identifying GPU Vendor) is useful to determine
whether to launch Gstreamer pipeline using h/w accelerated
plugins. On systems where libudev is not available (Windows,
MacOS, etc) we'd have to make this determination based on the
availability of the relevant plugins in the Gstreamer registry.

Cc: Frediano Ziglio <freddy77@gmail.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Dongwon Kim <dongwon.kim@intel.com>
Cc: Hazwan Arif Mazlan <hazwan.arif.mazlan@intel.com>
Cc: Jin Chung Teng <jin.chung.teng@intel.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2023-10-17 10:32:27 +01:00
Frediano Ziglio
58d375e5ea Replace EVP_PKEY_cmp with EVP_PKEY_eq
EVP_PKEY_cmp was made obsolete in OpenSSL.
The main reason is that the return value is not coherent with
other *_cmp functions.
So it was replaced by EVP_PKEY_eq, which does the same.
Rename to avoid a deprecation warning on newer OpenSSL releases.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-06-29 07:57:53 +01:00
Frediano Ziglio
bb0831cc10 canvas_base: Fix missing ntohl for Win32 platform
Win32 requires winsock2.h to be included in order to use ntohl.
To avoid the include use GUINT32_FROM_BE instead, already available.

This problem was reported by Biswapriyo Nath whom also tested the
solution for Win32.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2021-05-07 19:42:38 +01:00
Marc-André Lureau
91362d045a Fix invalid vdagent buffer access
The caller use the "size" argument in different ways. Either the size of
the data to convert, or the end boundary to be deduced by offset.

Fix it so the the "size" argument means the amount in bytes of data to
convert, that seems simpler and saner. (yay C)

Fixes: spice#53

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-04-13 21:30:38 +04:00
Frediano Ziglio
b24fe6b66b quic: Avoid possible buffer overflow in find_bucket
Proved by fuzzing the code.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-09-17 06:46:57 +01:00
Frediano Ziglio
ef1b6ff7b8 quic: Check RLE lengths
Avoid buffer overflows decoding images. On compression we compute
lengths till end of line so it won't cause regressions.
Proved by fuzzing the code.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-09-17 06:46:57 +01:00
Frediano Ziglio
404d74782c quic: Check image size in quic_decode_begin
Avoid some overflow in code due to images too big or
negative numbers.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-09-17 06:46:57 +01:00
Frediano Ziglio
762e0abae3 quic: Check we have some data to start decoding quic image
All paths already pass some data to quic_decode_begin but for the
test check it, it's not that expensive test.
Checking for not 0 is enough, all other words will potentially be
read calling more_io_words but we need one to avoid a potential
initial buffer overflow or deferencing an invalid pointer.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-09-17 06:46:57 +01:00
Marc-André Lureau
fa0c199d33 agent: fix vdagent monitor flag filtering
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-09-17 06:46:26 +01:00
Frediano Ziglio
0d7d0d35d8 agent: Extend agent_check_message to support VDAgentMonitorsConfig extension
Add support for VD_AGENT_CONFIG_MONITORS_FLAG_PHYSICAL_SIZE flag.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2020-09-15 11:55:45 +01:00
Frediano Ziglio
b03c894c21 quic: Fix typo in comment
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-09-04 21:05:48 +01:00
Frediano Ziglio
03bde6fdb2 quic: Constify a parameter
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-08-31 12:36:15 +01:00
Frediano Ziglio
c39cc1b1ef ssl_verify: Do not check IP if we fail to resolve it
There's no point on checking an empty IP address, an IP
address is never empty.
This also solve some compiler warnings trying to possibly
pass a NULL pointer to memcmp or setting a variable without
reading it.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-08-27 18:50:01 +01:00
Frediano Ziglio
7daee890be quic_tmpl: Remove unused bpc parameter
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-08-25 12:26:20 +01:00
Frediano Ziglio
b843d02a1b Avoid usage of GCC extension for __VA_ARGS__ where possible
The "##" before __VA_ARGS__ is a GCC extension.
Try to limit its usage where necessary.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-08-10 09:55:27 +01:00
Frediano Ziglio
ca1016eb15 backtrace: Do not attempt to compile if spice_backtrace is empty
In backtrace.h spice_backtrace is defined as:

  #if defined(WIN32) && !defined(__MINGW32__)
  #define spice_backtrace()
  #else
  ..

so don't try to compile if an empty macro is used.
Currently not causing any issue as we use MingW on Windows but
does not hurt is code is more portable.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-08-10 09:55:10 +01:00
Haochen Tong
bca74fb6c9 pixman_utils: fix clang "unused functions" warning
Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-07-11 08:17:18 +01:00
Frediano Ziglio
35be203f42 snd_codec: Use better type for snd_codec_create mode
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-07 13:09:38 +01:00
Frediano Ziglio
283d82b0a3 snd_codec: Use better type for function result
Instead of just plain preprocessor macros use an enum.
This is more type safe and could produce better debugging
type information.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-07 13:09:36 +01:00
Frediano Ziglio
8d9a79dd7d snd_codec: Use better types for snd_codec_is_capable
mode should be an enumeration value of SpiceAudioDataMode.
Return type is just a boolean.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-07 13:09:14 +01:00
Frediano Ziglio
ba7af04f65 rect: Avoid usage of "small"
Some Windows headers define "small" causing issues.
Use "small_rect" instead. For coherence use "big_rect" instead of
"big".

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-06-25 16:17:39 +01:00
Frediano Ziglio
5d8feeb19a Reuse macros from spice-protocol
Reuse SPICE_GNUC_NORETURN and SPICE_GNUC_PRINTF

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-19 14:45:36 +01:00
Frediano Ziglio
7a84f60267 build: Remove dependency to gio2 from common and server libraries
The dependency is required only for client part.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-04-26 16:50:00 +01:00
Frediano Ziglio
4c6b360f6b canvas_base: Remove canvas_draw_blend/canvas_draw_copy duplication
The 2 functions are exactly the same.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2020-04-24 17:18:52 +01:00
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