Commit Graph

2842 Commits

Author SHA1 Message Date
Frediano Ziglio
e2898dfd9e usb-device-manager: Remove disconnect_cb_data
"device" field is just written, never read.
"manager" field can be retrieved using g_task_get_source_object.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
2019-12-18 15:50:11 +02:00
Frediano Ziglio
db59d50f5c Use g_clear_object instead of g_clear_pointer if possible
If the pointer is freed with g_object_unref the two do the
same.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
2019-12-18 14:40:50 +02:00
Frediano Ziglio
7f7542f490 spice-session: Remove goto statement and label
Just a style change.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
2019-12-18 14:40:38 +02:00
Frediano Ziglio
67cf1f704b spice-session: Remove only assigned "pci_ram_size" field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-16 16:31:28 +00:00
Frediano Ziglio
adc5651ef1 spice-session: Removed unused "palettes" field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-16 16:31:28 +00:00
Frediano Ziglio
756e31b03e po/it: Update some Italian translations
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2019-12-16 16:30:54 +00:00
Frediano Ziglio
2340de0de0 po/it: Update po file
Simple automatic update of the file to sync with sources

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2019-12-16 16:30:30 +00:00
Alexander Nezhinsky
6685b013d7 fix style in usb-device-widget: always place curly brackets after if
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-12 14:50:48 +00:00
Alexander Nezhinsky
3b1afefcf3 fix style in usb-device-widget: arguments and parameters alignment
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-12 14:50:46 +00:00
Alexander Nezhinsky
c32fc36f02 fix style in usb-device-manager: always place curly brackets after if
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-12 14:50:44 +00:00
Alexander Nezhinsky
7e2e1ed462 fix style in usb-device-manager: arguments and parameters alignment
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-12 14:50:42 +00:00
Alexander Nezhinsky
d09a35603d fix style in usb-device-manager: rename 'self' to 'manager'
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-12 14:50:39 +00:00
Alexander Nezhinsky
e1ba69c255 implement spice_usb_device_widget_add_err_msg() in usb-device-widget
This is a common function for adding an error status message.

If an old message exists, checks if the new message is not already contained
in the old one. The new message is ignored if it is, added if it's not.

New message string should be dynamically allocated, it's always g_free-ed.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-12 14:50:36 +00:00
Alexander Nezhinsky
dbe4aec78c move spice_usb_backend_device_{eject|report_change} to usb_backend.h
These functions belong to usb_backend_device api

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-12 14:50:34 +00:00
Victor Toso
0c52ce8937 display: remove dangling pointer
It just holds a reference to the primary surface which is being
removed and freed from the hash table. This ends up generating a
warning below in the same function before setting the new primary
surface reference.

Signed-off-by: Victor Toso <victortoso@redhat.com>
2019-10-31 00:27:24 +01:00
Frediano Ziglio
33ca9d412c spice-widget: Fix invalidate region in case of image is scaled
In case the drawing on the screen is scaled the scaling required to
invalidate a slightly bigger region.
This is due to the interpolation done during the resize.
So if scaling is performed invalidate also the adjacent pixels.

This fixes https://gitlab.freedesktop.org/spice/spice-gtk/issues/19.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-10-14 13:16:35 +01:00
Victor Toso
ee35577c7e channel-main: add debug related to migration
Migration can start with different messages and the code could take
different paths. By having a debug on which message started can help
pinpoint issues faster.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-30 10:15:45 +02:00
Frediano Ziglio
ca6b5f384d test-cd-emu: Test no libusb context support
Although currently not supported by the code (libusb_context in
SpiceUsbBackend is never NULL), try to support it in order to be able to
have only emulated devices if the libusb layer is failing.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-27 11:08:48 +01:00
Frediano Ziglio
7d5e1c3005 test-cd-emu: Make sure we can call spice_usb_backend_channel_flush_writes
Currently we call this function when the SPICE channel is up
however this function should continue to work as in theory
the channel could avoid to handle the message and stop the flow
(for instance to implement some kind of flow limitation)
and so will need to call this function again.
This was failing in the first USB emulation implementation
causing a crash.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-27 11:08:45 +01:00
Frediano Ziglio
52074d7590 test-cd-emu: Test detach and reattach
Make sure device can be detached and attached again.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-27 11:08:42 +01:00
Frediano Ziglio
7cab37275b test-cd-emu: Test attach/detach emulated device
Mock some usb-backend functions to be able to simulate device
attachment and detachment.
Create session and channel to pass some valid pointer anyway.
Emulate channel state correctly.
Make sure HELLO packets are sent correctly at the beginning and
no more afterwards.
Test auto-connect enabled or disabled.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-27 11:08:40 +01:00
Frediano Ziglio
6ad2ec5a81 build: Use a convenience library for tests
Instead of linking all object inside spice-client-glib build a library
from these object and link to each test.
This will allow to override some object file for mocking purposes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-27 11:08:38 +01:00
Frediano Ziglio
e679d87bc0 test-cd-emu: Add base test for cd-emulation
Just allocate and free to test for base leaks and reference
counting.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-27 11:08:32 +01:00
Frediano Ziglio
b8f2255904 spicy: Do not call gst_init directly
GStreamer is already initialized using gst_init_get_option_group and
gst_init_get_option_group.

