Commit Graph

3011 Commits

Author SHA1 Message Date
Frediano Ziglio
a874ebadff Rename detach_stream to stream_detach_drawable and removed unused argument
This function deal only with Stream.
Also the name was misleading and was not clear if it detached the stream
from the DisplayChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 14:25:43 +01:00
Frediano Ziglio
ae01c6d4bc Removed only written roundtrip_stat field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 14:22:04 +01:00
Frediano Ziglio
693a6b8fd9 Removed unused stat field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 14:21:07 +01:00
Frediano Ziglio
c2f0b00fde Use enum value returning invalid value
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 13:25:50 +01:00
Frediano Ziglio
fd888a0bfd Check client is using unix sockets in dcc_gl_draw_item_new
Currently this is simply avoided by the fact that Virgl with 3d means
Unix socket. Once you enable (in Qemu) tcp sockets this message will
be added to all clients (supposing multiple clients) so potentially
will be in all queues. The same check is done for dcc_gl_scanout_item_new.
dcc_gl_scanout_item_new is called when Qemu calls spice_qxl_gl_draw_async.
Technically a client can support SPICE_DISPLAY_CAP_GL_SCANOUT but server
cannot send the DRM prime directly as this require a unix socket so
if the test for SPICE_DISPLAY_CAP_GL_SCANOUT is done here it make sense
to do the check for the socket type too.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 11:16:54 +01:00
Frediano Ziglio
46a4543d9d Reuse VD_AGENT_HAS_CAPABILITY macro for bit array
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-26 13:46:59 +01:00
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
03ff0dcef9 Make error simpler in reds_stat
There's no reason for so hard optimisations so avoid
having to maintain multiple labels.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-26 10:21: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