Commit Graph

2182 Commits

Author SHA1 Message Date
Frediano Ziglio
435daaffdb worker: RedCompressBuf optimization
Move large buffer field at the end of structure.
Due to the way machine address memory this usually can reduce code size
and make program sligthly faster.
Actually reduce size by 100 bytes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-26 10:27:58 +01:00
Frediano Ziglio
b009a7ff34 Prevent setting invalid image compression values
In case of invalid value the original compression is unchanged.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-26 10:11:47 +01:00
Frediano Ziglio
1cf2b16c42 replay: Update pointer in allocated list
Avoid to free invalid pointer.

Reported-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-22 17:00:06 +01:00
Frediano Ziglio
c51203ab16 Small comment on structure checking
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-22 16:50:03 +01:00
Frediano Ziglio
a9d6b72959 Remove unused fields
These fields were added in a32e90257e
as part of the multiple client support and were never used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-22 16:47:36 +01:00
Frediano Ziglio
b74fe03f00 Capitalize option documentation
All other options are documented using initial capital case letter.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-22 09:37:18 +01:00
Frediano Ziglio
07f1e3a296 Simplify serial sending packets
serial was the future serial to send while last_sent_serial was the
last sent.
serial sent started from 1.
To make sure sequence variable is updated just before sending the
message, not every message prepared.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-22 09:14:02 +01:00
Frediano Ziglio
d06fd6a2f9 worker: Do not check surface twice
validate_surface already do the same checks.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-22 09:10:05 +01:00
Frediano Ziglio
d3357a5a88 replay: Use unsigned in formatting
Avoid negative syntax. Also could prevent some memory problem is number
get too big.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 18:04:02 +01:00
Frediano Ziglio
e211f5dbe1 replay: Use proper formatting for scanf family
Currently on Linux PRIu64 and SCNu64 are the same but just to make
sure in the future use the correct macros.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 18:03:05 +01:00
Frediano Ziglio
a931713902 replay: Propagate error correctly in replay_fread
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 18:00:09 +01:00
Frediano Ziglio
0e5464f152 replay: Move error check
Do the check after replay_fscanf to make sure everything
is fine before calling red_replay_compat_drawable or
red_replay_native_drawable.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 17:57:59 +01:00
Frediano Ziglio
6c5ea7311a replay: Detect errors from red_replay_data_chunks
Change the return to ssize_t to be able to distinguish from
empty buffer to error.
Check result returned and avoid continuing potentially
deferencing NULL pointers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 17:57:57 +01:00
Frediano Ziglio
1c8a01e58d replay: Handle errors reading strings from record file
To check fscanf read all needed information a dummy "%n" is appended
to any string and the value stored there is tested. This as scanf family
could return a valid value but not entirely process the string so
adding a "%n" and checking this was processed make sure all expected
string is found.
The code to check for a specific string is now a bit more complicated
as replay_fscanf use a macro which append a constant string.
The "error" field is used to mark any error happened, so in most cases
there is no explicit check beside when this could cause a problem
(for instance results of replay_fscanf used which would result in
uninitialised variable usage).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 17:57:19 +01:00
Frediano Ziglio
98557452bc replay: Record allocations in a GList to handle errors
Allocations are kept into a GList to be able to free in case some
errors happened.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 17:56:00 +01:00
Frediano Ziglio
6d4db4f0bf Base FOREACH_DCC on GLIST_FOREACH
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:24 +01:00
Frediano Ziglio
9b5f93d1a7 Base FOREACH_CLIENT on GLIST_FOREACH
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:22 +01:00
Frediano Ziglio
3fa2f12c1f Use proper FOREACH_DCC instead of FOREACH_CLIENT
FOREACH_DCC should be more DisplayChannel related.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:20 +01:00
Frediano Ziglio
545ba23e18 RedChannel: Use more FOREACH_CLIENT macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:18 +01:00
Frediano Ziglio
eabafbd09f RedChannel: Add FOREACH_CHANNEL_CLIENT and use it to iterate
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:14 +01:00
Frediano Ziglio
f1d593b025 Introduce some macros to simplify iteration on GList
Noting that coding by hand these loop introduced some regression
I'm trying to introduce back from macros.
Before trying something harder to make possible to bind the type of
the content I'm trying some simple macro as were before.
I added the type to avoid some blindly void* casts.
Also the GListIter is introduced to avoid the possibility to exchange
easily some parameters.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:08 +01:00
Frediano Ziglio
54fa96f6eb Use spice_realloc instead of manually code it
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:34:53 +01:00
Frediano Ziglio
30184bb7fb Remove only set serial field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:32:08 +01:00
Frediano Ziglio
9481af181d Simplify send_free_list
The check for free_list->wait.header.wait_count was always true.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2016-09-20 13:10:52 +01:00
Frediano Ziglio
eebc89b85b Revert if to make code more readable
Keep all code to send SPICE_MSG_LIST together.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2016-09-20 13:10:39 +01:00
Jonathon Jongsma
8f9fd3a826 Use and introduce channel client cast macros
In anticipation of porting to GObject, use casting macros (e.g.
MAIN_CHANNEL_CLIENT()) to cast RedChannelClient types. This will help
reduce the changeset slightly porting to GObject and thus make it easier
to review those upcoming changes.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-20 09:14:17 +01:00
Jonathon Jongsma
21c6da814a Change RedCharDevicePrivate::clients to GList
More Ring cleanup. At the moment, we only support a single client, so
this is only a one-element list
2016-09-19 07:47:05 -05:00
Jonathon Jongsma
8340688c9d Change RedCharDevice::write_queue to GQueue
Change a couple more Rings to GQueue
2016-09-19 07:47:05 -05:00
Jonathon Jongsma
039d3150ab Change Drawable->pipes from Ring to GList
This improves the readability of the code and keeps things
encapsulated better.
2016-09-19 07:47:05 -05:00
Jonathon Jongsma
a78a7d2510 RedChannelClient: store pipe items in a GQueue
Instead of using a Ring (and having a ring item link in every pipe
item), store them in a GQueue. This also necesitated changing
RedCharDeviceVDIPort->priv->read_bufs to a GList as well.

