Commit Graph

117 Commits

Author SHA1 Message Date
Frediano Ziglio
ed68d491fd Do not check for HAVE_CONFIG_H
This should always be defined and including config.h is a requirement.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-04-30 09:26:55 +01:00
Jonathon Jongsma
14403117b5 Make channel client callbacks virtual functions
Rather than having an API to register client callbacks for each channel
type, make them vfuncs.

Since the client callbacks are registered identically for each channel
of the same type, it doesn't make sense for to require these to be
registered separately for each object.  It's cleaner to have these be
per-class properties, so they've been converted to virtual functions.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-28 20:20:25 +00:00
Christophe Fergeau
dedc4184c9 char-device: Make send_tokens_to_client() optional
Only RedCharDeviceVDIPortClass implements this vfunc, rather than
forcing every classes deriving from RedCharDeviceClass to implement it,
red_char_device_send_tokens_to_client() can deal with it.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-02-08 17:25:46 +01:00
Lukáš Hrázký
e810b48fcd char-device: separate functions to get write buffer for client and server
Instead of having a single red_char_device_write_buffer_get function to
get both client and server buffers and decide by testing client == NULL,
have separate function for a client and for a server. The situation
should always be clear (you're either on the client or on the server
side) and you shouldn't need to parametrize that.

For the server case, add a use_token parameter instead of a separate
red_char_device_write_buffer_get_server_no_token function, as you may
want to parametrize that.

Signed-off-by: Lukáš Hrázký <lhrazky@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-11-08 08:08:28 +00:00
Christophe Fergeau
2367497909 Replace spice_printerr() use with red_channel_{debug, warning}
Depending on the context, we want to output a warning or just a debug
log.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-28 13:21:46 +01:00
Christophe Fergeau
5dbd40129a Remove unneeded spice_printerr() calls
These calls seem to have been added for debugging for a very specific
purpose. At the very least, they should have been using g_debug() rather
than spice_printerr(). This commit removes these.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-28 13:21:22 +01:00
Christophe Fergeau
47ca1f0da0 channel: Remove unused 3rd red_channel_register_client_cbs() arg
It was probably meant to be used as a "user_data" argument for the
various callbacks, but turns out not to be used.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-21 17:54:27 +01:00
Frediano Ziglio
223bfed649 Reuse SPICE_DECLARE_TYPE macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-21 08:38:44 +00:00
Christophe Fergeau
bf61342e9b channel: Introduce logging helpers
This commit adds red_channel_{debug,warning,printerr}() helpers which
will prepend the log message with "channel-name:id (%p)". It also
changes various locations which were doing this manually.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-23 20:29:31 +01:00
Jonathon Jongsma
a5aa2a2261 Use standard "Red" namespace
The objects RedsStream and RedsSASL are currently using the namespace
"Reds" rather than the standard "Red" namespace used throughout the rest
of the project. Change these to be consistent. This also means changing
method names and some related enumeration types.

The files were also renamed to reflect the change:
  reds-stream.[ch] -> red-stream.[ch]

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-21 08:47:02 +01:00
Frediano Ziglio
7a3bfedfbe red-channel: Remove red_channel_init_outgoing_messages_window
This function does not make much sense anymore.
Is called by RedVmcChannel which doesn't use RedChannelClient ACKs
so the variable changed are not used.
Moreover, at red_vmc_channel_constructed() time, there will be no
clients yet, so red_channel_init_outgoing_messages() will be a no-op.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-10-12 16:37:14 +01:00
Frediano Ziglio
dd51cef748 red-pipe-item: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-11 12:52:17 +01:00
Frediano Ziglio
81816e09e6 spicevmc: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-11 12:52:17 +01:00
Frediano Ziglio
dd871c01a8 Avoid using global variable for channel IDs
This patch allocates VMC IDs by finding the first ID not used
instead of using a global variable and incrementing the value
for each channel created.
This solves some potential issues:
- remove the global state potentially making possible
  to use multiple SpiceServer on the same process;
- don't potentially overflow the variable. This can happen if
  channels are allocated/deallocated multiple times
  (currently not done by Qemu).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-02 08:20:56 +01:00
