Commit Graph

2957 Commits

Author SHA1 Message Date
Marc-André Lureau
b9754be166 main: add display physical size support
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-09-16 10:55:05 +01:00
Marc-André Lureau
e521ddee98 main: add stricter pre-condition on display id value
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-09-16 10:55:03 +01:00
Frediano Ziglio
dc66d07036 spice-channel: Reuse channel
We already checked "data", no need to do it again.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-09-15 11:51:46 +01:00
Marc-André Lureau
b25b992e79 meson: add back explicit dependency on spice-protocol
Partially revert commit
51ede38ee5 ("build: Tell SPICE common the
SPICE protocol version we require") as spice-gtk depends on
specific spice-protocol version as well.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-09-15 10:08:29 +01:00
Frediano Ziglio
97c43efb4e channel-display: Remove leak if surface is reused
"surface" parameters is normally attached to "surfaces" hash table
but in case surface is reused the buffer is not freed.

This problem was reported by Ding Fei.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-09-10 13:01:28 +01:00
Jakub Janků
7efeb298e0 Revert 4b9092b9 and add SpiceSession:webdav-server property instead
This reverts commit 4b9092b96b
"session: make spice_session_get_webdav_server() public".

Instead of publishing the function to access the PhodavServer
from spice-gtk-session.c, install a new read-only property
"webdav-server" and use g_object_get() to retrieve it.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-09-10 12:58:41 +01:00
Jakub Janků
f33d589d74 clipboard: enable copying files to guest using webdav
When an app advertises the "text/uri-list" target, the user
probably wants to copy/move files. Spice-gtk then sends
a grab message to the vdagent advertising the
VD_AGENT_CLIPBOARD_FILE_LIST type.

Vdagent can then request clipboard data in this type.

Spice-gtk tries to talk to the app that owns the clipboard
in its native format in order to determine the preferred
file operation (copy X move).

For GNOME Nautilus, that's simply "UTF8_TEXT",
for KDE Dolphin, "application/x-kde-cutselection".

Otherwise the generic "text/uri-list" is used that does not
provide any additional information.

Once the uri list is obtained from the app, spice-gtk
creates a unique virtual dir in the ".spice-clipboard"
directory that is designated for this purpose.

Each file is attached inside this virtual dir using
phodav_virtual_dir_attach_real_child(), see phodav API
for details.

A list of paths in the phodav server is then sent to vdagent,
as specified in the spice-protocol.
Such path can for example look like this:
    /.spice-clipboard/b8f0249c-082a-4da9-9a38-2de3237a66f0/file

It is up to the vdagent to ensure that the spice shared folder
is accessible and to set the clipboard data in a format that
other apps understand.

This requires new phodav with PhodavVirtualDir API.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-09-09 14:42:37 +01:00
Jakub Janků
996bfb48dc spice-gtk-session: cache atoms
At the moment, spice-gtk only sends a grab message to the vdagent
based on the retrieved atoms.

With the upcoming changes, spice-gtk will have to know which
targets were advertised outside of clipboard_get_targets() callback.

We could use gtk_clipboard_wait_for_targets() or
gtk_clipboard_wait_is_*_available(), but the targets are not cached
by GTK+ on wayland for some reason. So let's cache them in spice-gtk
to avoid having to talk to the clipboard owner.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-09-09 14:42:34 +01:00
Jakub Janků
852b847c86 spice-gtk-session: add clipboard_get_open_webdav()
File copy&paste functionality will only be enabled when there is an open
webdav channel.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-09-09 14:42:32 +01:00
Jakub Janků
c1b5433815 build: require GLib 2.52+
This adds g_uuid_string_random()
which is necessary for the following file copy&paste
functionality.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-09-09 14:42:29 +01:00
Jakub Janků
979b752b24 build: define HAVE_PHODAV_VIRTUAL if phodav >= 2.5
Phodav 2.5 brings PhodavVirtualDir API needed for the
file copy and paste functionality.

If the library version is not sufficient, this new feature
will be disabled, but the standard shared folders can still
be used.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-09-09 14:42:27 +01:00
Jakub Janků
4b9092b96b session: make spice_session_get_webdav_server() public
It will be necessary to access the webdav server from spice-gtk-session.c
which isn't compiled with spice-session-priv.h, so make
spice_session_get_webdav_server() public.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-09-09 14:42:23 +01:00
Frediano Ziglio
f524f87552 Update spice-common submodule
This brings in the following changes:

Frediano Ziglio (19):
      canvas_base: Format canvas_draw_blend similarly to canvas_draw_copy
      canvas_base: Rename blend to copy for canvas_draw_blend argument
      canvas_base: Remove canvas_draw_blend/canvas_draw_copy duplication
      build: Remove dependency to gio2 from common and server libraries
      build: Remove dependencies to libgthread
      test-utils: Add missing include file
      test-quic: Test fixed images
      test-quic: Different "more_space" function for decode and encode
      Reuse macros from spice-protocol
      rect: Avoid usage of "small"
      build: Remove -Werror from Meson build
      snd_codec: Use better types for snd_codec_is_capable
      snd_codec: Use better type for function result
      snd_codec: Use better type for snd_codec_create mode
      backtrace: Do not attempt to compile if spice_backtrace is empty
      Avoid usage of GCC extension for __VA_ARGS__ where possible
      helper-fuzzer-demarshallers: Provide replacement for ftello for MSVC
      quic_tmpl: Remove unused bpc parameter
      ssl_verify: Do not check IP if we fail to resolve it

Haochen Tong (2):
      pixman_utils: fix clang "unused functions" warning
      marshal: fix clang "missing field initializer" warning on generated files

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-08-28 09:51:36 +01:00
Frediano Ziglio
95f6f22c4f Remove some warnings from Clang static analyzer
qmp-port.c:
warning: Although the value stored to 'node' is used in the enclosing
expression, the value is never actually read from 'node'

usb-backend.c:
warning: Value stored to 'done' is never read
warning: Use of memory after it is freed

usb-device-cd.c:
warning: Value stored to 'error' is never read

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-08-27 17:20:06 +01:00
Marc-André Lureau
8d60d4fc3f main: add a few missing vdagent capability descriptions
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-25 08:13:40 +01:00
Marc-André Lureau
76baab8ae8 gtk: remove redundant monitor id from log
Since commit 162531a1c0, the
channel/monitor IDs are already printed.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-25 08:13:25 +01:00
Frediano Ziglio
5989350429 continuation: Simplify implementation
Instead of using ucontext and setjmp together just use setjmp and
limit ucontext usage to initialise the initial jmp_buf context.
This simplifies the code and reduce number of context operations done.
In particular using _setjmp/_longjmp moving from a context to
another does not require any system call.
On x64 the continuation structure is reduced from 2176 to 248 bytes.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-22 09:25:09 +01:00
Frediano Ziglio
942bd130dd Allows to use Valgrind with ucontext coroutines
Changing stack is not usually instrumentation friendly.
Allows to enable the usage of Valgrind memcheck calling some
valgrind macros.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-22 09:25:07 +01:00
Frediano Ziglio
f5121d14a7 coroutine: Fix indentation
These files use tabs instead of spaces, fix indentation.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-22 09:25:02 +01:00
Haochen Tong
515a84ba12 spice-widget: prevent mouse cursor from being too small
Caps the minimum scale of the mouse cursor to 50% so that it is still
visible even if the window is too small.

This also workarounds a GDK warning when SpiceDisplay is used in
remote-viewer. Upon its initialization there is a possible race
condition, where update_mouse_cursor is called but the widget still has
a size of 1x1. In such case, the calculated scale is very small and the
mouse surface width and height are both zero, causing a warning:

gdk_cursor_new_from_surface: assertion '0 <= x && x < cairo_image_surface_get_width (surface)' failed

Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:33 +01:00
Haochen Tong
cbdda33347 spice-widget: ensure a 640x480 initial size on HiDPI
Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:30 +01:00
Haochen Tong
d589fdafe3 spice-widget-egl: make mouse cursor scale with window size
This is the corresponding fix for EGL server mouse.

Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:28 +01:00
Haochen Tong
5e0a461bec spice-widget: make mouse cursor scale with window size
Make mouse cursor size scale with the window size on Cairo/EGL client
mouse and Cairo server mouse. The cursor size should always be the same
as how big it really is inside the virtual machine.

Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:25 +01:00
Haochen Tong
a15ba78aff spice-widget: correctly position mouse on ungrab
Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:23 +01:00
Haochen Tong
63644cdb2c spice-widget: treat cairo/egl equally on HiDPI
Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:21 +01:00
Haochen Tong
c905e80e59 spice-widget-cairo: respect device scale factor
Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:19 +01:00
Haochen Tong
9db4ae96a2 spice-widget: fix typo (wrap -> warp)
Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:16 +01:00
Haochen Tong
18dfbb9e79 spice-widget: add an API to get guest display size
Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:14 +01:00
Haochen Tong
b30598293b spice-widget: fix widget size request on HiDPI when scaling is disabled
Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:11 +01:00
Haochen Tong
a945a3c24b spice-widget: fix hotspot position on X11/HiDPI
GDK scales hotspot coordinates using screen scale factor on X11. We need
to undo this to get the correct hotspot behavior, otherwise mouse
selection becomes very inaccurate and difficult in the guest.

See [1].

[1] https://gitlab.gnome.org/GNOME/gtk/-/blob/3.24.21/gdk/x11/gdkcursor-x11.c#L556-557

Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:08 +01:00
Haochen Tong
3c9efe24bd spice-widget: fix EGL input coordinate on HiDPI
Fixes #127.

Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:05 +01:00
Haochen Tong
dddd48ad3d spice-widget: correctly scale mouse pointer on HiDPI
Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:46:03 +01:00
Haochen Tong
5e8a597f1c spice-widget: use pixel size for monitor geometry on scaled display
On HiDPI displays, guest screen used to be blurry because the screen
size is smaller than the widget size, and is scaled up. This patch fixes
that by considering scale factor when calculating geometry.

Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-19 10:45:57 +01:00
Frediano Ziglio
25cbf8b45f ci: Test for Windows coroutines
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-12 16:17:19 +01:00
Frediano Ziglio
aa8741d16b coroutine_ucontext: Reuse SPICE_CONTAINEROF
container_of is already implemented using spice macros.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-12 16:17:17 +01:00
Frediano Ziglio
9def63a7a4 coroutine_gthread: Fix recursive yield
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-12 16:17:15 +01:00
Frediano Ziglio
12af86a5a5 coroutine_winfibers: Fix chaining multiple coroutines
Using a single "caller" global does not allow to store multiple
coroutines so use "caller" inside coroutine structure.
Also correctly set the current coroutine returning in coroutine_swap.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-12 16:17:13 +01:00
Frediano Ziglio
ca2e4ec3bb coroutine: Remove "release" field
Not used and implemented in different ways by the various
coroutine implementations

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-12 16:17:11 +01:00
Frediano Ziglio
25875b2e26 coroutine: Initialize "current" at link time
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-12 16:17:09 +01:00
Frediano Ziglio
5f162843f9 coroutine: Make coroutine_swap static
Only used by different coroutine implementations

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-12 16:17:07 +01:00
Frediano Ziglio
afa6a89d5f coroutine: Do not check coroutine_self for NULL
The function never returns a NULL value

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-12 16:17:05 +01:00
Frediano Ziglio
3b24b556fd coroutine_gthread: Do not call g_cond_init
Not necessary from Glib 2.32 for static allocated conditions.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-12 16:17:01 +01:00
Frediano Ziglio
87dc8edfd5 coroutine_gthread: Remove repeated semicolon
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-12 16:16:56 +01:00
Frediano Ziglio
2dc26823d2 spice-channel: Compute correct network wait condition after SSL_connect error
Do not pass always G_IO_OUT. In case SSL_connect is waiting for
data and error was SSL_ERROR_WANT_READ instead of SSL_ERROR_WANT_WRITE
this was creating a tight loop repeatedly calling SSL_connect till
data arrived.
Note that G_IO_ERR and G_IO_HUP are always detected so no need to
add them.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-08-12 12:37:22 +01:00
Frediano Ziglio
5042a8e1c8 spice-channel: Factor out a function to compute GIOCondition from OpenSSL error
Code was duplicate in 2 places.
The or operation ("|") was not necessary as condition was reset to
0 some lines above in both functions.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-08-12 12:37:19 +01:00
Frediano Ziglio
2b6248490d decode-glz: Remove useless __packed__ attribute
These structures contain only bytes, no need for this attribute.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-08-07 10:51:04 +01:00
Frediano Ziglio
41c8a60e5e channel-main: Remove unused declaration
OldRedMigrationBegin is not used. Last usage removed in

  commit f944ad6935

    More cleanup for old protocol support

    Support for protocol version 1 was dropped in commit f77a1d50.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-08-04 15:50:03 +01:00
Jakub Janků
e4a5eb1d50 webdav: fix race caused by libsoup
If we read 0 bytes from the phodav server,
the client connection was closed by the server.

In that case, remove the client immediately,
instead of waiting for the data to be written to the mux channel.

Fixes: https://lists.freedesktop.org/archives/spice-devel/2020-July/051765.html

I believe that the underlying issue, that is causing the described problems,
is that libsoup closes the connection after each request
although the webdav client wanted it to be persistant (keep-alive).

Filed an issue for libsoup:
https://gitlab.gnome.org/GNOME/libsoup/-/issues/195

Additionally, spice-webdavd does not close the connection
when it receives 0-size message for a given webdav client.

As a result, single webdav client can send multiple request using one
connection to spice-webdavd, but in spice-gtk for each request
a new client with the same id must be created.

This leads to basically a race condition when there's still the
client with the given id in the hash table, but the connection
was already closed by libsoup/phodav server. So a new client should
be started but the old closed one is used. The write op then
naturally fails with the following error and the request is lost:

    ../spice-gtk-0.38/src/channel-webdav.c:325 webdav-11:0: write failed: Stream is already closed

So check whether the output stream is closed before demuxing.

Also add some debug messages.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-07-22 17:01:38 +01:00
Jakub Janků
5f685ff85f spice-session-priv: remove unused webdav declarations
This is a follow-up to 228caca239 (!52)

85ed26847c left some residues
in spice-session-priv.h, remove them.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
2020-05-24 15:31:12 +02:00
Kevin Pouget
c5e2ab4322 src/meson.build: fix bug when project version is unknown
When `build-aux/git-version-gen` is not able to find the project
version (no git tags and no `.tarball-version`), it returns 'UNKNOWN'
or 'UNKNOWN-dirty' (instead of the project version like
`0.38.28-d79b`).

This `UNKNOWN` value fails `meson build` command:

    src/meson.build:9:0: ERROR: Index 1 out of bounds of array of size 1.

With this patch, we set a default major/minor/micro value when the
actual version is unknown. This is the same as the `autoconf`
historical behavior.

See spice#41.

Signed-off-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-23 10:28:15 +01:00