Commit Graph

1709 Commits

Author SHA1 Message Date
Christophe Fergeau
f8617db67a Remove DisplayChannel::red_drawable_count
It's only used in a few debug printfs. If we want these stats, we'll
have to find a better way than forcing a dependency on a high-level
class in a lower-level _unref method just to maintain the stats.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:01 +00:00
Christophe Fergeau
78b495e467 qxl: Remove unused group_id arg to fill_attr
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:28:43 +00:00
Jonathon Jongsma
41d97b037a Add RedsState arg to all stat functions
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:04:02 +00:00
Frediano Ziglio
47223da1a3 revert new event-loop code for timers
Was causing sporadic crashes.
Also cause compatibility problems with RHEL 6.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-02-12 17:44:57 +00:00
Frediano Ziglio
6e43433ec2 tests: add a new case for event loop timers
Check that cancelling a timer the timer callback is not called.

This can happen in latency code (red-channel.c).
In red_channel_client_cancel_ping_timer latency timer is cancelled and
state is set to PING_STATE_NONE however if timer was already active what
happens is that the red_channel_client_ping_timer is called and the line

  spice_assert(rcc->latency_monitor.state == PING_STATE_TIMER);

is triggered causing spice-server to abort.
This happens as GLib loop add all active sources to an array but if the
timer is deactivated before the event is dispatched the event will be
dispatched unless the source is destroyed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-02-12 17:44:47 +00:00
Jonathon Jongsma
006e44b077 MainChannel: don't use global 'reds' variable
Add RedsState arg to main_channel_new(), and use the 'reds' property
that is stored in the base RedChannel struct rather than the global
'reds' variable.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-12 15:41:47 +00:00
Jonathon Jongsma
8b24bed220 Add RedsState arg to reds_set_migration_dest_info()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-12 15:33:11 +00:00
Jonathon Jongsma
36b0735192 Add RedsState arg to inputs_channel_new()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-12 15:32:47 +00:00
Jonathon Jongsma
dc4051fb9a Store a reference to RedsState in Channel base class
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-12 15:27:03 +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
Frediano Ziglio
efe5a0c501 dcc: remove not necessary volatile specifications
These automatic variable are used just inside the function.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-12 06:17:32 +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
721528fe37 remove unused structure definition
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-11 23:51:46 +00:00
Frediano Ziglio
d56745df19 dcc: remove group_id from compression functions
The parameter was not used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-11 23:51:45 +00:00
Frediano Ziglio
448700bfb4 channel: rename misleading functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-11 23:51:42 +00:00
Frediano Ziglio
b98aa6860d worker: simplify process loops
It was not clear when req_cmd_notification was called.
This code reproduce just the old behavior but is easier to read.

Steps are:

// original

if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
    worker->display_poll_tries++;
    worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
    return n;
}
if (worker->display_poll_tries > CMD_RING_POLL_RETRIES ||
             worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
    worker->display_poll_tries++;
    return n;
}
continue;

// split if

if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
    worker->display_poll_tries++;
    worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
    return n;
}
if (worker->display_poll_tries > CMD_RING_POLL_RETRIES) {
    worker->display_poll_tries++;
    return n;
}
if (worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
    worker->display_poll_tries++;
    return n;
}
continue;

// order inside if

if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
    worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
    worker->display_poll_tries++;
    return n;
}
if (worker->display_poll_tries > CMD_RING_POLL_RETRIES) {
    worker->display_poll_tries++;
    return n;
}
if (worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
    worker->display_poll_tries++;
    return n;
}
continue;

// consider cases

if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
    worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
    worker->display_poll_tries++;
    return n;
}
if (worker->display_poll_tries > CMD_RING_POLL_RETRIES) {
    worker->display_poll_tries++;
    return n;
}
if (worker->display_poll_tries == CMD_RING_POLL_RETRIES) {
    if (worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
        worker->display_poll_tries++;
        return n;
    }
    continue;
}
// unreachable

// invert if

if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
    worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
    worker->display_poll_tries++;
    return n;
}
if (worker->display_poll_tries > CMD_RING_POLL_RETRIES) {
    worker->display_poll_tries++;
    return n;
}
if (worker->display_poll_tries == CMD_RING_POLL_RETRIES) {
    if (!worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
        continue;
    }
    worker->display_poll_tries++;
    return n;
}
// unreachable

// reuse code

if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
    worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
} else if (worker->display_poll_tries > CMD_RING_POLL_RETRIES) {
} else if (worker->display_poll_tries == CMD_RING_POLL_RETRIES) {
    if (!worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
        continue;
    }
}
worker->display_poll_tries++;
return n;

// remove empty if

if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
    worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
} else if (worker->display_poll_tries == CMD_RING_POLL_RETRIES) {
    if (!worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
        continue;
    }
}
worker->display_poll_tries++;
return n;

// collapse two conditions

if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
    worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
} else if (worker->display_poll_tries == CMD_RING_POLL_RETRIES &&
           !worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
    continue;
}
worker->display_poll_tries++;
return n;

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
2016-02-11 23:45:30 +00:00
Frediano Ziglio
fa2668319e dispatcher: remove unused async_commands ring
The only usage of this ring was to have a message when there was no
commands on the list.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-11 19:57:20 +00:00
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