Christophe Fergeau
5dbfbb4d78 channel: Move RedChannel::on_disconnect to RedChannelClient
This vfunc only has a RedChannelClient * argument, and most of the time,
it operates on RedChannelClient, not on RedChannel. Moreover, the only
time it's used is from RedChannelClient. This commit moves the vfunc to
RedChannelClient, which seems like a better fit for it.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-08-31 15:51:57 +02:00
Frediano Ziglio
3a5007d18f red-channel: unregister channel in red_channel_destroy
Mostly of red_channel_destroy calls were preceded by
a call to unregister the channel.
The only exception was the main channel as this channel is
always present and its initialisation is a bit different.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-23 22:19:07 +01:00
Frediano Ziglio
930a1196e3 char-device: Allows to handle port events from any char device
From spice_server_port_event API you can send port events to
any char device. Although currently this is used only for "port"
devices implemented in spicevmc.c this will allow to support
such events using different objects.

This will be used for instance for a streaming device which
will be a specific SpicePort implementation.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-23 16:11:49 +01:00
Frediano Ziglio
1b9cf935b7 spicevmc: Remove useless check
rcc is already deferenced in red_channel_client_get_client so
checking for NULL after that is uselss.

Also this call is generated from red_channel_client_disconnect
which requires the rcc pointer to be valid.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-05-03 12:35:13 +01:00
Christophe Fergeau
b8bc1fe715 Don't set RedChannelClient::monitor-latency to FALSE
This is the default value, and the property is marked as
_CONSTRUCT_ONLY, so we don't need to explicitly force the default when
instantiating a RedChannelClient.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-30 18:17:13 +01:00
Christophe Fergeau
4b1c95beee Add missing chainups to parent class
A few dispose/finalize implementations were not chaining up to their
parent classes, causing memory leaks.

This fixes leaks like the following:

