Commit Graph

25 Commits

Author SHA1 Message Date
Christophe Fergeau
0c6e51011b Move RedCharDeviceCallbacks into RedCharDeviceClass
This structure holding virtual function pointers was kept until now as a
RedCharDevice member in order to make the GObject conversion easier.
Now that all RedCharDevice children are converted to GObject, it can be
moved into RedCharDeviceClass.
2016-04-07 11:42:37 -05:00
Christophe Fergeau
87b6b9273d reds: Remove red_char_device_new()
Nothing is using it anymore now that CharDevice classes are
gobjectified.
2016-04-07 11:42:24 -05:00
Christophe Fergeau
852a9824a1 char-device: Fix property name in red_char_device_new()
This method will be removed in a subsequent commit, but for now it's
causing breakage since it's setting "reds" instead of "spice-server"
2016-04-06 10:30:00 +02:00
Christophe Fergeau
96bde4bf95 char-device: Make RedCharDevice a GObject
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-02 18:06:51 +01:00
Frediano Ziglio
77946c395b Rename some missing names related to RedCharDevice
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-04-01 14:40:44 +01:00
Frediano Ziglio
742612f34d Rename SpiceCharDeviceCallbacks to RedCharDeviceCallbacks
The structure is an internal one so should not have the Spice prefix
but use the Red one.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-04-01 14:33:54 +01:00
Jonathon Jongsma
a24ebcae89 Rename RedCharDevice functions
make the function names match the type names. So
spice_char_device_state_* becomes red_char_device_* and
spice_char_device_* also becomes red_char_device_*.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-01 11:59:46 +01:00
Jonathon Jongsma
0fd5b56be7 Rename SpiceCharDeviceClientState to RedCharDeviceClient
Make it consistent with the renamed RedCharDevice and the convention of
using 'Red' namespaces for internal types

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-01 11:59:44 +01:00
Jonathon Jongsma
b693eae580 Rename SpiceCharDeviceState to RedCharDevice
This is more consistent with internal type naming convention, and it
paves the way for a new char device GObject heirarchy

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-01 11:59:43 +01:00
Jonathon Jongsma
f3028e9ada Rename SpiceCharDeviceWriteBuffer to RedCharDeviceWriteBuffer
Internal types should use 'Red' namespace for consistency

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-01 11:59:40 +01:00
Jonathon Jongsma
f02b66a225 Rename SpiceCharDeviceMsgToClient to RedCharDeviceMsgToClient
Internal types should use Red namespace for consistency

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-01 11:59:33 +01:00
Christophe Fergeau
fe3d5d542d char-device: Avoid use-after-free
Reset pointer after freeing the structure pointing to it.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-03-31 08:07:52 +01:00
Christophe Fergeau
8e614edd0f char-device: Move instance data to SpiceCharDeviceState::priv
Create a structure to hold private data.
This helps to make patch for GObject smaller.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-03-29 10:09:09 +01:00
Christophe Fergeau
5981cf2645 char-device: Add helpers for SpiceCharDeviceCallbacks vfuncs
Add helper functions wrapping calls to the virtual functions
defined in SpiceCharDeviceCallbacks.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-22 10:29:39 +00:00
Christophe Fergeau
3484b739a9 char-device: Refactor spice_char_device_client_add a bit
Factor out CharDeviceClientState creation out of
spice_char_device_client_add.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-10 10:48:11 +00:00
Christophe Fergeau
e5c89b0b60 Introduce spice_char_device_get_interface()
Hides awkward casting/dereferencing to go from a
SpiceCharDeviceInstance to a SpiceCharDeviceInterface

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-09 17:33:43 +00:00
Christophe Fergeau
55b9478b9c Make use of the new reds_core_timer_* API
This makes the code more readable.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-03 16:56:07 +00:00
Jonathon Jongsma
abcbf20d8b Add RedsState arg to smartcard_device_connect()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-12 15:10:53 +00:00
Jonathon Jongsma
b830f193a1 char-device: use local 'reds' variable
Store a reference to the server in the SpiceCharDeviceState struct and
use that rather than the global 'reds' variable

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 13:57:30 +00:00
Jonathon Jongsma
2726e04a9a Move 'core' into RedsState struct
Also add reds_get_core_interface() accessor for external use.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 11:55:30 +00:00
Jonathon Jongsma
b85c8295d6 Remove use of global 'reds' var from spice_server_remove_interface()
Since this is public API, we can't easily change the signature of the
function to take a RedsState argument, so instead we apply a hack and
store the reds argument inside the device state struct when the
interface is added, and retrieve it for use later when it is removed.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-03 08:41:37 +00:00
Jonathon Jongsma
e5d3b2bf73 Change some functions to take RedsState arg
In preparation for getting rid of the global 'reds' variable, we need to
pass the RedsState variable to all functions where it is needed. For now
the callers just pass in the global reds variable.

Functions changed:
- reds_mig_fill_wait_disconnect;
- reds_mig_cleanup_wait_disconnect;
- reds_mig_remove_wait_disconnect_client;
- reds_migrate_channels_seamless;
- reds_mig_finished;
- reds_mig_switch;
- reds_enable_mm_time;
- reds_disable_mm_time;
- attach_to_red_agent;
- reds_char_device_add_state;
- reds_char_device_remove_state;
- reds_on_char_device_state_destroy;
- spice_server_char_device_remove_interface;
- migrate_timeout.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-21 14:42:58 +00:00
Frediano Ziglio
ba175f9be1 channel: add interface parameters to SpiceCoreInterfaceInternal
This patch and previous ones want to solve the problem of not having a
context in SpiceCoreInterface. SpiceCoreInterface defines a set of
callbacks to handle events in spice-server. These callbacks allow to
handle timers, watch for file descriptors and send channel events.
All these callbacks do not accept a context (usually in C passed as a
void* parameter) so it is hard for them to differentiate the interface
specified.
Unfortunately this structure is used even internally from different
contexts for instance every RedWorker thread has a different context. To
solve this issue some workarounds are used. Currently for timers a variable
depending on the current thread is used while for watches the opaque
parameter to pass to the event callback is used as it currently points just
to RedChannelClient structure.  This however imposes some implicit
maintainance problem in the future. What happens for instance if for some
reason a timer is registered during worker initialization, run in another
thread? What if we decide to register a file descriptor callback for
something not a RedChannelClient?  Could be that the program will run
without any issue till some bytes change and weird things could happen.

The implementation of this solution is done implementing an internal "core"
interface that has context specific and use it to differentiate the
context instead of relying on some other, hard to maintain, detail. Then an
adapter structure (name inpired to the adapter pattern) will provide the
internal core interface using the external, public, definition (in the
future this technique can be used to extend the external interface without
breaking the ABI).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-11 16:40:17 +00:00
Francois Gouget
110c31439b server: Use PRI macros in printf for 32/64 bit compatibility
Some integer type definitions are different between 32 and 64 bit
systems which causes problems in printf. The PRI macros automatically
provide the printf format appropriate for the system.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-15 17:47:50 +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