From gst_init documentation:
   WARNING: This function does not work in the same way as
   corresponding functions in other glib-style libraries,
   such as gtk_init(). In particular, unknown command line options
   cause this function to abort program execution.

This luckily is not true (program won't abort if you pass --gst-foo
for instance) but better to stick to documentation.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Snir Sheriber <ssheribe@redhat.com>
2019-09-23 16:13:59 +01:00
Frediano Ziglio
d7f743f617 build: Do not build usbredir dependent file if usbredir is disabled
These files would end up to compile empty code, no reason
to compile and link them.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-23 15:51:50 +01:00
Yuri Benditovich
50953f2360 usb-redir: enable redirection of emulated CD drive
Add implementation of emulated device to build.
Now it is possible to create emulated CD devices.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-23 14:01:58 +01:00
Yuri Benditovich
f771f701ad usb-redir: add implementation of emulated CD device
This module contains implementation of emulated device
interface for shared CD.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-23 13:58:31 +01:00
Frediano Ziglio
5bf98b3926 cd-scsi: Do not export sense code constants
They are used only inside the module.
Use a macro to simplify declaration which is pretty long.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-23 13:58:31 +01:00
Yuri Benditovich
ef0bee2e56 usb-redir: add files for SCSI and USB MSC implementation
Files added without including them in compilation.
They contain implementation of SCSI commands for logical
units of mass-storage device class and USB bulk-only
mass-storage device protocol.

Signed-off-by: Alexander Nezhinsky<anezhins@redhat.com>
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-23 13:58:31 +01:00
Yuri Benditovich
3e20f17b90 usb-redir: extend USB backend to support emulated devices
Redirection of emulated devices requires special approach, as
usbredirhost can't be used for that (it works only with libusb
devices). For emulated devices we create instance of usbredirparser
that implements USB redirection protocol.  In order to work with the
same set of protocol capabilities that usbredirhost sets up with
remote side, the parser shall: - not send its own 'hello' to the
server
- initialize the same capabilities that usbredirhost
- receive the same 'hello' response
For that we analyze 'hello' sent by USB redir parser and extract set
of capabilities from it and upon receive of 'hello' response we
provide it also to the parser.  When libusb device is redirected via a
channel, instance of usbredirhost serves it.  When emulated device is
redirected via a channel, instance of usbredirparser does the job.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-23 13:58:31 +01:00
Yuri Benditovich
78c5a2e933 usb-backend: include usbredirparser
This patch introduces the usage of usbredirparser in
SpiceUsbBackendChannel.

The focus of this patch is to the code path of real devices. As we
don't know beforehand if a SpiceUsbBackendChannel will be used by real
or emulated devices, an instance of usbredirparser must be initialized
with the usbredirhost's first hello message.

