Commit Graph

47 Commits

Author SHA1 Message Date
Frediano Ziglio
71284c4984 red-worker: Limit visibility
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-06-01 22:08:55 +01:00
Frediano Ziglio
1b02f2d3d0 red-worker: Associate message structure and numbers
Makes sure a message is sent with the proper message number.
Reduce mistakes associating types with wrong registered number.
Make easier to add new messages in the future.
Avoids having to type the message number every time, it's inferred
from the type.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-06-01 22:08:55 +01:00
Frediano Ziglio
21f9d25aa8 Update filenames in comments
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-05-11 08:14:47 +01:00
Frediano Ziglio
6db395dc74 Make sure empty structure are ABI compatible
Empty structure are not really portable however adding
an zero size array seems to be the way to have a zero
size structure portably.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
e0b395fb68 Declare exported functions as C
Allows to be used by both C and C++ code.
So to leave part of the code in C and part move to C++.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
20daba6bc3 red-worker: Remove unused definitions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-29 15:18:49 +00:00
Frediano Ziglio
fe52264204 Check running state in red_qxl_set_client_capabilities
No reasons to expose red_qxl_is_running, this was used to not
send capability is the state was not running.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2019-03-28 20:20:25 +00:00
Jonathon Jongsma
b0eab081be Save running property in QXLState
This is a preparatory patch that states the running property in QXLState
and provides accessor functions that allows us to check whether the QXL
device is running from different threads.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-28 20:20:25 +00:00
Frediano Ziglio
571dc645c5 Move thread/dispatching handling to RedChannel
Currently channel threading/handling is spread between RedQxl,
RedWorker and RedChannel.
Move more to RedChannel simplify RedQxl and RedWorker.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2019-03-28 20:20:25 +00:00
Frediano Ziglio
08659f91b4 red-worker: Remove obsolete type definition
AsyncCommand was removed in eb6c8ba025.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-01-23 21:22:37 +00:00
Frediano Ziglio
9872e7b8e5 Reduce dependencies from red-qxl.h
This header is mainly exporting functions to handle public
interface for the QXL devices.
Avoid spreading its inclusion including this header in other
headers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-12-01 22:19:31 +00:00
Jonathon Jongsma
a5aa2a2261 Use standard "Red" namespace
The objects RedsStream and RedsSASL are currently using the namespace
"Reds" rather than the standard "Red" namespace used throughout the rest
of the project. Change these to be consistent. This also means changing
method names and some related enumeration types.

The files were also renamed to reflect the change:
  reds-stream.[ch] -> red-stream.[ch]

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-21 08:47:02 +01:00
Frediano Ziglio
b83eb77c30 red-qxl: Remove surface_create field
This field was used just to store a value and retrieve again
while we can just pass it instead.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-17 21:56:20 +01:00
Frediano Ziglio
eb6c8ba025 red-qxl: Remove AsyncCommand
This structure was used to store the cookie for the async
reply and the message for the generic async callback.
Most async messages do not require extra action beside sending back the
cookie for the reply so instead of having a switch on the message type
in red_qxl_async_complete, this commit moves the message-specific
behaviour to the callers, which allows us to store the cookie directly
in RedWorkerMessageAsync rather than needing an intermediate
AsyncCommand structure.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-18 17:49:25 +01:00
Frediano Ziglio
b3d239012a red-qxl: Remove unused includes
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-08 16:51:27 +01:00
Frediano Ziglio
3d5859043b red-qxl: Move private declarations to red-worker.h
RedQxl and RedWorker are quite bound together running
CursorChannel and DisplayChannel in a separate thread
marshalling (RedQxl) and unmarshalling and executing
(RedWorker) requests.
Make the communication between them private trying
to facilitate maintaining these two files.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-08 16:51:25 +01:00
Christophe Fergeau
bc5326b1ce Unify header guards
This changes the header guards in all .h files to follow this format:

/*
 * Licensing block
 */

/* ... */

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-30 18:17:20 +01:00
Frediano Ziglio
87f562d843 Add red_qxl_destroy function
Allows to destroy a QXL object

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 15:53:39 +00:00
Jonathon Jongsma
96e94c6f32 Convert RedChannel hierarchy to GObject
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-10-25 11:32:13 -05:00
Frediano Ziglio
afd4d44807 red-worker: Do not include not necessary red-channel-client.h
Definitions are all in red-channel.h

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-10-20 17:19:39 +01:00
Jonathon Jongsma
bcb8503659 Move CommonGraphicsChannel to a new file
Move out of red-worker.c. This requires a little bit of minor
refactoring to avoid accessing some RedWorker internals in the
constructor function, etc.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-14 11:49:12 +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
Jonathon Jongsma
bed132d6e2 Move RedChannelClient to separate file
Reduce direct access to RedChannelClient, and get ready to convert to
GObject.