==16240== Memcheck, a memory error detector
==16240== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==16240== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==16240== Command: ./test-leaks
==16240==
==16240==
==16240== HEAP SUMMARY:
==16240==     in use at exit: 245,490 bytes in 3,638 blocks
==16240==   total heap usage: 5,418 allocs, 1,780 frees, 17,676,968 bytes allocated
==16240==
==16240== 16 bytes in 1 blocks are definitely lost in loss record 203 of 771
==16240==    at 0x4C2DADE: malloc (vg_replace_malloc.c:298)
==16240==    by 0x4C2FC91: realloc (vg_replace_malloc.c:785)
==16240==    by 0x52864E: dispatcher_register_handler (dispatcher.c:374)
==16240==    by 0x5293E0: main_dispatcher_constructed (main-dispatcher.c:315)
==16240==    by 0x7F873DB: g_object_new_internal (gobject.c:1823)
==16240==    by 0x7F87EE4: g_object_new_valist (gobject.c:2042)
==16240==    by 0x7F86E90: g_object_new (gobject.c:1626)
==16240==    by 0x5292A5: main_dispatcher_new (main-dispatcher.c:295)
==16240==    by 0x429A0A: do_spice_init (reds.c:3416)
==16240==    by 0x42A3F5: spice_server_init (reds.c:3663)
==16240==    by 0x4095B1: server_leaks (test-leaks.c:45)
==16240==    by 0x844C60A: test_case_run (gtestutils.c:2161)
==16240==    by 0x844C9CA: g_test_run_suite_internal (gtestutils.c:2244)
==16240==    by 0x844CA73: g_test_run_suite_internal (gtestutils.c:2256)
==16240==    by 0x844CC8A: g_test_run_suite (gtestutils.c:2332)
==16240==    by 0x844B92C: g_test_run (gtestutils.c:1599)
==16240==    by 0x409A0B: main (test-leaks.c:126)
==16240==
==16240== 16 bytes in 1 blocks are definitely lost in loss record 204 of 771
==16240==    at 0x4C2DADE: malloc (vg_replace_malloc.c:298)
==16240==    by 0x4C2FC91: realloc (vg_replace_malloc.c:785)
==16240==    by 0x52864E: dispatcher_register_handler (dispatcher.c:374)
==16240==    by 0x5293E0: main_dispatcher_constructed (main-dispatcher.c:315)
==16240==    by 0x7F873DB: g_object_new_internal (gobject.c:1823)
==16240==    by 0x7F87EE4: g_object_new_valist (gobject.c:2042)
==16240==    by 0x7F86E90: g_object_new (gobject.c:1626)
==16240==    by 0x5292A5: main_dispatcher_new (main-dispatcher.c:295)
==16240==    by 0x429A0A: do_spice_init (reds.c:3416)
==16240==    by 0x42A3F5: spice_server_init (reds.c:3663)
==16240==    by 0x40BFD4: test_new (test-display-base.c:902)
==16240==    by 0x40979D: vmc_leaks (test-leaks.c:92)
==16240==    by 0x844C60A: test_case_run (gtestutils.c:2161)
==16240==    by 0x844C9CA: g_test_run_suite_internal (gtestutils.c:2244)
==16240==    by 0x844CA73: g_test_run_suite_internal (gtestutils.c:2256)
==16240==    by 0x844CC8A: g_test_run_suite (gtestutils.c:2332)
==16240==    by 0x844B92C: g_test_run (gtestutils.c:1599)
==16240==    by 0x409A0B: main (test-leaks.c:126)
==16240==
==16240== 96 bytes in 1 blocks are definitely lost in loss record 638 of 771
==16240==    at 0x4C2FA50: calloc (vg_replace_malloc.c:711)
==16240==    by 0x8427D3C: g_malloc0 (gmem.c:124)
==16240==    by 0x842801F: g_malloc0_n (gmem.c:355)
==16240==    by 0x527B44: dispatcher_constructed (dispatcher.c:141)
==16240==    by 0x529321: main_dispatcher_constructed (main-dispatcher.c:307)
==16240==    by 0x7F873DB: g_object_new_internal (gobject.c:1823)
==16240==    by 0x7F87EE4: g_object_new_valist (gobject.c:2042)
==16240==    by 0x7F86E90: g_object_new (gobject.c:1626)
==16240==    by 0x5292A5: main_dispatcher_new (main-dispatcher.c:295)
==16240==    by 0x429A0A: do_spice_init (reds.c:3416)
==16240==    by 0x42A3F5: spice_server_init (reds.c:3663)
==16240==    by 0x4095B1: server_leaks (test-leaks.c:45)
==16240==    by 0x844C60A: test_case_run (gtestutils.c:2161)
==16240==    by 0x844C9CA: g_test_run_suite_internal (gtestutils.c:2244)
==16240==    by 0x844CA73: g_test_run_suite_internal (gtestutils.c:2256)
==16240==    by 0x844CC8A: g_test_run_suite (gtestutils.c:2332)
==16240==    by 0x844B92C: g_test_run (gtestutils.c:1599)
==16240==    by 0x409A0B: main (test-leaks.c:126)
==16240==
==16240== 96 bytes in 1 blocks are definitely lost in loss record 639 of 771
==16240==    at 0x4C2FA50: calloc (vg_replace_malloc.c:711)
==16240==    by 0x8427D3C: g_malloc0 (gmem.c:124)
==16240==    by 0x842801F: g_malloc0_n (gmem.c:355)
==16240==    by 0x527B44: dispatcher_constructed (dispatcher.c:141)
==16240==    by 0x529321: main_dispatcher_constructed (main-dispatcher.c:307)
==16240==    by 0x7F873DB: g_object_new_internal (gobject.c:1823)
==16240==    by 0x7F87EE4: g_object_new_valist (gobject.c:2042)
==16240==    by 0x7F86E90: g_object_new (gobject.c:1626)
==16240==    by 0x5292A5: main_dispatcher_new (main-dispatcher.c:295)
==16240==    by 0x429A0A: do_spice_init (reds.c:3416)
==16240==    by 0x42A3F5: spice_server_init (reds.c:3663)
==16240==    by 0x40BFD4: test_new (test-display-base.c:902)
==16240==    by 0x40979D: vmc_leaks (test-leaks.c:92)
==16240==    by 0x844C60A: test_case_run (gtestutils.c:2161)
==16240==    by 0x844C9CA: g_test_run_suite_internal (gtestutils.c:2244)
==16240==    by 0x844CA73: g_test_run_suite_internal (gtestutils.c:2256)
==16240==    by 0x844CC8A: g_test_run_suite (gtestutils.c:2332)
==16240==    by 0x844B92C: g_test_run (gtestutils.c:1599)
==16240==    by 0x409A0B: main (test-leaks.c:126)
==16240==
==16240== LEAK SUMMARY:
==16240==    definitely lost: 224 bytes in 4 blocks
==16240==    indirectly lost: 0 bytes in 0 blocks
==16240==      possibly lost: 0 bytes in 0 blocks
==16240==    still reachable: 207,718 bytes in 3,312 blocks
==16240==                       of which reachable via heuristic:
==16240==                         newarray           : 1,536 bytes in 16 blocks
==16240==         suppressed: 34,548 bytes in 302 blocks
==16240== Reachable blocks (those to which a pointer was found) are not shown.
==16240== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==16240==
==16240== For counts of detected and suppressed errors, rerun with: -v
==16240== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 20 from 20)
FAIL test-leaks (exit status: 1)

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-14 09:19:49 +00:00
Christophe Fergeau
6377b72d44 Use bool rather than int return values when appropriate
This commit changes all functions returning TRUE/FALSE from having an
'int' return value to 'bool'.
This way it's obvious that such a function is not going to return
anything else than TRUE or FALSE.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-09 18:39:29 +01:00
Frediano Ziglio
9af182b67a red-channel: Move alloc_recv_buf and release_recv_buf to RedChannelClient
These vfuncs are more appropriate in RedChannelClient.
The buffer they allocated are related to the client stream
which is managed directly by RedChannelClient.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-04 14:58:15 +00:00
Frediano Ziglio
afc4171c98 red-channel: Use RedChannelCapabilities directly to pass capabilities
For each channel there are two set of capabilities, one
for the common ones and one for the specific ones.
A single set were almost always passed using 2 arguments,
a number of elements and an array but then before using
these were converted to a GArray.
Use a single structure (already available) to pass all
channel capabilites using a single argument.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-02 15:34:58 +00:00
Frediano Ziglio
47ba429a8f spicevmc: Use spice_new instead of spice_malloc
spice_new is a bit more safe as return a properly typed pointer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-28 14:17:56 +00:00
Frediano Ziglio
9724381afa Make RedChannel::config_socket() optional
Most channels don't need to do specific settings for the client socket
so avoid the need to do this setting making easier to setup the client
channnel.

