Commit Graph

428 Commits

Author SHA1 Message Date
Christophe Fergeau
cc47d9eba8 reds: Derive VDIPortReadBuf from PipeItem
Since PipeItem is already refcounted, this allows to remove various
layers of ref/unref helpers from reds.c, and use the generic
pipe_item_{ref, unref} instead.
2016-04-15 09:50:20 -05:00
Christophe Fergeau
7d616b3de3 char-device: Fix el6 compilation
One more duplicate typedef, once in reds.c and another time in
reds-private.h
RedsState::agent_dev is defined in reds-private.h but only used in
reds.c, so longer term this could all be moved back to reds.c
2016-04-11 09:28:46 +02:00
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
1cec1c5118 reds: Make VDIPortState a GObject
This inherits from RedCharDevice.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2016-04-06 11:54:53 -05:00
Jonathon Jongsma
eaaa8985fd Rename VDIPortState to RedCharDeviceVDIPort
Consistent with internal naming conventions, and prepares for
conversion to GObject
2016-04-06 11:45:28 -05:00
Christophe Fergeau
eb58bc9ad0 gobject: Add g_type_init() for older glibs
Older glib versions require g_type_init() to be called before using
GObject.
2016-04-05 16:49:40 +02:00
Christophe Fergeau
d5c17b50bc reds: Prepare to make VDIPortState a GObject
This inherits from RedCharDevice.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-02 18:19:50 +01:00
Christophe Fergeau
9bf65f1c58 reds: Make VDIPortState private to reds.c
VDIPortState and VDIReadBuf don't really need to be defined in a header
file as they are only used in reds.c

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-02 18:15:32 +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
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
Francois Gouget
3486ecde03 server: More clearly identify channels that support multiple clients
Rename the function to channel_supports_multiple_clients() as
channel_is_secondary() is unclear and was coded to return the opposite
of what was originally intended.
Also there are few channel types and whether they support multiple
clients is totally static so we might as well delegate the check to
the compiler.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2016-03-24 15:19:38 +01:00
Frediano Ziglio
ee4b8a1480 remove unused reds_set_mm_time
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-03-24 12:48:38 +00:00
Frediano Ziglio
44a97b6095 use constructor/destructor macros
Initialize global images at load time:
- make sure these stuff are initialized without using runtime
resources;
- make sure stuff are initialize really earlier.
Do not use atexit function but a destructor.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-03-23 16:31:02 +00:00
Jonathon Jongsma
4f6c1765c7 Remove last usage of global 'reds' variable
This should be the final piece of removing the global reds variable. We
still need a global variable to clean up during the atexit() function,
but we use a GList of servers (even though we technically don't support
multiple servers in the same process yet).

Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-23 08:21:57 +00:00
Christophe Fergeau
4bf53c23d8 Remove dependency of vdi_port_read_buf_process on RedsState
This makes it easier to move the VDIPort API to a different file, and
make it as self-contained as possible.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-21 10:34:31 +00:00
Christophe Fergeau
0df59fcfc9 agent: Sync AgentMsgFilter state upon agent connection
AgentMsgFilter needs to know whether monitors config messages need to be
filtered or not. This used to be done from within
agent_msg_filter_config() using the global RedsState, but this got more
tricky as it was removed.
A first attempt a1e62fa5ae caused crashes on qemu startup with
"qemu-system-x86_64 -spice port=5900" (without -vga qxl). A second
attempt added a RedsState* argument to agent_msg_filter_config() which
in my opinion is not really nice from a layering point of view.

This new attempt makes sure AgentMsgFilter state is correct when the
filter is set to stop discarding all data, which allows to remove direct
use of RedsState from within AgentMsgFilter.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-21 10:34:29 +00:00
Christophe Fergeau
79e02e98ab Revert "fix regression due to callback called earlier"
Passing Reds into agent-msg-filter.[ch] isn't the right thing to do from
a layering point of view.