This is a must to the current design on supporting emulated devices.
This will be extended in the next patch to match remote's usbredirhost
capabilities and providing support to emulated devices.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Victor Toso <victortoso@redhat.com>
2019-09-23 13:58:31 +01:00
Frediano Ziglio
6ee21ef76b usb-backend: add safe check on attach()
At this moment, spice_usb_backend_channel_attach() is only related to
real devices and this call might happen on channel-up event that can
possibly come before usbredirhost has been created.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-23 13:58:19 +01:00
Victor Toso
4dd2eb519e usb-backend: add guard and doc to check_filter()
* Add documentation on spice_usb_backend_device_check_filter()
* Add guard on libusb_device
* Adds G_GNUC_INTERNAL as this is only called internally in
  usb-device-manager.c
* Changed the style a bit, still under 100 char in a single line

This is a preparatory patch for extending usb-backend for emulated
devices.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-19 15:34:49 +01:00
Yuri Benditovich
9ca9095186 usb-backend: no emulated isoch devices
SpiceUsbBackendDevice deals with real and emulated devices but there
is no plans to implement emulated isochronous devices.

This patch adds check to edev (emulated device) in the guard, fix the
return value to FALSE instead of plain 0 and return early in case the
code path is around emulated devices.

This is a preparatory patch to extend emulated devices support.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-19 15:34:49 +01:00
Yuri Benditovich
5aec2ddd91 usb-redir: do not use spice_usb_acl_helper for emulated devices
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-09 09:13:08 +01:00
Yuri Benditovich
ddb62340a1 usb-redir: move implementation of device description to USB backend
For local USB device the USB backend returns the same device
description as spice-usb-manager did, for emulated devices it
uses the description provided by device's implementation.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-09 09:13:08 +01:00
Yuri Benditovich
822e855887 usb-redir: define interfaces to support emulated devices
SpiceUsbBackendDevice structure is extended to support
additional kind of device that is emulated by Spice-GTK
and not present locally (and does not have libusb_device),
such device has instead pointer to SpiceUsbEmulatedDevice
abstract structure. Specific implementation of such device
depends on its device type. Implementation module will define
constructor for specific device type.
Device structure is abstract but always starts from table of
virtual functions required to redirect such virtual device.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-09 09:13:08 +01:00
Frediano Ziglio
efc284ec6f spice-session: Fix SWAP_STR macro
Really swap "x" and "y", not temporary copies.
The issue was introduced by 01c6343 "Use macro to swap
data in spice_session_start_migrating()".

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-09 09:11:46 +01:00
Frediano Ziglio
f361d17235 usb-backend: SpiceUsbredirChannel is not opaque anymore
Use specific type in spice_usb_backend_channel_new and
specific name instead of "user_data" field.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-05 14:20:04 +01:00
Frediano Ziglio
d9ec1ce3b3 channel-usbredir: Rename spice_usbredir_write_callback
Remove "_callback" suffix.
The function is called directly, no much reasons to keep that
suffix.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-05 14:20:04 +01:00
Victor Toso
a8cf5ff538 main: code style on main_migrate_connect()
1) Make one argument per line, instead of 1, 2, 1
2) Use session variable that already exists
3) Don't cast again to SpiceChannel

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-05 10:17:55 +02:00
Victor Toso
d77b2db80c main: migration: check return value to count channels
Although spice_channel_connect() works in idle, if it returns false
it'll not emit any signal further and we would be counting a
'connected' channel that wouldn't be emitting anything.