Some improvements and commit subject suggested by Christophe Fergeau.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-15 12:40:38 +00:00
Frediano Ziglio
01c25074dc Do not set TCP_NODELAY flag twice
TCP_NODELAY flag is set by default for all connection inside
reds.c so there's no need to set again for the single
client channel.

Note that there are still some calls to setsockopt to change this
option.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-15 12:38:30 +00:00
Frediano Ziglio
5a922af9e6 spicevmc: Add some statistics
Allows to see compressed/uncompressed ratio

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 10:16:16 +00:00
Christophe Fergeau
03ab893412 channel: Remove RedChannel::handle_parsed
red_channel_client_parse() currently does roughly:

if (klass->parser) {
    parsed = klass->parser(msg, msg_size, &parsed_size);
    klass->handle_parsed(rcc, parsed_size, msg_type, parsed);
} else {
    klass->handle_message(rcc, msg_type, msg, msg_size);
}

The handle_parsed implementation expects a void * 'parsed' argument,
which will then be cast to the correct type. There is not really a need
to provide distinct handle_parsed/handle_message vfuncs, instead we can
say that if a RedChannel subclass provides a 'parser' vfunc, then it's
'handle_message' vfunc will be called with the parsed message, otherwise
it will be called with unparsed data (ie what handle_message currently
expects).

This makes the code slightly easier to follow as messages will always be
handled by the same vfunc.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-15 08:47:52 +01:00
Frediano Ziglio
d8a32e77f5 spicevmc: Avoid computing some variable value if not necessary
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-01 08:47:07 +00:00
Frediano Ziglio
7ce225f053 spicevmc: Reduce number of last saved IDs
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-01-26 14:48:01 +00:00
Frediano Ziglio
00ec69f4fe spicevmc: Remove leak of RedPortInitPipeItem::name
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-01-26 14:47:52 +00:00
Frediano Ziglio
71e1af9d8b spicevmc: Avoid useless pointer cast
red_channel_client_handle_message already accepts a void* pointer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-01-26 14:46:44 +00:00
Jonathon Jongsma
0ace8a81c7 Remove third argument from red_channel_client_init_send_data()
This third argument (and the 'item' member of
RedChannelClient::priv::send_data) was a somewhat roundabout way to keep
the RedPipeItem alive until a message is sent, just in case some data
owned by that pipeitem was added to the marshaller by reference. This
was a rather confusing mechanism, however, since it did not have any
obvious connection to the _add_by_ref() call. It was never very clear
whether you needed to pass an item to this function or not. The previous
series of patches made this parameter unnecessary since the referencing
of the pipe item (or other related structure) is now more explicitly
connected to the calls to spice_marshaller_add_by_ref_full().

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-20 16:11:39 +00:00
Jonathon Jongsma
b5758229ad Spicevmc: don't pass pipe item to init_send_data()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-20 16:11:31 +00:00
Jonathon Jongsma
5c0f2e341c Avoid passing pipe item to red_channel_client_init_send_data()
The only time that the pipe item needs to be passed as the third
argument to red_channel_client_init_send_data() is when the pipe item
holds a data buffer that has been added to the marshaller by reference
(spice_marshaller_add_by_ref()) and needs to be kept alive until the
data has been sent. In all other cases, the item does not need to be
kept alive, so we can safely pass NULL for this third parameter.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-20 10:14:02 +00:00
Frediano Ziglio
91668cdaab Sort include order in source files
Sort based on coding style.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-16 08:16:21 +00:00
Frediano Ziglio
3613ead4d8 marshaller: rename _add_ref() to _add_by_ref()
The spice_marshaller_add_ref() family of functions is confusing since it
sounds like you're incrementing a reference on the marshaller. What it
is actually doing is adding a data buffer to the marshaller by reference
rather than by value. Changing the function names to _add_by_ref() makes
this clearer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-12-08 14:05:04 +00:00
Frediano Ziglio
2e34c83391 spicevmc: Remove some duplicate typedefs
These cause compiler errors using RHEL6.
These typedefs are defined in the same file some lines above.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-15 11:50:27 +00:00
Jonathon Jongsma
e86f9521db char-device: add 'self' param to vfuncs
Add a 'self' parameter to all of the char device virtual functions so
that we don't have to play games with the 'opaque' pointer.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-14 14:30:47 +00:00
Frediano Ziglio
6a3917f653 spicevmc: Change creation of RedCharDeviceSpiceVmc
Instead of having channel and device object create one the other
create the objects at the beginning and then join them.

