Commit Graph

1690 Commits

Author SHA1 Message Date
Frediano Ziglio
5c1d744d85 Store 'renderers' as GArray in RedsState
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 19:12:53 +00:00
Jonathon Jongsma
127e3ad191 Add RedsState arg to activate_modifiers_watch()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 13:57:44 +00:00
Jonathon Jongsma
a8dc9b0936 Add RedsState arg to spicevmc_device_connect|disconnect()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 13:57:41 +00:00
Jonathon Jongsma
d576c76a70 Add RedsState arg to red_on_main_agent_tokens()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 13:57:39 +00:00
Jonathon Jongsma
ec7d59c902 Store a reference to RedsState in RedsMigTargetClient
This allows RedsMigTargetClient methods to use local variables rather
than the global 'reds' variable

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 13:57:37 +00:00
Jonathon Jongsma
cca32779f5 spice_server_kbd_leds: don't use global 'reds'
Store a reference to the RedsState server in the keyboard state struct

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 13:57:35 +00:00
Jonathon Jongsma
2dfcf9c6e3 Add reference to server in RedClient
Allows client methods to not use global 'reds' variable

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 13:57:34 +00:00
Jonathon Jongsma
451ac31a7a Remove use of global 'reds' from VDIReadBuf functions
Add a new 'state' property to VDIReadBuf so that we can refer back to
the VDIPortState struct from the readbuf functions.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 13:57:32 +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
82fe27d753 Add RedsState member to RedLinkInfo
This allows us to use local 'reds' variables in all of the various async
callbacks rather than using the global 'reds' variable.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 13:57:15 +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
Christophe Fergeau
35d1fbff1d reds: Pass RedState instance to reds_accept()
Rather than relying on a global 'reds' variable, we can pass the needed
instance through the callback user data.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-10 17:30:03 +00:00
Christophe Fergeau
3fa733a800 reds: Make sure accept_ssl_connection() gets a reds instance
Commit 3a66b75 changed reds_accept_ssl_connection() to expect a RedState
instance when its called, but the core->watch_add() which is calling it
was not changed accordingly. This causes a crash when connecting through
SSL.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-10 17:29:48 +00:00
Marc-André Lureau
8777864311 Handle GL_DRAW_DONE
When a client is done with drawing and sends
SPICE_MSGC_DISPLAY_GL_DRAW_DONE, or when it ends, update the number of
async counts.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
[reduce critical message to a warning; do not reset gl_draw_ongoing
 - Frediano Ziglio]
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-09 14:01:30 +00:00
Marc-André Lureau
381dc93ec0 Handle GL_DRAW messages
Create an async, and marshall the GL_DRAW message. Count number of
clients, and wait until gl_draw_async_count is 0 to complete the async.
The count is going to be updated in the following patch when the client
is done with the draw.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
[removed unused sent field; move gl_draw_async_count to DisplayChannel
 - Frediano Ziglio]
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-09 14:01:25 +00:00
Marc-André Lureau
5881b40ebd Send current GL scanout to new client
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2016-02-09 14:01:20 +00:00
Marc-André Lureau
7a06efde1c Handle GL_SCANOUT messages
Go through dispatcher and marshall scanout message. Since the marshaller
and the QXL state are manipulated from different threads, add a mutex to
protect the current scanout.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2016-02-09 14:01:17 +00:00
Marc-André Lureau
ebf461b8e6 Add new spice-gl stubs API
- spice_qxl_gl_scanout() to take the current scanout

- spice_qxl_gl_draw_async() to draw the scanout, is like other Spice async
  functions, it takes a cookie and will return in the
  QXLInterface.async_complete()

Two new fields are also added to QXLState, in order to save the current
scanout, and the pending async.

A scanout can't be updated if there are pending draw atm. Discarding
outdated draws is left as a future improvement to allow updating the
scanout without waiting for draw async to be done.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
[make QXL function names more coherent - Frediano Ziglio]
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-09 14:01:12 +00:00
Marc-André Lureau
9766619dff red-channel: return number of created pipe items
This is useful in the following patches to count the number of replies
to wait for.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2016-02-09 14:01:08 +00:00
Jonathon Jongsma
b0b64bea59 Add RedsState arg to reds_handle_channel_event()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-09 11:10:00 +00:00
Jonathon Jongsma
3a66b755bd Add RedsState arg to reds_init_client_[ssl_]connection()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-09 10:56:47 +00:00
Jonathon Jongsma
c141dcb850 Rename vdi_port_read_buf_get() to match convention
Since this is technically a RedsState method, name it as such.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-09 10:46:32 +00:00
Frediano Ziglio
1cf96a58ec record: save real time during recording
Instead of using CPU time use a timer depending on real times.
Currently that time in the record log is not used.
However if we want to reproduce problems with stream would be useful
to have real times instead.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-05 15:48:35 +00:00
Frediano Ziglio
8fc8b69bff channel: fix typo in comment
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-02-05 15:47:22 +00:00
Jonathon Jongsma
1884b3ac99 Move ssl_parameters to RedsState struct
Removing more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-04 09:19:25 +00:00
Jonathon Jongsma
4b228d5c1f Move agent_mouse to RedsState struct
Required adding a RedsState arg to reds_get_agent_mouse()

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-04 08:55:43 +00:00
Jonathon Jongsma
e7e42f4126 Move streaming_video to RedsState struct
Also requires adding reds_get_streaming_video() accessor so that other
files can check this value.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-04 08:55:43 +00:00
Marc-Andre Lureau
df7ba60503 tests: link test-qxl-parsing with libserver
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-03 17:33:15 +00:00
Frediano Ziglio
56182be522 worker: don't do too much polling
Now that processing is correctly restored there is no need to keep
polling to avoid main loop hangs. Reduce the polling count to 1
(just try once).
This reduce cpu usage if guests are mainly idle.
If you consider 100 guests waiting to login with cursor blinking
and considering the polling was done 200 times every 10ms (maximum)
just the cursor blinking was causing 10100 loop iterations per second
while now only 200 are needed (considering cursor blinking every
second).

