Commit Graph

1641 Commits

Author SHA1 Message Date
Jonathon Jongsma
fdcd8980ce Move sasl_enabled, sasl_appname to RedsState struct
Removing more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-01 15:09:39 +00:00
Jonathon Jongsma
47c42d4f75 Move taTicket to RedsState struct
Removing more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-01 15:09:39 +00:00
Jonathon Jongsma
1333e0ee8c Move spice_family to RedsState struct
Removing more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-01 15:09:39 +00:00
Jonathon Jongsma
5aad27b25c Move spice_addr to RedsState struct
Removing more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-01 14:46:24 +00:00
Jonathon Jongsma
905bfc8dbb Move migration_interface to RedsState struct
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-01 14:46:24 +00:00
Jonathon Jongsma
deb6afc325 Move vdagent to RedsState struct
Also change API of reds_has_vdagent() to take RedsState arg.  Removes
another global variable.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-01 14:05:36 +00:00
Jonathon Jongsma
6806bb6d46 Move spice_listen_socket_fd to RedsState struct
Removing more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-01 13:57:56 +00:00
Jonathon Jongsma
d4d6747937 Move spice_secure_port to RedsState struct
removing more global variables

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-29 10:38:51 +00:00
Jonathon Jongsma
40f1e9429b Move spice_port to RedsState struct
Remove another global variable

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-29 10:36:52 +00:00
Jonathon Jongsma
8c8888e009 Change init_vd_agent_resources() to take RedsState arg
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-29 10:33:39 +00:00
Frediano Ziglio
3894b066c4 worker: unify flush_cursor_commands and flush_display_commands
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-29 00:20:10 +00:00
Frediano Ziglio
1020736efd worker: use glib main loop
Use the glib mainloop instead of writing our own. The glib loop is both
cleaner to use and is more extensible. It is also very mature and
reduces the maintenance burden on the spice server.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-28 16:16:50 +00:00
Jonathon Jongsma
b8066339bf Move default_renderer into RedsState
Not global.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-28 15:59:11 +00:00
Jonathon Jongsma
43a857f2ef main_channel_init() -> main_channel_new()
Rename to make function name more consistent

Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-28 15:34:53 +00:00
Jonathon Jongsma
3881abc081 inputs_init() -> inputs_channel_new()
Rename function to be more consistent

Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-28 15:34:53 +00:00
Jonathon Jongsma
ab55619492 Remove global inputs channel
Make the RedsState object own an InputsChannel object rather than
having a global inputs channel. This means changing a lot of
inputs-related API to take an InputsChannel* argument and moving the
keyboard, mouse, and tablet objects into the InputsChannel object.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-28 15:34:52 +00:00
Frediano Ziglio
a61ab509b2 worker: remove useless check
display_channel is never NULL.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
2016-01-28 08:15:50 +00:00
Frediano Ziglio
17684522e1 worker: remove useless test
red_channel_max_pipe_size returns 0 if no client (channel disconnected)
no need to check if cursor_channel/display_channel are NULL or
connected.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
2016-01-28 08:15:38 +00:00
Frediano Ziglio
871dbe5417 worker: do not leak cursor after disconnecting clients
Calling cursor_channel_disconnect does not free cursor_display
so this causes a leak.
Is the only code where this pointer is reset preventing any
further cursor channel connection. If a client is lazy reading
cursor data during the flush connection is closed and further clients
won't be able to use the cursor.
This also prevents future use of a NULL pointer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
2016-01-28 08:15:04 +00:00
Frediano Ziglio
8191265f78 qxl: inline documentation for get_command and req_cmd_notification
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-27 11:06:56 -06:00
Frediano Ziglio
28e33ccdf0 worker: improved implementation of SpiceTimer
Use a custom GSource.
This to avoid having to allocate a timer all the time we add one.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-26 13:13:57 +00:00
Frediano Ziglio
1ad571f576 replay: do not wake up loop too much
Send wakeups only when a command is available.
This emulate better what a guest driver should do (append the command
to the ring and then signal).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-26 12:46:32 +00:00
Frediano Ziglio
a68d9a3100 worker: use core interface to create watch
This increase code reuse and make Glib integration more straight forward.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-26 12:46:04 +00:00
Frediano Ziglio
2a6adfcd1e worker: remove empty statement at line end
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-26 10:43:18 +00:00
Frediano Ziglio
4084b2b246 worker: use variable already set at beginning of loops
This is mainly question of style.
Instead of repeating same conversion use the variable we set at the
beginning of the function.
Note also that I used same name to make the two functions more
similar.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-26 10:31:18 +00:00
Frediano Ziglio
b2f5ef0f3c worker: remove max_pipe_size constant parameter
All checks for full channel pipes have to be consistents
so there is no point in passing as a parameter.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-26 10:21:01 +00:00
Marc-Andre Lureau
3d9ea0bb6b channel: do not call pipe_add with null items
If the creator was not able to produce the item, no need to call
pipe_add().

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat>
2016-01-22 13:22:33 +00:00
Marc-Andre Lureau
e5fa7f4740 channel: document pipes_create_batch() function
Rename callback to pipe_add, and document the arguments.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat>
2016-01-22 13:22:33 +00:00
Jonathon Jongsma
77ae19c0c6 Replay: report error if we don't read the correct file header
The replay file should start with a header such as
  SPICE_REPLAY 1