This make explicit the code that links the two objects and separate
the objects creation from the linking.

Also remove some boilerplate code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-07 10:37:20 +00:00
Jonathon Jongsma
b6cca46d75 spicevmc: use 'channel' instead of 'state'
After renaming the object to RedVmcChannel, the local variables still
used the old 'state' terminology. Changing these variables to 'channel'
makes things a bit more consistent.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 11:02:25 +00:00
Jonathon Jongsma
7e70be6d16 Remove spicevmc_red_channel_client_get_state()
This helper function does nothing but cast the return from
red_channel_client_get_channel(), and it has a confusing name
(_get_state(), but returns a channel)

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 09:15:17 +00:00
Frediano Ziglio
97e299cc50 spicevmc: Clear RedVmcChannel on red_char_device_spicevmc_dispose
This move object destructions from spicevmc_device_disconnect
to RedCharDeviceSpiceVmc destructor functions assuring any possible
RedCharDeviceSpiceVmc object free will clear its references.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 08:59:18 +00:00
Frediano Ziglio
d80d7447e7 spicevmc: More RedVmcChannel::recv_from_client_buf cleanup to finalize
No reason why this should be done only on spicevmc_device_disconnect.
red_char_device_write_buffer_release can be called with first pointer
NULL.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 08:59:16 +00:00
Frediano Ziglio
cd7d3d3486 spicevmc: Free pipe_item in finalize
Assure field is freed at the end and not used or allocate again.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 08:59:06 +00:00
Jonathon Jongsma
f751eb9fdb spicevmc: store channel in char device
Store the channel in the char device object, and unref it in dispose.
Previously, we were just creating a channel and potentially allowing it
to leak.  There may be better long-term solutions, but this works for
now.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 08:58:38 +00:00
Jonathon Jongsma
e09f8bab6c Rename SpiceVmcState to RedVmcChannel
Internal types use the 'Red' prefix by convention, rather than the
'Spice' prefix. In addition, this type inherits from RedChannel, so
makes the code a lot clearer to call it a 'channel' rather than a
'state'.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-01 15:02:18 +00:00
Jonathon Jongsma
96e94c6f32 Convert RedChannel hierarchy to GObject
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-10-25 11:32:13 -05:00
Frediano Ziglio
5193360594 Convert RedChannelClient hierarchy to GObject
Convert the RedChannelClient heirarchy into GObjects. Since the existing
constructors could fail and return NULL, I inherited the base channel
client from GInitable, which introduces a dependency on gio.

When using private structs with GObject, there's a maximum size of (I
think) 64k, which was exceeded by some of the private structs. To avoid
this limitation I changed some members to dynamically allocated.
2016-10-07 14:46:37 -05:00
Jonathon Jongsma
bed132d6e2 Move RedChannelClient to separate file
Reduce direct access to RedChannelClient, and get ready to convert to
GObject.

Acked-by: Frediano Ziglio <fziglio@redhat.com
2016-09-08 09:37:59 +01:00