Signed-by: Frediano Ziglio <figlio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-03 16:03:54 +00:00
Frediano Ziglio
916e48e331 worker: avoid blocking loop
Make sure we process commands after we can send data to client.
If during processing we detected that there was too much data in the
clients queues the processing of commands just stop till the next
iteration.
However if all data are pushed in a single iteration of the loop
and commands were already processed there was the (remote) possibility
that the loop hangs till a separate event (like a screen resize on
client window) arrive.
I manage to reproduce and after half an hour no events arrived.
This patch detect that processing was stuck and now we can process new
commands and force a new iteration.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-03 16:03:54 +00:00
Frediano Ziglio
77adbb7574 replay: remove a message that could be caused by a race condition
The req_cmd_notification callback is called by spice-server when it
has processed all commands and wants to be notified (by a wakeup) that
new commands have been appended to the command queue.
Replay utility tries to fill the commands when it detects that
spice-server is trying to read commands but there are no more commands.
However, new commands are appended in a separate thread so if the main
red worker loop on spice-server is really tight this request can
happen.
Avoid printing any message on this condition, message will be appended
and loop woken up when replay code can do it.

Signed-by: Frediano Ziglio <figlio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-03 16:03:17 +00:00
Frediano Ziglio
5c460de1a3 worker: push data when clients can receive them
During every iteration of the main worker loop, outgoing data was pushed to
the client. However, there was no guarantee that the loop would be woken up
in every situation. So there were some conditions where the loop would stop
iterating until a new event was sent.

Currently, the events that can wake up the main worker loop include:
 - data from dispatcher (including wakeups from the guest)
 - data from clients
 - timeouts on a stream
 - other timeouts
 - polling

This patch adds a new wakeup event: when we have items that are queued to
be sent to a client, we set up a watch event for writing data to the
client. If no items are waiting to be sent, this watch will be disabled.
This allows us to remove the explicit push from the main worker loop.

This has some advantages:
 - it could lower latency as we don't have to wait for a polling timeout.
   From my experiments using a tight loop (so not really the ideal
   condition to see the improvements) the total time was reduced by 2-3%)
 - helps reduce the possibility of hanging loops
 - avoids having to scan all clients to detect which one can accept data.

Signed-by: Frediano Ziglio <figlio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-03 16:02:37 +00:00
Jonathon Jongsma
5a8ccd1ac7 Move zlib_glz_state to RedsState struct
Also required adding reds_get_zlib_glz_state() for external access.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-03 15:14:46 +00:00
Jonathon Jongsma
ffd2cda51e Move exit_on_disconnect to RedsState struct
Removing more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-03 15:05:48 +00:00
Jonathon Jongsma
9c512617cb Move agent_file_xfer to RedsState struct
Removing more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-03 15:03:21 +00:00
Jonathon Jongsma
fe4db36783 Move agent_copypaste to RedsState struct
Removing more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-03 15:01:39 +00:00
Frediano Ziglio
7a11b96095 compatibility patch for event loop
This patch use old code to implement timer events.
The new version use some function from GLib 2.34 however some systems
(like RHEL 6) have former GLib version (RHEL 6 has GLib 2.28 installed)

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-02-03 13:27:16 +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
41adaa15ba Move ticketing_enabled to RedsState struct
Removing more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-03 08:33:42 +00:00
Jonathon Jongsma
da6618681c Move jpeg_state to RedsState struct
Also required adding reds_get_jpeg_state() for external access.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-02 15:58:47 +00:00
Jonathon Jongsma
f23c03e37b Move image_compression to RedsState struct
Removing more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-02 15:45:10 +00:00
Jonathon Jongsma
70a5cc9b09 Make default_security and channels_security non-global
Move them into the RedsState struct, adjust functions that use these
variables to take a RedsState arg.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-02 15:18:30 +00:00
Frediano Ziglio
8b14dc113c red-channel: send marshaller message fd
Send the fd associated to the last message sent.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-02 12:52:10 +00:00
Marc-Andre Lureau
15c908ef25 tests: make sure that the default rule builds all tests
The default rule being "all", it builds noinst_PROGRAMS but not
check_PROGRAMS. Let's build all the tests by default.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-02 11:36:10 +00:00
Victor Toso
0f4dd2730b reds: remove unused structs
RedsMigSpiceMessage and RedsMigCertPubKeyInfo

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-01 15:42:34 +00:00
Frediano Ziglio
3cc00f1207 reds: constify renderers_info array
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-02-01 15:24:32 +00:00
Frediano Ziglio
e940ba1fe7 reds: remove default_renderer as field
Was used to just assure there was at least one renderer in the list.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-01 15:24:13 +00:00
Jonathon Jongsma
c5ec8760f8 Move spice_uuid, spice_uuid_is_set to RedsState struct
Removing more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-01 15:20:54 +00:00
Jonathon Jongsma
a826bcad4e Move spice_name to RedsState struct
Remove more global variables

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-01 15:20:54 +00:00
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