Instead of soldiering on if we don't encounter this header, print a
warning and return NULL.  Also exit with a failure if spice_replay_new()
returns a NULL object in main.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-22 11:03:30 +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
Christophe Fergeau
6e407a81df event-loop: Remove template
Since SpiceCoreInterfaceInternal is a private data structure, we can
extend it as we see fit without breaking ABI. In particular, adding a
GMainContext member to it allows us to remove the need for
the event loop template which is currently included in the
basic_event_loop.c test file.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-21 14:19:24 +00:00
Christophe Fergeau
4b923347b7 test-loop: Improve basic_event_loop base_{timer, watch}_add
They call the functions provided by event_loop_core, but with a NULL
SpiceCoreInterfaceInternal parameter. It makes more sense to pass
event_loop_core rather than NULL.
This will allow to pass the GMainContext to be used through
SpiceCoreInterfaceInternal rather than through a template parameter.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-21 14:19:12 +00:00
Pavel Grunt
0bfad8a37f dcc: make dcc_compress_image_*() private
Reviewed-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-20 16:05:02 +00:00
Pavel Grunt
a310ac8860 dcc-send: Use dcc_compress_image to compress image
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-20 16:04:59 +00:00
Pavel Grunt
faa907e3c6 dcc_compress_image: Handle NULL drawable
It will be used in the following commit.
The GLZ compression cannot be used when the drawable is NULL.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-20 16:04:55 +00:00
Jonathon Jongsma
2a39131d5b 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_link_mig_target_channels;
- reds_on_migrate_dst_set_seamless;
- reds_on_client_seamless_migrate_complete;
- reds_on_client_semi_seamless_migrate_complete;
- reds_handle_other_links;
- reds_handle_link;
- reds_send_mm_time;
- reds_set_client_mm_time_latency;
- reds_init_net;
- do_spice_init;
- reds_init_ssl;
- on_activating_ticketing;
- reds_mig_release to take RedsState arg
- reds_mig_started.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-20 15:26:25 +00:00
Jonathon Jongsma
b8be8a7886 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_on_main_migrate_connected;
- reds_on_main_mouse_mode_request;
- reds_on_main_channel_migrate;
- reds_marshall_migrate_data;
- reds_agent_state_restore;
- reds_handle_migrate_data;
- reds_send_link_ack;
- reds_mig_target_client_add;
- reds_mig_target_client_find;
- reds_mig_target_client_free;
- reds_mig_target_client_disconnect_all;
- reds_find_client;
- reds_get_client;
- reds_handle_main_link;
- reds_set_client_mouse_allowed.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-20 13:11:49 +00:00
Frediano Ziglio
ddaa46d70f channel: do not free rcc->stream in red_channel_client_disconnect
This fixes a crash if red_channel_client disconnect is called
handling a message.
This can happen for instance while handling SPICE_MSGC_ACK which calls
red_channel_client_push which tries to detect write errors while writing
to a socket (for instance socket disconnection).
Messages are read in a loop and red_channel_client_disconnect would
cause rcc->stream to be NULL which will result in a use-after-free
problem (stream in red_peer_handle_incoming will use cached stream value).

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>
2016-01-20 00:27:55 +00:00
Frediano Ziglio
a5a0d4a290 tests: test removed triggered timers are not called
This could happen for instance if a given timer remove all clients
which have associated timers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-19 23:57:01 +00:00
Frediano Ziglio
323dc46794 tests: add a test for event loop
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-19 23:56:59 +00:00
Frediano Ziglio
f3a7befafe tests: extract code for event loop
This code will be reused for main loop

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-19 23:56:33 +00:00
Frediano Ziglio
3686132923 tests: do not use default loop context
Make sure we don't handle event reserved to other loop contexts.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-19 23:56:28 +00:00
Christophe Fergeau
4b8607c40c Remove use of spice_warn_if()
spice_warn_if_fail() is doing the same thing except for the inverted
condition. spice_warn_if() is being removed from spice-common to avoid
having potentially confusing redundancy.
2016-01-19 17:15:49 +01:00
Jonathon Jongsma
30f873d033 reds_num_of_clients() -> reds_get_n_clients()
More consistent with glib naming conventions. Also make the function
static since it's not used outside of this source file.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-19 14:14:23 +00:00
Jonathon Jongsma
dc7ef0eaa2 reds_num_of_channels() -> reds_get_n_channels()
More consistent with glib naming conventions.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-19 14:14:23 +00:00
Jonathon Jongsma
3ead546abb 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:
- vdi_port_read_buf_process;
- vdi_port_read_buf_get;
- vdi_port_read_buf_unref;
- reds_handle_agent_mouse_event;
- reds_num_of_channels;
- reds_num_of_clients;
- reds_fill_channels;
- reds_on_main_agent_start;
- reds_get_agent_data_buffer;
- reds_release_agent_data_buffer;
- reds_client_monitors_config_cleanup;
- red_on_main_agent_data.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-19 14:11:54 +00:00
Frediano Ziglio
28c3585730 tests: remove leaks in test-qxl-parsing
This make happy address sanitizer during make check.
Otherwise memory leak detector can keep in and make tests fails.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-19 14:03:43 +00:00
Jonathon Jongsma
bb6901e7f7 Pass 'reds' as opaque data in vdi port char device
This allows us to access the RedsState variable non-globally without
changing the signature of the callback functions.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-19 09:54:12 +00:00
Jonathon Jongsma
07297dd3d0 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_register_channel;
- reds_unregister_channel;
- reds_get_mouse_mode;
- reds_set_mouse_mode;
- reds_update_mouse_mode;
- reds_agent_remove;
- reds_find_channel;
- reds_mig_cleanup;
- reds_reset_vdp;
- reds_main_channel_connected;
- reds_client_disconnect;
- reds_disconnect;
- reds_mig_disconnect.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-18 16:01:12 +00:00
Frediano Ziglio
e433a6634c replay: better documentation for -C and -S options
Document all possible values

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-01-15 15:42:19 +00:00