Commit Graph

2019 Commits

Author SHA1 Message Date
Frediano Ziglio
108d11f4aa Move others glz fields to dcc-encoders
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-14 15:07:31 +01:00
Frediano Ziglio
41231aa4f8 Change dcc_encoders_init to take ImageEncoders instead of DisplayChannelClient
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-14 15:07:29 +01:00
Frediano Ziglio
b46984ed30 Move some glz fields to ImageEncoders
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-14 15:07:28 +01:00
Frediano Ziglio
86b702a7d0 Add a structure to hold ImageEncoders shared data
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-14 15:07:23 +01:00
snir sheriber
903c91cd30 LZ4 compression is now available at the 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

If SPICE_USBREDIR_CAP_DATA_COMPRESS_LZ4 capability is available &&
data_size > COMPRESS_THRESHOLD && !AF_LOCAL data will be sent
compressed otherwise data will be sent uncompressed (also if
compression has failed)

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:12:59 +01:00
Frediano Ziglio
6e29efadbc Remove unused DCC_TO_WORKER macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-06-10 13:36:00 +01:00
Frediano Ziglio
9c5a8d5bce More encapsulation for dcc_encoders_free
Encoders function should not use DisplayChannelClient

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-10 09:15:24 +01:00
Frediano Ziglio
c2bc754559 Encapsulate zlib information in ImageEncoders structure
This change is less clean the other similar patches as zlib and
glz require more steps.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-10 09:15:17 +01:00
Frediano Ziglio
21a90ae986 Move image_encoders_compress_lz4 to dcc-encoders.c
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:50:12 +01:00
Frediano Ziglio
aa10a2ca2a Prepare to move dcc_compress_image_lz4 to ImageEncoders
Remove all DisplayChannel(Client) dependencies.
Rename function.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:50:10 +01:00
Frediano Ziglio
6d70d15d64 Encapsulate lz4 information in ImageEncoders structure
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:50:02 +01:00
Frediano Ziglio
25c0b204c4 Move image_encoders_compress_jpeg to dcc-encoders.c
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:32:50 +01:00
Frediano Ziglio
9d92a2edc8 Prepare to move dcc_compress_image_jpeg to ImageEncoders
Remove all DisplayChannel(Client) dependencies.
Rename function.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:32:48 +01:00
Frediano Ziglio
7b6cb37cc0 Encapsulate jpeg information in ImageEncoders structure
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:32:26 +01:00
Frediano Ziglio
cff7950aa3 Move image_encoders_compress_lz to dcc-encoders.c
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:11:30 +01:00
Frediano Ziglio
c5caf0dddd Prepare to move dcc_compress_image_lz to ImageEncoders
Remove all DisplayChannel(Client) dependencies.
Rename function.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:11:27 +01:00
Frediano Ziglio
a25182f060 Encapsulate lz information in ImageEncoders structure
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:11:20 +01:00
Frediano Ziglio
fa0a579a65 Move image_encoders_compress_quic to dcc-encoders.c
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 21:14:43 +01:00
Frediano Ziglio
645b8af35b Prepare to move dcc_compress_image_quic to ImageEncoders
Remove all DisplayChannel(Client) dependencies.
Rename function.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 21:12:43 +01:00
Frediano Ziglio
d7fb16c80e Encapsulate quic information in a new ImageEncoders structure
Start putting all encoding code into dcc-encoders.c.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 21:12:34 +01:00
Frediano Ziglio
2d34002e59 Move marshalling code from dcc-encoders to dcc-send
No reasons why dcc-encoders should know about marshalling.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-06-09 06:55:43 +01:00
Frediano Ziglio
fa4eb13f7b Add compress_buf_free function
dcc-encoders should be in change of allocate and free the structure
don't put internal assumptions (which functions are used for memory
management) in different files.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-06-09 06:55:40 +01:00
Frediano Ziglio
aed25d8407 record: Use spice_get_monotonic_time_ns instead of stat_now(CLOCK_MONOTONIC)
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-08 15:27:55 +01:00
Frediano Ziglio
cf4b289f29 record: Use proper type for timestamp
Use red_time_t to make sure timestamp has the right precision even
on 32 bit systems.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-08 15:27:48 +01:00
Frediano Ziglio
69628ea137 improve primary surface parameter checks
Primary surface, as additional surfaces, can be used to access
host memory from the guest using invalid parameters.