This reverts commit a1e62fa5ae.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-21 10:34:22 +00:00
Christophe Fergeau
e45ab9cf23 Use QXLInstance instead of QXLState in red_qxl_*
This seems to make more sense this way, QXLInstance is the 'main' object
with QXLState being its private data. External users then use QXLInstance
rather than passing a pointer to the private data to red-qxl.h methods.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-17 16:26:33 +00:00
Christophe Fergeau
4c1471d0b6 Remove spice_server_set_keepalive_timeout
This public API is no longer needed as the keepalive interval does not
need to be configurable.
This API was present in the 0.13.0 release, but was never added to a
stable release, in my opinion it's still acceptable to remove it without
changing soname.
2016-03-11 18:27:51 +01:00
Christophe Fergeau
7199ce961a Always enable TCP keepalive
Always enabled, hardcoded interval
as per https://bugzilla.redhat.com/show_bug.cgi?id=1298590
2016-03-11 18:27:51 +01:00
Christophe Fergeau
91bab2ff1c Replace RedsPrivate::mig_wait_disconnect_clients with a GList
The code was introducing an intermediate RedsMigWaitDisconnectClient type to
hold linked list elements, resulting in a memory handling behaviour very
similar to a GList. Using GList directly makes the code shorter and more
readable.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-09 17:33:53 +00:00
Christophe Fergeau
30f718aae2 Replace RedsPrivate::char_devs_state with a GList
The code was introducing an intermediate SpiceCharDevStateItem type to
hold linked list elements, resulting in a memory handling behaviour very
similar to a GList. Using GList directly makes the code shorter and more
readable.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-09 17:33:49 +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
Jonathon Jongsma
c3d43fdea7 Store reference to RedsState in QXLState
Remove use of global 'reds' variable from QXLState functions.
Instead store the owning RedsState variable inside the QXLState
struct and use that when necessary.

Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-05 10:13:51 +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
Frediano Ziglio
a8ff771ee8 rename red_dispatcher_ functions to red_qxl_
RedDispatcher is basically implementing QXLInstance.
After some internal discussion we decided to use QXLState structure
and red_qxl_ as function prefix.
This is the first of 3 patches that rename functions, structure
and files.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-03-04 15:27:39 +00:00
Christophe Fergeau
79cbe5ce53 Introduce reds_core_timer_* 2016-03-03 16:47:05 +00:00
Christophe Fergeau
ebbe4779fc Introduce reds_core_watch_*
These methods wrap the RedsCoreInterface::watch_add,
RedsCoreInterface::watch_remove and RedsCoreInterface::watch_update_mask
vfuncs.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-03 16:45:36 +00:00
Frediano Ziglio
badb08a859 use G_N_ELEMENTS instead of manually compute array size
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-23 17:49:35 +00:00
Frediano Ziglio
b92588bf2c constify some global variables
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-23 17:49:26 +00:00
Frediano Ziglio
a1e62fa5ae fix regression due to callback called earlier
Patch 1f21008060 ("Remove use of global
'reds' from AgentMsgFilter") introduced a regression. This because
QXLInterface->client_monitors_config was called before returning
from spice_add_interface. Some client of spice-server expect the
spice_add_interface already returned and some state change was done
before client_monitors_config was called.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-19 09:51:25 +00:00
Frediano Ziglio
2094e8f1db reds: remove unneeded variable
Remove version_string variable.
Was never changed and used in a single place.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-17 13:55:53 +00:00
Christophe Fergeau
2db21168d8 Remove redundant argument to vdi_port_read_buf_process
The 'port' argument can be determined from VDIPortState, so no need to
pass both (through RedsState) to vdi_port_read_buf_process().

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-16 11:21:25 +00:00
Jonathon Jongsma
1f21008060 Remove use of global 'reds' from AgentMsgFilter
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 10:54:30 +00:00
Jonathon Jongsma
4ac21bc649 Remove use of global 'reds' from sound.c
Pass RedsState variable to snd_attach_(playback|record) and get a
reference to this variable when needed by various functions.

Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 10:54:30 +00:00
Jonathon Jongsma
2a18e874a2 Remove global main_dispatcher variable
Requires changing a bunch of internal API to take MainDispatcher
arguments, etc. The main dispatcher object is now owned by RedsState,
since that is the object that previously created (initialized) it.

Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 10:54:10 +00:00
Jonathon Jongsma
de2572815b Add RedsState reference to RedsStream
Allows us to remove use of global 'reds' variable from reds-stream.c.
Requires changing the RedsStream constructor to accept a RedsState arg.

Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 10:45:46 +00:00
Frediano Ziglio
aadb945570 Remove global 'dispatchers', 'num_active_workers' variables
Since these are server-level variables, move them into RedsState.
However, num_active_workers was removed because:
- each dispatcher always has 1 active worker, so we can determine the
  number of active workers by counting the dispatchers
- it was never actually set correctly. Even if there was more than one
  worker, this variable was always only set to either 0 or 1.

This change required moving a bunch of helper code into RedsState as
well, an providing some RedDispatcher interfaces to access dispatcher
information from RedsState.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 10:10:58 +00:00
Frediano Ziglio
faa5364732 move red_dispatcher_on_vm_stop and red_dispatcher_on_vm_start to RedsState
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 09:39:33 +00:00
Frediano Ziglio
577966e482 use list in RedsState for ic_change and sv_change
Instead of using list in RedDispatcher (which is going to be removed)
use the one in RedsState.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 09:39:28 +00:00
Frediano Ziglio
0435ab30d5 keep dispatcher list in RedsState
This duplicate the other list which will be removed

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 09:39:26 +00:00
Frediano Ziglio
e98ed23bc2 move calc_compression_level to reds
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 09:39:24 +00:00
Frediano Ziglio
8bdc63495a remove num_active_workers
This global variable was mainly 1.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 09:39:12 +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
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