As other callbacks take this in consideration, we should only
increment the counter if we reached spice-channel::connect_delayed()
callback.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-05 10:17:53 +02:00
Victor Toso
6538d15b59 main: return void on migrate_channel_connect()
The migration process would happen in idle, so the process only fails
at a later time. No call to migrate_channel_connect() is actually
checking the return value.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-09-05 10:17:43 +02:00
Victor Toso
4b9d56b740 spice-gstaudio: fix GTask leak on query for volume
> 184 bytes in 1 blocks are definitely lost in loss record 12,668 of 14,231
 >    at 0x483880B: malloc (vg_replace_malloc.c:309)
 >    by 0x4A64C98: g_malloc (in /usr/lib64/libglib-2.0.so.0.6000.6)
 >    by 0x4A7CFB5: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.6000.6)
 >    by 0x4A7D5DD: g_slice_alloc0 (in /usr/lib64/libglib-2.0.so.0.6000.6)
 >    by 0x4D3E061: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.6000.6)
 >    by 0x4D2042C: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
 >    by 0x4D21B14: g_object_new_with_properties (in /usr/lib64/libgobject-2.0.so.0.6000.6)
 >    by 0x4D226C0: g_object_new (in /usr/lib64/libgobject-2.0.so.0.6000.6)
 >    by 0x4BE0FB8: g_task_new (in /usr/lib64/libgio-2.0.so.0.6000.6)
 >    by 0x48EDFCB: spice_gstaudio_get_record_volume_info_async (spice-gstaudio.c:679)
 >    by 0x48C2A4F: spice_audio_get_record_volume_info_async (spice-audio.c:212)
 >    by 0x48B2F00: agent_sync_audio_record (channel-main.c:1285)
 >
 > 240 (184 direct, 56 indirect) bytes in 1 blocks are definitely lost in loss record 12,889 of 14,231
 >    at 0x483880B: malloc (vg_replace_malloc.c:309)
 >    by 0x4A64C98: g_malloc (in /usr/lib64/libglib-2.0.so.0.6000.6)
 >    by 0x4A7CFB5: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.6000.6)
 >    by 0x4A7D5DD: g_slice_alloc0 (in /usr/lib64/libglib-2.0.so.0.6000.6)
 >    by 0x4D3E061: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.6000.6)
 >    by 0x4D2042C: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
 >    by 0x4D21B14: g_object_new_with_properties (in /usr/lib64/libgobject-2.0.so.0.6000.6)
 >    by 0x4D226C0: g_object_new (in /usr/lib64/libgobject-2.0.so.0.6000.6)
 >    by 0x4BE0FB8: g_task_new (in /usr/lib64/libgio-2.0.so.0.6000.6)
 >    by 0x48EDAF9: spice_gstaudio_get_playback_volume_info_async (spice-gstaudio.c:597)
 >    by 0x48C2967: spice_audio_get_playback_volume_info_async (spice-audio.c:189)
 >    by 0x48B2C33: agent_sync_audio_playback (channel-main.c:1229)

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2019-09-05 09:36:53 +02:00
Kevin Pouget
f9d54ada79 streaming: make draw-area visible on MJPEG encoder creation
This patch allows the MJPEG encoder to inform the spice-widget that
its video drawing area (draw-area) should be made visible on screen.

This is required to switch from GST video decoding to native MJPEG
decoding, otherwise the gst-area remained on top and the MJPEG video
stream was never shown.

Signed-off-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Snir Sheriber <ssheribe@redhat.com>
2019-09-03 08:19:06 +02:00
Frediano Ziglio
74f1f75647 usb-device-manager: Use SpiceUsbBackendDevice directly instead of SpiceUsbDevice
They were the same structure.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-02 12:05:06 +01:00
Frediano Ziglio
039d0796af usb-device-manager: Remove isochronous field from _SpiceUsbDevice
Report directly value from SpiceUsbBackendDevice.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-02 12:05:04 +01:00
Frediano Ziglio
60342d26ee usb-backend: Cache isochronous value
Allows to remove _SpiceUsbDevice structure.
_SpiceUsbDevice is only caching this value from SpiceUsbBackendDevice.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-09-02 12:04:59 +01:00
Frediano Ziglio
aed7c51a23 build: Fix compatibility with Meson 0.49
The "install" argument for configure_file is available since 0.50.
However this is already "false" if "install_dir" is not provided.

Update also spice-common submodule to import a similar fix for
spice-common module. This brings in the following changes:

Frediano Ziglio (10):
      gitignore: Ignore auto generated generated_messages.h file
      Do not check for HAVE_CONFIG_H
      build: Remove unused git-version-gen file
      recorder: Update
      build: Disable Celt support by default
      codegen: Use has_end_attr instead of has_attr("end")
      codegen: Exit with error on error generating C structures
      protocol: Removed unneeded type specifications
      codegen: Add a check for C structure fields
      meson: Remove "install" argument from configure_file

Uri Lublin (2):
      ptypes.py: remove useless condition member != None
      test-marshallers.proto: ArrayMessage: make space for name

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2019-08-29 16:58:18 +01:00
Frediano Ziglio
1dc73b2c63 usb-redir: cosmetic style fixes 2019-08-27 22:03:21 +01:00