The removed warning is not enough to prevent all cases. Also a warning
is not enough to stop an escalation to happen.
The red_validate_surface do different checks to make sure surface
request is valid and not cause possible buffer/integer overflows:
- format is valid;
- width is not large to cause overflow compared to stride;
- stride is not -2^31 (a number which negate is still <0);
- stride * height does not overflow.

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1312980.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-06-08 09:59:54 +01:00
Frediano Ziglio
790d8f3e53 factor out red_validate_surface function to validate surface parameters
Make possible to reuse it outside red-parse-qxl.c.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-06-08 09:59:31 +01:00
Frediano Ziglio
a051a4d884 Move dcc glz field initialization into dcc_new
There is no reason to initialize these fields in two different places.
Note that an usage between dcc_new and the function where these
field were initialised would have resulted in a crash.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-07 23:09:45 +01:00
Frediano Ziglio
ddd3b286ad record: Make red_record_cursor_cmd static
This function is never used outside this compile unit.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-07 22:43:48 +01:00
Frediano Ziglio
2b58c60bb1 replay: Handle cursor commands
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-07 22:43:30 +01:00
Victor Toso
9df00ebdc8 char-device: fix mismatch of client tokens
As the tokens counter were not being reset you could enter in a
situation where client thinks it has more tokens then server which
would eventually lead to client's disconnection from 0c5eca97f1
onwards (before it was crashing).

It is easy to check the above situation if you track the amount of
tokens you have in the client and simply kill and restart the agent
while doing some file transfer: the client could reach more then 13
tokens which should not really be possible.

Based on patch from Frediano Ziglio <fziglio@redhat.com>

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-06-07 18:06:31 +01:00
Frediano Ziglio
b46fcbb3ab replay: Load cursor commands
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-06 09:29:12 +01:00
Frediano Ziglio
52f9850be8 worker: Record cursor commands
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-06 09:29:12 +01:00
Frediano Ziglio
3f4ba5e5f5 record: Support cursor commands
Use red_record_cursor_cmd to be able to record cursor commands.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-06 09:28:39 +01:00
Frediano Ziglio
18c99e008f avoid integer underflow under 32 bit architectures
The segment_size computation on 32 bit can lead to big numbers which
can lead to negative offset. Let'ss avoid to underrun the buffer,
as it's not checked.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-06-06 08:58:52 +01:00
Frediano Ziglio
3dd93a1f5f fix integer overflows in red_get_path
Use 64 bit arithmetic to avoid overflows.
The multiplication between count and a constant can overflow.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-06-05 09:44:42 +01:00
Frediano Ziglio
4c171dbd0c Remove unused parameter
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
2016-06-04 10:10:08 +01:00
Frediano Ziglio
e8d7fecbc2 Remove only written field
EncoderData::dcc field is never read back.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-03 16:31:20 +01:00
Francois Gouget
ff1a381f60 red-parse-qxl: Check consistency of QXL_DRAW_COPY operations
The source area should not extend outside the source bitmap, or have
swapped coordinates.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-06-03 11:37:48 +01:00
Jonathon Jongsma
3037b078f5 Remove global "allowed" variable
This variable was always the same value as
dispatcher_allows_client_mouse.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-02 16:06:41 -05:00
Frediano Ziglio
852fc16086 Remove only written lock_count variable
Possibly used for debugging or an initial recursive lock.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-02 17:04:30 +01:00
Frediano Ziglio
a1715a01d4 channel: Remove clients_num and use g_list_length
This fixes a regression introduced by
4028fb1c79, where clients_num
was not updated correctly anymore.

There is no reason to cache the number of elements on that list,
as the expected number of clients is quite small.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2016-06-01 16:56:16 +01:00
Frediano Ziglio
795d274e2b smartcard: Avoid crash on remove_interface call
SpiceCharDeviceInstance is not a GObject, the GObject is char_device->st
as the above line is stating.
The crash never happen as Qemu never calls spice_server_remove_interface
for smartcards.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-01 16:24:27 +01:00
Frediano Ziglio
80f2d7731d Simplify setting char device instance
Setting "sin" property is equivalent to call
red_char_device_reset_dev_instance so there is no need for a if/else
as the code is doing mostly (beside setting agent_attached) the
same thing

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-01 16:24:24 +01:00
Frediano Ziglio
6fbefcc3c3 Remove obsolete comment
AGENT_CONNECT with token count is implemented by agent_connected_tokens
message.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-01 16:21:07 +01:00
Frediano Ziglio
8a314520cc Fix some typos in comments
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-01 16:09:44 +01:00
Jonathon Jongsma
27d18b659f Replace RedClient::channels with GList
Allows us to not expose the client_link in RedChannelClient.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-05-31 16:29:04 +01:00
Frediano Ziglio
0c5eca97f1 Handle flow control without crashing for agent
RedCharDevice used for the agent has flow control enabled.
This make possible for red_char_device_write_buffer_get to return NULL.
Handle such situation without crashing avoiding NULL dereference.

This fixes https://bugs.freedesktop.org/show_bug.cgi?id=95416.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2016-05-31 16:26:33 +01:00
Frediano Ziglio
5d2fb6a897 Avoid getting channel from client
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-27 18:02:29 +01:00
Frediano Ziglio
5841a2abda Move upcast conversion to a safer place
Upcast conversions are by definition unsafe. There are however some
location where such conversion are more safe. In this case send_item
callback is registered specifically for this type of RedChannel making
the conversion more reliable.
The other conversion (CursorChannel -> RedChannel) became safe.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-27 09:41:01 +01:00
Frediano Ziglio
8d25e03371 Add some comments to cursor-channel.h header
Explain usage of the class.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-27 09:32:58 +01:00