Acked-by: Frediano Ziglio <fziglio@redhat.com
2016-09-08 09:37:59 +01:00
Frediano Ziglio
76cecd66fb remove CommonGraphicsChannelClient structure
Was just containing a RedChannelClient field

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-08-09 10:22:46 -05:00
Frediano Ziglio
cbc86e7a1f move is_low_bandwidth to DisplayChannelClient
The field is only used by DisplayChannelClient, not by CursorChannelClient

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-08-09 10:22:46 -05:00
Frediano Ziglio
5d61659bba remove common_graphics_channel_new_client function
The function was just calling another function with same parameters

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-08-09 10:22:46 -05:00
Frediano Ziglio
eef8d0d8a3 move during_target_migrate out of common_graphics_channel_new_client
This reduces the number of arguments that need to be passed to the
function, and also avoids changing a different object within a function
that is supposed to just create a new object

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-08-09 10:22:46 -05:00
Jonathon Jongsma
4028fb1c79 Replace RedChannel::clients with GList
Instead of using a Ring, use a GList to store the list of channel
clients. This allows us to iterate the clients without poking inside of
the client struct to get the channel_link. This is required in order to
make the RedChannelClient struct private.
2016-05-24 14:56:45 -05:00
Jonathon Jongsma
920e117c24 Rename all RedPipeItem subclasses
Use 'Red' prefix to match internal type naming convention

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 10:22:26 -05:00
Jonathon Jongsma
b9720d80e0 Rename PipeItem to RedPipeItem
Following internal type naming conventions

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 10:22:01 -05:00
Frediano Ziglio
4c5c9f6b69 dispatcher: move channel final initialization to red-worker
CursorChannel and DisplayChannel was initialized half in red_worker_new
and half in red_dispatcher_init using some accessor for RedWorker
(red_worker_get_cursor_channel and red_worker_get_display_channel).
Moving directly into red_worker_new make easier to follow code path.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-03-29 09:26:23 +01:00
Christophe Fergeau
a653044011 Rename red_channel_pipe_item_init to pipe_item_init
The RedChannel argument is not used by pipe_item_init. Removing it
will make code simpler in places where we don't have a RedChannel
directly available.
This is acting on a PipeItem object so correct name is pipe_item_init.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-03-10 11:36:52 +00:00
Frediano Ziglio
95fa8bfb13 worker: remove useless qxl_state
qxl_state can be extracted easily from qxl.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-03-04 15:47:50 +00:00
Frediano Ziglio
e9ed125dbd use QXLState instead of RedDispatcher
Considering that:
- QXLState is the state of QXLInstance implementation;
- RedDispatcher is the implementation of QXL;
- qif (QXLInterface*) field can be computed really easy from QXLInstance;
- most of its state is private.
Make all structure private and use QXLState instead of RedDispatcher.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-03-04 15:47:45 +00:00
Frediano Ziglio
5916dd8fa6 rename red-dispatcher.* files to red-qxl.*
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-03-04 15:27:41 +00:00
Jonathon Jongsma
3644783e24 CommonChannel -> CommonGraphicsChannel
Rename this struct to make it clear that it's only the base class for
graphics channels (e.g. display and cursor), not all channels.

Also renamed CommonChannelClient to CommonGraphicsChannelClient.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-17 12:58:40 +00:00
Frediano Ziglio
c111bfa8c3 worker: removed unused red_worker_get_qxl function
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-16 13:09:33 +00:00
Frediano Ziglio
0ebd3b0d04 dcc: move id from CommonChannelClient to DisplayChannelClient
Was not used by CursorChannelClient but only by DisplayChannelClient.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-16 13:07:08 +00:00
Christophe Fergeau
e213f09c38 Simplify red_drawable_unref()
Now it no longer needs external state in order to destroy the
RedDrawable instance when needed, so we can remove this from the
prototype.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:08 +00:00
Frediano Ziglio
fbdea0fa79 CommonChannel: hold a reference to QXLInstance instead of RedWorker
CommonChannel does not need to know about RedWorker.
This reduce a bit dependencies between objects.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-11 23:51:46 +00:00
Frediano Ziglio
79e50495fe ccc: remove unused field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-11 23:51:46 +00:00
Frediano Ziglio
1df9510581 worker: remove unused red_worker_get_memslot function
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-11 23:51:46 +00:00
Frediano Ziglio
26c7e33de3 stats: use CLOCK_THREAD_CPUTIME_ID for cpu statistics
Use CLOCK_THREAD_CPUTIME_ID instead of getting the clock
with pthread_getcpuclockid.
This avoids to call red_worker_get_clockid. This function returns
uninitialized value at the time DisplayChannel is built resulting in setting
statistics to CLOCK_REALTIME (which is 0) instead to cpu time as expected.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-11 16:29:08 +00:00
Francois Gouget
5c9fb9a0f3 server: Add time constants to go with spice_get_monotonic_time_ns()
They clarify the time unit being used, reduce the need for casts and
simplify calculations.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-12-14 11:24:34 +00:00
Francois Gouget
cbc4e07682 server: Rename DISPLAY_CLIENT_TIMEOUT and de-duplicate it
Given that it is used for both cursor and display, COMMON_CLIENT_TIMEOUT
seems more appropriate. Also define it only in red-worker.h.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-14 10:53:40 +00:00
Frediano Ziglio
febaed3529 server: misc header cleanups
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-09 22:17:51 +00:00
Frediano Ziglio
525cd67be7 server: rename files
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-03 23:54:32 +00:00