Also Optimise client pipe by passing pipe position instead of data.
This avoids having the search the data scanning all the queue changing
the order of these operations from O(n) to O(1).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-19 07:47:05 -05:00
Jonathon Jongsma
46c83dfe1f Rename display_channel_set_monitors_config_to_primary()
Since this function is a DisplayChannel method, use a name consistent
with naming conventions.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 13:40:09 -05:00
Jonathon Jongsma
5e74387d25 Add DisplayChannelPrivate struct
Move all of the DisplayChannel data memembers into a private struct to
encapsulate things better. This necessitated a few new 'public' methods
and a small bit of refactoring to avoid poking into DisplayChannel
internals from too many places. The DisplayChannel and the
DisplayChannelClient are still far too intertwined to completely avoid
accessing private data, so at the moment the private struct is defined
in display-channel.h and the DisplayChannelClient implementation
still accesses it sometimes.
2016-09-16 13:40:09 -05:00
Jonathon Jongsma
fede3f38c5 Improve encapsulation of DisplayChannel
Add a couple new functions to the header so that they can be called by
other objects rather than poking into the internals of the struct.
2016-09-16 13:40:09 -05:00
Pavel Grunt
83ff645d54 reds: Simplify vdi_port_read_buf_process
Reuse and handle the return value from agent_msg_filter_process_data

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-16 12:21:06 +01:00
Frediano Ziglio
b0528f334a replay: Rename eof to error
The eof variable and enumeration will be used for all errors
so avoid confusion.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 12:06:19 +01:00
Frediano Ziglio
bd8ccfcd78 replay: Assure read_binary receives a NULL pointer
read_binary do not allocate a buffer for no-NULL pointers.
Avoid using uninitialized data and allocate proper buffer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 12:00:27 +01:00
Pavel Grunt
cd80b9fc78 agent-filter: Use enum as return value
Explicitely discard AGENT_MSG_FILTER_MONITORS_CONFIG messages
from the agent.

Also remove unused AGENT_MSG_FILTER_END

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-16 11:54:56 +01:00
Frediano Ziglio
80b1e816c6 Remove unused drawable parameter
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 09:29:19 +01:00
Frediano Ziglio
57dfbebaa9 Reduce indentation
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 09:17:10 +01:00
Frediano Ziglio
5ccad56915 Simplify some boolean arithmetic
Pass boolean directly.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 09:14:24 +01:00
Jonathon Jongsma
b6cbb26e25 Replace a couple Rings with GList
Make RedsState::mig_target_clients into a GList to improve encapsulation
and maintainability. Also RedsMigTargetClient::pending_links. With
GList, a type implementation can be ignorant of whether they're
contained within a list or not.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-16 08:49:59 +01:00
Jonathon Jongsma
b08f132102 Make glz_dictionary_list a GList
Removing more intrusive RingItems from various structures and improving
readibility.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-15 16:06:34 +01:00
Jonathon Jongsma
867bee66a7 Add CursorChannelPrivate struct
Encapsulate private data of CursorChannel in a private struct. This
isn't very useful at the moment, but it will help prepare the way for
porting the RedChannel heirarchy to GObject.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-15 15:34:31 +01:00
Uri Lublin
4cb02250f4 dcc_compress_image: fix a possible overflow when calculating image_size
Both src->stride and src->y are uint32_t
Fixed by making one of them uint64_t

Found by coverity

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-15 15:16:27 +01:00
Uri Lublin
37e4cae9d4 dcc_gl_draw_item_new: allocate item when needed
Prevents a leak on early return.

Found by coverity.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-15 15:16:25 +01:00
Uri Lublin
dc6c57668a dcc_gl_scanout_item_new: allocate item when needed
Prevents a leak on early return.

Found by coverity.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-15 15:16:23 +01:00
Uri Lublin
42066f03ec dcc: do not check the pointer returned by spice_new
The rest of the code assumes spice_new does not return NULL

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-15 15:16:00 +01:00
Pavel Grunt
5d6e3ff1e9 agent-filter: Constantify parameter
Filter should not modify data

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-12 13:22:11 +01:00
Frediano Ziglio
0f6ccd8af5 Remove global key_modifiers_timer variable
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-12 13:18:40 +01:00
Frediano Ziglio
9432b01663 Remove unused structure declaration
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-12 13:04:38 +01:00