Re: [Spice-devel] [client 01/10] build-sys: Enable deprecation warnings instead of ignoring them entirely

2016-10-18 Thread Pavel Grunt
Hi,

this should be the last patch to avoid any compilation issues

On Tue, 2016-10-18 at 19:46 +0200, Francois Gouget wrote:
> For Spice-gtk most deprecation issues come from changes outside
> Spice
> (GLib) and thus should not be treated as errors to not break
> compilation for users who have newer third-party libraries.
> However they must be visible otherwise Spice developers will not be
> aware of them and thus will not fix them before breakage happens.
> 
> Signed-off-by: Francois Gouget 
> ---
>  m4/spice-compile-warnings.m4 | 2 +-
>  src/controller/Makefile.am   | 1 -
>  2 files changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/m4/spice-compile-warnings.m4 b/m4/spice-compile-
> warnings.m4
> index 533bac6..dfa88fe 100644
> --- a/m4/spice-compile-warnings.m4
> +++ b/m4/spice-compile-warnings.m4
> @@ -85,7 +85,7 @@ AC_DEFUN([SPICE_COMPILE_WARNINGS],[
>  gl_WARN_ADD([-Wno-format-nonliteral])
>  # We use some deprecated functions to avoid #ifdef hell while
> maintaining
>  # compat with older gtk / glib versions
> -gl_WARN_ADD([-Wno-deprecated-declarations])
> +gl_WARN_ADD([-Wno-error=deprecated-declarations])
>  
>  
>  
> diff --git a/src/controller/Makefile.am b/src/controller/Makefile.am
> index fb56986..00552e8 100644
> --- a/src/controller/Makefile.am
> +++ b/src/controller/Makefile.am
> @@ -4,7 +4,6 @@ AM_CPPFLAGS = 
> \
>   -DG_LOG_DOMAIN=\"GSpiceController\" \
>   $(GIO_CFLAGS)   \
>   $(COMMON_CFLAGS)\
> - -Wno-deprecated-declarations\

we should keep it, because we don't have much control over the
generated C code by vala 

Pavel

>   $(NULL)
>  
>  # http://www.gnu.org/software/libtool/manual/html_node/Updating-ver
> sion-info.html
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [client] gtk: Remove an obsolete comment

2016-10-18 Thread Pavel Grunt
On Tue, 2016-10-18 at 05:30 -0400, Frediano Ziglio wrote:
> > 
> > The GTK+ compatibility code has been gathered in a single file
> > long ago.
> > 
> 
similar thing is in vncdisplaykeymap.c

> And I also think we removed support for Gtk2 too
> 
> Frediano
> 
> > Signed-off-by: Francois Gouget 
> > ---
> > 
> > See commit c2356a71.
> > 
> >  src/spice-widget.c | 1 -
> >  1 file changed, 1 deletion(-)
> > 
> > diff --git a/src/spice-widget.c b/src/spice-widget.c
> > index 06e332f..3ac0a7d 100644
> > --- a/src/spice-widget.c
> > +++ b/src/spice-widget.c
> > @@ -44,7 +44,6 @@
> >  #include "vncdisplaykeymap.h"
> >  #include "spice-grabsequence-priv.h"
> >  
> > -/* Some compatibility defines to let us build on both Gtk2 and
> > Gtk3 */
> >  
> >  /**
> >   * SECTION:spice-widget
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server 01/10] Define a compatibility include for GLib

2016-10-18 Thread Pavel Grunt
Hi,

On Mon, 2016-10-17 at 14:26 +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio 
> ---
>  server/Makefile.am   |  1 +
>  server/glib-compat.h | 47
> +++
>  2 files changed, 48 insertions(+)
>  create mode 100644 server/glib-compat.h
> 
> diff --git a/server/Makefile.am b/server/Makefile.am
> index 036abcd..dff1ad2 100644
> --- a/server/Makefile.am
> +++ b/server/Makefile.am
> @@ -162,6 +162,7 @@ libserver_la_SOURCES =
> \
>   dcc-private.h   \
>   image-encoders.c\
>   image-encoders.h\
> + glib-compat.h   \
>   $(spice_built_sources)  \
>   $(NULL)
>  
> diff --git a/server/glib-compat.h b/server/glib-compat.h
> new file mode 100644
> index 000..a20a434
> --- /dev/null
> +++ b/server/glib-compat.h
> @@ -0,0 +1,47 @@
> +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
> +/*
> +   Copyright (C) 2016 Red Hat, Inc.
> +
> +   This library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later
> version.
> +
> +   This library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with this library; if not, see  /licenses/>.
> +*/
> +#ifndef GLIB_COMPAT_H_
> +#define GLIB_COMPAT_H_
> +
> +#include 
> +
> +#if !GLIB_CHECK_VERSION(2,32,0)
> +static inline void
> +g_queue_free_full(GQueue *queue, GDestroyNotify free_func)
> +{
> + /* quite hack cast but work with standard C call convention
> */
> + g_queue_foreach(queue, (GFunc) free_func, NULL);
> + g_queue_clear(queue);
> +}
> +#endif
> +
> +#if !GLIB_CHECK_VERSION(2,30,0)
> +static inline gboolean
> +g_queue_remove_boolean(GQueue *queue, gconstpointer data)
> +{
> + GList *link = g_queue_find(queue, data);
> + if (!link) {
> + return FALSE;
> + }
> + g_queue_unlink(queue, link);
> + return TRUE;
> +}
> +#define g_queue_remove g_queue_remove_boolean

glib changed the function ?

> +#endif
> +
> +#endif /* GLIB_COMPAT_H_ */
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server 02/12] Be consistent with opaque type

2016-10-18 Thread Pavel Grunt
On Tue, 2016-10-18 at 10:09 +0100, Frediano Ziglio wrote:
> vdi_port_read_buf_release is registered passing data as
> RedVDIReadBuf*, not RedPipeItem*. Cast opaque to proper
> pointer type to avoid the assumption that first field of
> RedVDIReadBuf is a RedPipeItem.
> 
> Signed-off-by: Frediano Ziglio 
Acked-by: Pavel Grunt 
> ---
>  server/reds.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/server/reds.c b/server/reds.c
> index 79f9c9e..a71029f 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -745,7 +745,8 @@ static void reds_agent_remove(RedsState *reds)
>  
>  static void vdi_port_read_buf_release(uint8_t *data, void *opaque)
>  {
> -red_pipe_item_unref((RedPipeItem *)opaque);
> +RedVDIReadBuf *read_buf = (RedVDIReadBuf *)opaque;
> +red_pipe_item_unref(_buf->base);
>  }
>  
>  /*
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] Remove Virgl status

2016-10-18 Thread Frediano Ziglio
Hi,
  has been a while since I posted a patchset on this.
One reason is that the feature set of the series is not changed.

Basically all pieces from DRM prime handling to VAAPI (hardware
encoding acceleration), forcing streaming and fallback to software
encoding are there.

The main concern about these patches are the status of some
implementation. The mainly hacks and fixes came from streaming.
The idea of the streaming code currently is recognizing and
optimizing video streaming done by virtual machine.
With Virgl (using host rendering which is the current target)
the streaming code is used continually so this part of code is
quite stressed. Basically when Virgl kicks in all display become
a big and continuous video.
This introduce some issues like the fact that if user interaction
stops the frame rate fall down to a 0 average causing some
computation problems.
The other big problems came introducing hardware acceleration
and DRM primes. Hardware accelerations means the use of different
encoders (VAAPI was chosen). The status of these encoders and
the gstreamer plugins (the part of code to use them) status is
not so optimal like software encoders (for instance there is the
lack for changing bit rate dynamically although supported by
VAAPI). Also our gstreamer support code needs specific settings
for every new encoders (for instance to support live streaming).
Another problem with hardware encoders is license issues which
could limit the usage and distribution of the required software;
this lead to having to support fallback to software encoders
to avoid blank screen.

As said above all these are implemented but with lot of hacks
and restrictions.

Reordering the patches and list of todos/bugs I realized that
the main issues came from streaming. For this reason I decided
to focus first of all on the streaming part. The first step
will be the implementation of a proper test as a unit test
for the encoding code checking for different aspect from
encoders, formats (at the beginning just different bitmap
formats, after DRM primes), clipping, bit rate handling.
This will help in the next step to add support for different
formats (DRM primes) and encoders (hardware ones).

Frediano
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server v4 0/4] Small updates to refactory patches

2016-10-18 Thread Frediano Ziglio
Added 2 fixup:
- revert some changes that can cause regressions;
- make compile if debug is enabled.

Frediano Ziglio (2):
  fixup! Improve MainChannel encapsulation
  fixup! Convert RedChannel hierarchy to GObject

Jonathon Jongsma (2):
  Improve MainChannel encapsulation
  Convert RedChannel hierarchy to GObject

 server/Makefile.am  |   2 +
 server/common-graphics-channel.c| 111 --
 server/common-graphics-channel.h|  42 ++-
 server/cursor-channel.c | 135 
 server/cursor-channel.h |  20 +-
 server/dcc-send.c   |  11 +-
 server/dcc.c|   1 +
 server/dcc.h|   2 +-
 server/display-channel-private.h|  76 +
 server/display-channel.c| 234 ++---
 server/display-channel.h| 100 ++
 server/dummy-channel-client.c   |  17 +-
 server/dummy-channel.c  |  49 +++
 server/dummy-channel.h  |  60 
 server/inputs-channel.c | 140 +---
 server/inputs-channel.h |  20 +-
 server/main-channel-client.c|  62 ++--
 server/main-channel-client.h|   5 +-
 server/main-channel.c   | 169 +++---
 server/main-channel.h   |  36 +-
 server/red-channel-client-private.h |  19 ++
 server/red-channel-client.c | 179 ++
 server/red-channel-client.h |   6 +-
 server/red-channel.c| 649 
 server/red-channel.h| 183 +-
 server/red-parse-qxl.h  |   2 +
 server/red-qxl.c|  21 +-
 server/red-replay-qxl.c |   2 +-
 server/red-worker.c |  27 +-
 server/red-worker.h |   2 -
 server/reds-private.h   |   3 +-
 server/reds.c   |  66 ++--
 server/smartcard.c  | 138 ++--
 server/sound.c  |  44 ++-
 server/spicevmc.c   | 450 +++--
 server/stream.c |   4 +-
 36 files changed, 2109 insertions(+), 978 deletions(-)
 create mode 100644 server/display-channel-private.h
 create mode 100644 server/dummy-channel.c
 create mode 100644 server/dummy-channel.h

-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server v4 2/4] fixup! Improve MainChannel encapsulation

2016-10-18 Thread Frediano Ziglio
Revert back spice_assert changes.
Pass success to main_channel_on_migrate_connected to avoid
changing check behaviour.

Signed-off-by: Frediano Ziglio 
---
 server/main-channel-client.c | 2 +-
 server/main-channel.c| 9 +
 server/main-channel.h| 3 ++-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 28d2839..f74de07 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -439,7 +439,7 @@ void 
main_channel_client_handle_migrate_connected(MainChannelClient *mcc,
 
 mcc->priv->mig_wait_connect = FALSE;
 mcc->priv->mig_connect_ok = success;
-main_channel_on_migrate_connected(main_channel, seamless && success);
+main_channel_on_migrate_connected(main_channel, success, seamless);
 } else {
 if (success) {
 spice_printerr("client %p MIGRATE_CANCEL", client);
diff --git a/server/main-channel.c b/server/main-channel.c
index 2d2783d..fe98b9d 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -420,13 +420,14 @@ int main_channel_migrate_src_complete(MainChannel 
*main_chan, int success)
return semi_seamless_count;
 }
 
-void main_channel_on_migrate_connected(MainChannel *main_channel, gboolean 
seamless)
+void main_channel_on_migrate_connected(MainChannel *main_channel,
+   gboolean success, gboolean seamless)
 {
-g_return_if_fail(main_channel->num_clients_mig_wait);
-g_warn_if_fail(!seamless || main_channel->num_clients_mig_wait == 1);
+spice_assert(main_channel->num_clients_mig_wait);
+spice_assert(!seamless || main_channel->num_clients_mig_wait == 1);
 if (!--main_channel->num_clients_mig_wait) {
 
reds_on_main_migrate_connected(red_channel_get_server(RED_CHANNEL(main_channel)),
-   seamless);
+   seamless && success);
 }
 }
 
diff --git a/server/main-channel.h b/server/main-channel.h
index 529e7be..4d0c070 100644
--- a/server/main-channel.h
+++ b/server/main-channel.h
@@ -81,6 +81,7 @@ void main_channel_migrate_cancel_wait(MainChannel *main_chan);
 const RedsMigSpice* main_channel_peek_migration_target(MainChannel *main_chan);
 /* returns the number of clients for which SPICE_MSG_MAIN_MIGRATE_END was 
sent*/
 int main_channel_migrate_src_complete(MainChannel *main_chan, int success);
-void main_channel_on_migrate_connected(MainChannel *main_channel, gboolean 
seamless);
+void main_channel_on_migrate_connected(MainChannel *main_channel,
+   gboolean success, gboolean seamless);
 
 #endif
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server v4 1/4] Improve MainChannel encapsulation

2016-10-18 Thread Frediano Ziglio
From: Jonathon Jongsma 

Encapsulate MainChannel a bit better in preparation for proting to
GObject.
---
 server/main-channel-client.c | 24 +++-
 server/main-channel.c| 15 +++
 server/main-channel.h|  2 ++
 3 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 0913028..28d2839 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -439,11 +439,7 @@ void 
main_channel_client_handle_migrate_connected(MainChannelClient *mcc,
 
 mcc->priv->mig_wait_connect = FALSE;
 mcc->priv->mig_connect_ok = success;
-spice_assert(main_channel->num_clients_mig_wait);
-spice_assert(!seamless || main_channel->num_clients_mig_wait == 1);
-if (!--main_channel->num_clients_mig_wait) {
-reds_on_main_migrate_connected(channel->reds, seamless && success);
-}
+main_channel_on_migrate_connected(main_channel, seamless && success);
 } else {
 if (success) {
 spice_printerr("client %p MIGRATE_CANCEL", client);
@@ -876,7 +872,7 @@ static void main_channel_marshall_notify(RedChannelClient 
*rcc,
 static void main_channel_fill_migrate_dst_info(MainChannel *main_channel,
SpiceMigrationDstInfo *dst_info)
 {
-RedsMigSpice *mig_dst = _channel->mig_target;
+const RedsMigSpice *mig_dst = 
main_channel_peek_migration_target(main_channel);
 dst_info->port = mig_dst->port;
 dst_info->sport = mig_dst->sport;
 dst_info->host_size = strlen(mig_dst->host) + 1;
@@ -935,17 +931,19 @@ static void 
main_channel_marshall_migrate_switch(SpiceMarshaller *m, RedChannelC
 RedChannel *channel = red_channel_client_get_channel(rcc);
 SpiceMsgMainMigrationSwitchHost migrate;
 MainChannel *main_ch;
+const RedsMigSpice *mig_target;
 
 spice_printerr("");
 red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST, 
item);
 main_ch = SPICE_CONTAINEROF(channel, MainChannel, base);
-migrate.port = main_ch->mig_target.port;
-migrate.sport = main_ch->mig_target.sport;
-migrate.host_size = strlen(main_ch->mig_target.host) + 1;
-migrate.host_data = (uint8_t *)main_ch->mig_target.host;
-if (main_ch->mig_target.cert_subject) {
-migrate.cert_subject_size = strlen(main_ch->mig_target.cert_subject) + 
1;
-migrate.cert_subject_data = (uint8_t 
*)main_ch->mig_target.cert_subject;
+mig_target = main_channel_peek_migration_target(main_ch);
+migrate.port = mig_target->port;
+migrate.sport = mig_target->sport;
+migrate.host_size = strlen(mig_target->host) + 1;
+migrate.host_data = (uint8_t *)mig_target->host;
+if (mig_target->cert_subject) {
+migrate.cert_subject_size = strlen(mig_target->cert_subject) + 1;
+migrate.cert_subject_data = (uint8_t *)mig_target->cert_subject;
 } else {
 migrate.cert_subject_size = 0;
 migrate.cert_subject_data = NULL;
diff --git a/server/main-channel.c b/server/main-channel.c
index a1b8e31..2d2783d 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -419,3 +419,18 @@ int main_channel_migrate_src_complete(MainChannel 
*main_chan, int success)
}
return semi_seamless_count;
 }
+
+void main_channel_on_migrate_connected(MainChannel *main_channel, gboolean 
seamless)
+{
+g_return_if_fail(main_channel->num_clients_mig_wait);
+g_warn_if_fail(!seamless || main_channel->num_clients_mig_wait == 1);
+if (!--main_channel->num_clients_mig_wait) {
+
reds_on_main_migrate_connected(red_channel_get_server(RED_CHANNEL(main_channel)),
+   seamless);
+}
+}
+
+const RedsMigSpice* main_channel_peek_migration_target(MainChannel *main_chan)
+{
+return _chan->mig_target;
+}
diff --git a/server/main-channel.h b/server/main-channel.h
index e0858d0..529e7be 100644
--- a/server/main-channel.h
+++ b/server/main-channel.h
@@ -78,7 +78,9 @@ void main_channel_migrate_switch(MainChannel *main_chan, 
RedsMigSpice *mig_targe
 int main_channel_migrate_connect(MainChannel *main_channel, RedsMigSpice 
*mig_target,
  int try_seamless);
 void main_channel_migrate_cancel_wait(MainChannel *main_chan);
+const RedsMigSpice* main_channel_peek_migration_target(MainChannel *main_chan);
 /* returns the number of clients for which SPICE_MSG_MAIN_MIGRATE_END was 
sent*/
 int main_channel_migrate_src_complete(MainChannel *main_chan, int success);
+void main_channel_on_migrate_connected(MainChannel *main_channel, gboolean 
seamless);
 
 #endif
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server v4 4/4] fixup! Convert RedChannel hierarchy to GObject

2016-10-18 Thread Frediano Ziglio
g_object_get require the object to be no-const.
Avoid compiler error if statistics are enabled

Signed-off-by: Frediano Ziglio 
---
 server/display-channel.c | 2 +-
 server/display-channel.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index 51d297c..b82af61 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -104,7 +104,7 @@ void display_channel_compress_stats_reset(DisplayChannel 
*display)
 image_encoder_shared_stat_reset(>priv->encoder_shared_data);
 }
 
-void display_channel_compress_stats_print(const DisplayChannel 
*display_channel)
+void display_channel_compress_stats_print(DisplayChannel *display_channel)
 {
 #ifdef COMPRESS_STAT
 uint32_t id;
diff --git a/server/display-channel.h b/server/display-channel.h
index 48b4105..d782969 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -231,7 +231,7 @@ void   display_channel_set_video_codecs 
 (DisplayCha
   GArray 
*video_codecs);
 intdisplay_channel_get_stream_video  
(DisplayChannel *display);
 intdisplay_channel_get_streams_timeout   
(DisplayChannel *display);
-void   display_channel_compress_stats_print  (const 
DisplayChannel *display);
+void   display_channel_compress_stats_print  
(DisplayChannel *display);
 void   display_channel_compress_stats_reset  
(DisplayChannel *display);
 void   display_channel_surface_unref 
(DisplayChannel *display,
   uint32_t 
surface_id);
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server 03/10] Avoid to typedef twice CursorChannel

2016-10-18 Thread Pavel Grunt
On Mon, 2016-10-17 at 14:26 +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio \
Acked-by: Pavel Grunt 
> ---
>  server/cursor-channel-client.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/server/cursor-channel-client.h b/server/cursor-channel-
> client.h
> index 2336b95..fab6837 100644
> --- a/server/cursor-channel-client.h
> +++ b/server/cursor-channel-client.h
> @@ -24,6 +24,7 @@
>  #include "red-common.h"
>  #include "red-channel-client.h"
>  #include "reds-stream.h"
> +#include "cursor-channel.h"
>  
>  G_BEGIN_DECLS
>  
> @@ -43,7 +44,6 @@ G_BEGIN_DECLS
>  typedef struct CursorChannelClient CursorChannelClient;
>  typedef struct CursorChannelClientClass CursorChannelClientClass;
>  typedef struct CursorChannelClientPrivate
> CursorChannelClientPrivate;
> -typedef struct CursorChannel CursorChannel;
>  
>  struct CursorChannelClient
>  {
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server 02/10] Include GLib compatibility header where needed

2016-10-18 Thread Pavel Grunt
My preference would be to squash with the first patch

On Mon, 2016-10-17 at 14:26 +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio 
Acked-by: Pavel Grunt 
> ---
>  server/char-device.c| 1 +
>  server/red-channel-client.c | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/server/char-device.c b/server/char-device.c
> index 4f01d3c..7775c07 100644
> --- a/server/char-device.c
> +++ b/server/char-device.c
> @@ -25,6 +25,7 @@
>  #include "char-device.h"
>  #include "red-channel.h"
>  #include "reds.h"
> +#include "glib-compat.h"
>  
>  #define CHAR_DEVICE_WRITE_TO_TIMEOUT 100
>  #define RED_CHAR_DEVICE_WAIT_TOKENS_TIMEOUT 3
> diff --git a/server/red-channel-client.c b/server/red-channel-
> client.c
> index 36d9c33..9426b13 100644
> --- a/server/red-channel-client.c
> +++ b/server/red-channel-client.c
> @@ -36,6 +36,7 @@
>  #include "red-channel-client.h"
>  #include "red-channel-client-private.h"
>  #include "red-channel.h"
> +#include "glib-compat.h"
>  
>  static const SpiceDataHeaderOpaque full_header_wrapper;
>  static const SpiceDataHeaderOpaque mini_header_wrapper;
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server] Remove unused InputsChannelPrivate typedef

2016-10-18 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/inputs-channel.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/server/inputs-channel.h b/server/inputs-channel.h
index 4bae61f..26569fa 100644
--- a/server/inputs-channel.h
+++ b/server/inputs-channel.h
@@ -41,7 +41,6 @@ G_BEGIN_DECLS
 
 typedef struct InputsChannel InputsChannel;
 typedef struct InputsChannelClass InputsChannelClass;
-typedef struct InputsChannelPrivate InputsChannelPrivate;
 
 GType inputs_channel_get_type(void) G_GNUC_CONST;
 
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 03/12] Remove warnings from reds_stat utility

2016-10-18 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 tools/reds_stat.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/reds_stat.c b/tools/reds_stat.c
index 9aca1ad..3e966d4 100644
--- a/tools/reds_stat.c
+++ b/tools/reds_stat.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define TAB_LEN 4
@@ -33,15 +34,14 @@
 static SpiceStat *reds_stat = (SpiceStat *)MAP_FAILED;
 static uint64_t *values = NULL;
 
-void print_stat_tree(int32_t node_index, int depth)
+static void print_stat_tree(int32_t node_index, int depth)
 {
 SpiceStatNode *node = _stat->nodes[node_index];
-int i;
 
 if ((node->flags & SPICE_STAT_NODE_MASK_SHOW) == 
SPICE_STAT_NODE_MASK_SHOW) {
 printf("%*s%s", depth * TAB_LEN, "", node->name);
 if (node->flags & SPICE_STAT_NODE_FLAG_VALUE) {
-printf(":%*s%llu (%llu)\n", (VALUE_TABS - depth) * TAB_LEN - 
strlen(node->name) - 1, "",
+printf(":%*s%"PRIu64" (%"PRIu64")\n", (int) ((VALUE_TABS - depth) 
* TAB_LEN - strlen(node->name) - 1), "",
node->value, node->value - values[node_index]);
 values[node_index] = node->value;
 } else {
@@ -60,7 +60,6 @@ int main(int argc, char **argv)
 {
 char *shm_name;
 pid_t kvm_pid;
-uint64_t *val;
 uint32_t num_of_nodes = 0;
 size_t shm_size;
 size_t shm_old_size;
@@ -98,7 +97,9 @@ int main(int argc, char **argv)
 goto error;
 }
 while (1) {
-system("clear");
+if (system("clear") != 0) {
+printf("\n\n\n");
+}
 printf("spice statistics\n\n");
 if (num_of_nodes != reds_stat->num_of_nodes) {
 num_of_nodes = reds_stat->num_of_nodes;
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 04/12] Add reds_stat to compiled software

2016-10-18 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
Acked-by: Christophe Fergeau 
---
 Makefile.am   |  2 +-
 configure.ac  |  1 +
 tools/Makefile.am | 19 +++
 3 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 tools/Makefile.am

diff --git a/Makefile.am b/Makefile.am
index 7eb0f28..5272d5a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
 NULL =
 ACLOCAL_AMFLAGS = -I m4
 
-SUBDIRS = spice-common server docs
+SUBDIRS = spice-common server docs tools
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = spice-server.pc
diff --git a/configure.ac b/configure.ac
index 483f18b..68aed15 100644
--- a/configure.ac
+++ b/configure.ac
@@ -272,6 +272,7 @@ server/spice-version.h
 server/tests/Makefile
 docs/Makefile
 docs/manual/Makefile
+tools/Makefile
 ])
 
 dnl ==
diff --git a/tools/Makefile.am b/tools/Makefile.am
new file mode 100644
index 000..03980c5
--- /dev/null
+++ b/tools/Makefile.am
@@ -0,0 +1,19 @@
+NULL =
+
+AM_CPPFLAGS = \
+   $(COMMON_CFLAGS) \
+   $(SPICE_PROTOCOL_CFLAGS) \
+   $(WARN_CFLAGS) \
+   $(NULL)
+
+AM_LDFLAGS = \
+   $(LIBRT) \
+   $(NULL)
+
+noinst_PROGRAMS = \
+   reds_stat \
+   $(NULL)
+
+reds_stat_SOURCES = \
+   reds_stat.c \
+   $(NULL)
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 11/12] Move monitors_config_ref inside red_monitors_config_item_new

2016-10-18 Thread Frediano Ziglio
Make move symmetric red_monitors_config_item_new and
red_monitors_config_item_free.

Signed-off-by: Frediano Ziglio 
---
 server/dcc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/dcc.c b/server/dcc.c
index 9bd1c0a..82a9f49 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -657,7 +657,7 @@ static RedMonitorsConfigItem 
*red_monitors_config_item_new(RedChannel* channel,
 RedMonitorsConfigItem *mci;
 
 mci = spice_new(RedMonitorsConfigItem, 1);
-mci->monitors_config = monitors_config;
+mci->monitors_config = monitors_config_ref(monitors_config);
 
 red_pipe_item_init_full(>pipe_item, 
RED_PIPE_ITEM_TYPE_MONITORS_CONFIG,
 red_monitors_config_item_free);
@@ -681,7 +681,7 @@ void dcc_push_monitors_config(DisplayChannelClient *dcc)
 }
 
 mci = 
red_monitors_config_item_new(red_channel_client_get_channel(RED_CHANNEL_CLIENT(dcc)),
-   
monitors_config_ref(dc->priv->monitors_config));
+   monitors_config);
 red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), >pipe_item);
 red_channel_client_push(RED_CHANNEL_CLIENT(dcc));
 }
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 01/12] Remove red_pipe_add_verb family function

2016-10-18 Thread Frediano Ziglio
These functions were implementing the same stuff as empty
messages functions provided by RedChannel so reuse them.

The implementation seems a bit different but the result
is the same. Specifically:
- RedEmptyMsgPipeItem::msg is int while RedVerbItem::verb was
  uint16_t however this data goes into the message type which
  is uint16_t (a 16 bit on the network protocol);
- red_channel_client_send_empty_msg calls
  red_channel_client_begin_send_message while red_marshall_verb
  not. However cursor_channel_send_item and dcc_send_item call
  red_channel_client_begin_send_message always after calling
  red_marshall_verb and dcc_send_item calls.
  You can be mistaken in dcc_send_item by
  red_channel_client_send_message_pending check however this is
  false only if during a marshalling a cache notify was added
  which does not happen for red_marshall_verb;
- when a PipeItem is created red_channel_client_pipe_add_empty_msg
  calls red_channel_client_push while red_pipe_add_verb does not.
  This actually make very few difference as this kind of item are
  never removed from the queue and a push is forced in every case
  running the event handler for the stream watch (see
  prepare_pipe_add and red_channel_client_event).

Signed-off-by: Frediano Ziglio 
---
 server/common-graphics-channel.h | 34 +-
 server/cursor-channel.c  |  5 +
 server/dcc-send.c|  3 ---
 server/dcc.c |  2 +-
 server/display-channel.c |  2 +-
 server/red-worker.c  |  4 ++--
 6 files changed, 6 insertions(+), 44 deletions(-)

diff --git a/server/common-graphics-channel.h b/server/common-graphics-channel.h
index 97cd63b..2a03414 100644
--- a/server/common-graphics-channel.h
+++ b/server/common-graphics-channel.h
@@ -39,43 +39,11 @@ gboolean 
common_graphics_channel_get_during_target_migrate(CommonGraphicsChannel
 QXLInstance* common_graphics_channel_get_qxl(CommonGraphicsChannel *self);
 
 enum {
-RED_PIPE_ITEM_TYPE_VERB = RED_PIPE_ITEM_TYPE_CHANNEL_BASE,
-RED_PIPE_ITEM_TYPE_INVAL_ONE,
+RED_PIPE_ITEM_TYPE_INVAL_ONE = RED_PIPE_ITEM_TYPE_CHANNEL_BASE,
 
 RED_PIPE_ITEM_TYPE_COMMON_LAST
 };
 
-typedef struct RedVerbItem {
-RedPipeItem base;
-uint16_t verb;
-} RedVerbItem;
-
-static inline void red_marshall_verb(RedChannelClient *rcc, RedVerbItem *item)
-{
-red_channel_client_init_send_data(rcc, item->verb, NULL);
-}
-
-static inline void red_pipe_add_verb(RedChannelClient* rcc, uint16_t verb)
-{
-RedVerbItem *item = spice_new(RedVerbItem, 1);
-
-red_pipe_item_init(>base, RED_PIPE_ITEM_TYPE_VERB);
-item->verb = verb;
-red_channel_client_pipe_add(rcc, >base);
-}
-
-static inline void red_pipe_add_verb_proxy(RedChannelClient *rcc, gpointer 
data)
-{
-uint16_t verb = GPOINTER_TO_UINT(data);
-red_pipe_add_verb(rcc, verb);
-}
-
-
-static inline void red_pipes_add_verb(RedChannel *channel, uint16_t verb)
-{
-red_channel_apply_clients_data(channel, red_pipe_add_verb_proxy, 
GUINT_TO_POINTER(verb));
-}
-
 CommonGraphicsChannel* common_graphics_channel_new(RedsState *server,
QXLInstance *qxl,
const 
SpiceCoreInterfaceInternal *core,
diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index 28a6d54..7df8763 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -292,9 +292,6 @@ static void cursor_channel_send_item(RedChannelClient *rcc, 
RedPipeItem *pipe_it
 case RED_PIPE_ITEM_TYPE_INVAL_ONE:
 red_marshall_inval(rcc, m, SPICE_CONTAINEROF(pipe_item, RedCacheItem, 
u.pipe_data));
 break;
-case RED_PIPE_ITEM_TYPE_VERB:
-red_marshall_verb(rcc, SPICE_UPCAST(RedVerbItem, pipe_item));
-break;
 case RED_PIPE_ITEM_TYPE_CURSOR_INIT:
 cursor_channel_client_reset_cursor_cache(rcc);
 red_marshall_cursor_init(ccc, m, pipe_item);
@@ -392,7 +389,7 @@ void cursor_channel_reset(CursorChannel *cursor)
 if (red_channel_is_connected(channel)) {
 red_channel_pipes_add_type(channel, 
RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
 if 
(!common_graphics_channel_get_during_target_migrate(COMMON_GRAPHICS_CHANNEL(cursor)))
 {
-red_pipes_add_verb(channel, SPICE_MSG_CURSOR_RESET);
+red_channel_pipes_add_empty_msg(channel, SPICE_MSG_CURSOR_RESET);
 }
 if (!red_channel_wait_all_sent(>common.base,
COMMON_CLIENT_TIMEOUT)) {
diff --git a/server/dcc-send.c b/server/dcc-send.c
index e33f428..36521f0 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -2398,9 +2398,6 @@ void dcc_send_item(RedChannelClient *rcc, RedPipeItem 
*pipe_item)
 case RED_PIPE_ITEM_TYPE_UPGRADE:
 marshall_upgrade(rcc, m, SPICE_UPCAST(RedUpgradeItem, pipe_item));
 break;
-case RED_PIPE_ITEM_TYPE_VERB:
-red_marshall_verb(rcc, 

[Spice-devel] [PATCH spice-server 00/12] Miscellaneous patches

2016-10-18 Thread Frediano Ziglio
Frediano Ziglio (12):
  Remove red_pipe_add_verb family function
  Be consistent with opaque type
  Remove warnings from reds_stat utility
  Add reds_stat to compiled software
  Make QXLMessage handling safe
  Reuse SPICE_N_ELEMENTS macro
  Make compression image declarations more similar
  Do not declare image_encoders_compress_lz4 if LZ4 is not available
  Fix typo in comment
  dcc: Use spice_new instead of spice_malloc
  Move monitors_config_ref inside red_monitors_config_item_new
  Declare same enumerator in a single header

 Makefile.am  |  2 +-
 configure.ac |  1 +
 server/common-graphics-channel.h | 34 +-
 server/cursor-channel-client.c   |  6 --
 server/cursor-channel-client.h   |  6 ++
 server/cursor-channel.c  | 11 +--
 server/dcc-send.c|  3 ---
 server/dcc.c | 10 +-
 server/display-channel.c |  2 +-
 server/image-encoders.h  | 11 ++-
 server/memslot.c | 14 ++
 server/memslot.h |  3 +++
 server/red-channel.h |  2 +-
 server/red-parse-qxl.c   | 11 +++
 server/red-parse-qxl.h   |  1 +
 server/red-worker.c  | 11 +--
 server/reds.c|  3 ++-
 tools/Makefile.am| 19 +++
 tools/reds_stat.c| 11 ++-
 19 files changed, 84 insertions(+), 77 deletions(-)
 create mode 100644 tools/Makefile.am

-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 10/12] dcc: Use spice_new instead of spice_malloc

2016-10-18 Thread Frediano Ziglio
spice_new return directly the correct type.

Signed-off-by: Frediano Ziglio 
---
 server/dcc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/dcc.c b/server/dcc.c
index 45ba81b..9bd1c0a 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -176,7 +176,7 @@ static RedSurfaceCreateItem 
*red_surface_create_item_new(RedChannel* channel,
 {
 RedSurfaceCreateItem *create;
 
-create = spice_malloc(sizeof(RedSurfaceCreateItem));
+create = spice_new(RedSurfaceCreateItem, 1);
 
 create->surface_create.surface_id = surface_id;
 create->surface_create.width = width;
@@ -691,7 +691,7 @@ static RedSurfaceDestroyItem 
*red_surface_destroy_item_new(RedChannel *channel,
 {
 RedSurfaceDestroyItem *destroy;
 
-destroy = spice_malloc(sizeof(RedSurfaceDestroyItem));
+destroy = spice_new(RedSurfaceDestroyItem, 1);
 destroy->surface_destroy.surface_id = surface_id;
 red_pipe_item_init(>pipe_item, 
RED_PIPE_ITEM_TYPE_DESTROY_SURFACE);
 
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 06/12] Reuse SPICE_N_ELEMENTS macro

2016-10-18 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/red-worker.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/red-worker.c b/server/red-worker.c
index 3784261..f3b8c4b 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -407,11 +407,11 @@ static void guest_set_client_capabilities(RedWorker 
*worker)
 red_qxl_set_client_capabilities(worker->qxl, FALSE, caps);
 } else {
 // Take least common denominator
-for (i = 0 ; i < sizeof(caps_available) / sizeof(caps_available[0]); 
++i) {
+for (i = 0 ; i < SPICE_N_ELEMENTS(caps_available); ++i) {
 SET_CAP(caps, caps_available[i]);
 }
 FOREACH_CLIENT(worker->display_channel, iter, rcc) {
-for (i = 0 ; i < sizeof(caps_available) / 
sizeof(caps_available[0]); ++i) {
+for (i = 0 ; i < SPICE_N_ELEMENTS(caps_available); ++i) {
 if (!red_channel_client_test_remote_cap(rcc, 
caps_available[i]))
 CLEAR_CAP(caps, caps_available[i]);
 }
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 12/12] Declare same enumerator in a single header

2016-10-18 Thread Frediano Ziglio
Avoid having duplication and desynchronisation.

Signed-off-by: Frediano Ziglio 
---
 server/cursor-channel-client.c | 6 --
 server/cursor-channel-client.h | 6 ++
 server/cursor-channel.c| 6 --
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/server/cursor-channel-client.c b/server/cursor-channel-client.c
index b7ab2e5..56efd1e 100644
--- a/server/cursor-channel-client.c
+++ b/server/cursor-channel-client.c
@@ -35,12 +35,6 @@
 #define CURSOR_CACHE_HASH_KEY(id) ((id) & CURSOR_CACHE_HASH_MASK)
 #define CURSOR_CLIENT_TIMEOUT 300ULL //nano
 
-enum {
-RED_PIPE_ITEM_TYPE_CURSOR = RED_PIPE_ITEM_TYPE_COMMON_LAST,
-RED_PIPE_ITEM_TYPE_CURSOR_INIT,
-RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE,
-};
-
 G_DEFINE_TYPE(CursorChannelClient, cursor_channel_client, 
RED_TYPE_CHANNEL_CLIENT)
 
 #define CURSOR_CHANNEL_CLIENT_PRIVATE(o) \
diff --git a/server/cursor-channel-client.h b/server/cursor-channel-client.h
index fab6837..d1dd31d 100644
--- a/server/cursor-channel-client.h
+++ b/server/cursor-channel-client.h
@@ -72,6 +72,12 @@ void cursor_channel_client_on_disconnect(RedChannelClient 
*rcc);
 RedCacheItem* cursor_channel_client_cache_find(CursorChannelClient *ccc, 
uint64_t id);
 int cursor_channel_client_cache_add(CursorChannelClient *ccc, uint64_t id, 
size_t size);
 
+enum {
+RED_PIPE_ITEM_TYPE_CURSOR = RED_PIPE_ITEM_TYPE_COMMON_LAST,
+RED_PIPE_ITEM_TYPE_CURSOR_INIT,
+RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE,
+};
+
 G_END_DECLS
 
 #endif /* CURSOR_CHANNEL_CLIENT_H_ */
diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index 7df8763..9a31e94 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -30,12 +30,6 @@
 
 #define CURSOR_CHANNEL(channel) ((CursorChannel*)(channel))
 
-enum {
-RED_PIPE_ITEM_TYPE_CURSOR = RED_PIPE_ITEM_TYPE_COMMON_LAST,
-RED_PIPE_ITEM_TYPE_CURSOR_INIT,
-RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE,
-};
-
 typedef struct CursorItem {
 QXLInstance *qxl;
 int refs;
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 02/12] Be consistent with opaque type

2016-10-18 Thread Frediano Ziglio
vdi_port_read_buf_release is registered passing data as
RedVDIReadBuf*, not RedPipeItem*. Cast opaque to proper
pointer type to avoid the assumption that first field of
RedVDIReadBuf is a RedPipeItem.

Signed-off-by: Frediano Ziglio 
---
 server/reds.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/server/reds.c b/server/reds.c
index 79f9c9e..a71029f 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -745,7 +745,8 @@ static void reds_agent_remove(RedsState *reds)
 
 static void vdi_port_read_buf_release(uint8_t *data, void *opaque)
 {
-red_pipe_item_unref((RedPipeItem *)opaque);
+RedVDIReadBuf *read_buf = (RedVDIReadBuf *)opaque;
+red_pipe_item_unref(_buf->base);
 }
 
 /*
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 09/12] Fix typo in comment

2016-10-18 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/red-channel.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/red-channel.h b/server/red-channel.h
index 8818a04..5299646 100644
--- a/server/red-channel.h
+++ b/server/red-channel.h
@@ -358,7 +358,7 @@ struct RedClient {
 
 int disconnecting;
 /* Note that while semi-seamless migration is conducted by the main 
thread, seamless migration
- * involves all channels, and thus the related varaibles can be accessed 
from different
+ * involves all channels, and thus the related variables can be accessed 
from different
  * threads */
 int during_target_migrate; /* if seamless=TRUE, migration_target is turned 
off when all
   the clients received their migration data. 
Otherwise (semi-seamless),
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 08/12] Do not declare image_encoders_compress_lz4 if LZ4 is not available

2016-10-18 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/image-encoders.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/server/image-encoders.h b/server/image-encoders.h
index 6b4999e..a755bf3 100644
--- a/server/image-encoders.h
+++ b/server/image-encoders.h
@@ -202,8 +202,10 @@ int image_encoders_compress_lz(ImageEncoders *enc, 
SpiceImage *dest,
SpiceBitmap *src, compress_send_data_t* 
o_comp_data);
 int image_encoders_compress_jpeg(ImageEncoders *enc, SpiceImage *dest,
  SpiceBitmap *src, compress_send_data_t* 
o_comp_data);
+#ifdef USE_LZ4
 int image_encoders_compress_lz4(ImageEncoders *enc, SpiceImage *dest,
 SpiceBitmap *src, compress_send_data_t* 
o_comp_data);
+#endif
 int image_encoders_compress_glz(ImageEncoders *enc, SpiceImage *dest,
 SpiceBitmap *src,
 RedDrawable *red_drawable,
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 07/12] Make compression image declarations more similar

2016-10-18 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/image-encoders.h | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/server/image-encoders.h b/server/image-encoders.h
index 6542edd..6b4999e 100644
--- a/server/image-encoders.h
+++ b/server/image-encoders.h
@@ -198,15 +198,14 @@ typedef struct compress_send_data_t {
 
 int image_encoders_compress_quic(ImageEncoders *enc, SpiceImage *dest,
  SpiceBitmap *src, compress_send_data_t* 
o_comp_data);
-int image_encoders_compress_lz(ImageEncoders *enc,
-   SpiceImage *dest, SpiceBitmap *src,
-   compress_send_data_t* o_comp_data);
+int image_encoders_compress_lz(ImageEncoders *enc, SpiceImage *dest,
+   SpiceBitmap *src, compress_send_data_t* 
o_comp_data);
 int image_encoders_compress_jpeg(ImageEncoders *enc, SpiceImage *dest,
  SpiceBitmap *src, compress_send_data_t* 
o_comp_data);
 int image_encoders_compress_lz4(ImageEncoders *enc, SpiceImage *dest,
 SpiceBitmap *src, compress_send_data_t* 
o_comp_data);
-int image_encoders_compress_glz(ImageEncoders *enc,
-SpiceImage *dest, SpiceBitmap *src,
+int image_encoders_compress_glz(ImageEncoders *enc, SpiceImage *dest,
+SpiceBitmap *src,
 RedDrawable *red_drawable,
 GlzImageRetention *glz_retention,
 compress_send_data_t* o_comp_data,
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 1/2] Refactory Glz RedDrawable retention code

2016-10-18 Thread Frediano Ziglio
The code was quite complicated.
- a GlzEncDictImageContext was bound to a GlzDrawableInstanceItem
  (1-1 relation);
- multiple GlzDrawableInstanceItem were attached to RedGlzDrawable;
- multiple RedGlzDrawable (one for RedClient) were attached to Drawable
  using GlzImageRetention;
- OOM code require all Glz dictionary used by DisplayChannel to be locked
  at the same time;
- drawable count computation during OOM was not corrent in case of
  multiple clients;
- not clear why to call glz_retention_free_drawables or
  glz_retention_detach_drawables.

Now:
- a GlzEncDictImageContext is bound to a GlzDictItem (still 1-1 relation);
- multiple GlzDictItem are attached to a Drawable using GlzImageRetention;
- there is only a glz_retention_free to be called when the structure
  must be destroyed.

Implementation detail:
- red_drawable_unref returns a gboolean to indicate if the object
  was really freed;
- glz_drawable_count was removed as there are no more RedGlzDrawable;
- image_encoders_glz_encode_lock and image_encoders_glz_encode_unlock
  were removed and now the locking is handled entirely by ImageEncoders;
- instead of marking GlzDictItem/GlzDrawableInstanceItem changing
  has_drawable flag contexts are moved to a glz_orphans ring;
- code is smaller (100 lines less in image-encoders.c) and I hope easier
  to read.

Signed-off-by: Frediano Ziglio 
---
 server/display-channel.c |  57 +
 server/image-encoders.c  | 300 +++
 server/image-encoders.h  |  27 +++--
 server/red-worker.c  |   5 +-
 server/red-worker.h  |   2 +-
 5 files changed, 145 insertions(+), 246 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index 69edd35..9a56080 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1185,7 +1185,7 @@ void display_channel_free_glz_drawables(DisplayChannel 
*display)
 }
 }
 
-static bool free_one_drawable(DisplayChannel *display, int force_glz_free)
+static bool free_one_drawable(DisplayChannel *display)
 {
 RingItem *ring_item = ring_get_tail(>priv->current_list);
 Drawable *drawable;
@@ -1196,9 +1196,6 @@ static bool free_one_drawable(DisplayChannel *display, 
int force_glz_free)
 }
 
 drawable = SPICE_CONTAINEROF(ring_item, Drawable, list_link);
-if (force_glz_free) {
-glz_retention_free_drawables(>glz_retention);
-}
 drawable_draw(display, drawable);
 container = drawable->tree_item.base.container;
 
@@ -1210,37 +1207,47 @@ static bool free_one_drawable(DisplayChannel *display, 
int force_glz_free)
 void display_channel_current_flush(DisplayChannel *display, int surface_id)
 {
 while (!ring_is_empty(>priv->surfaces[surface_id].current_list)) {
-free_one_drawable(display, FALSE);
+free_one_drawable(display);
 }
 current_remove_all(display, surface_id);
 }
 
 void display_channel_free_some(DisplayChannel *display)
 {
-int n = 0;
+int left_to_free = RED_RELEASE_BUNCH_SIZE;
 DisplayChannelClient *dcc;
 GListIter iter;
 
-spice_debug("#draw=%d, #glz_draw=%d", display->priv->drawable_count,
-display->priv->encoder_shared_data.glz_drawable_count);
+/* As we are trying to release some memory as requested by guest driver
+ * loop througth Glz freeing drawables which have no corresponding Drawable
+ * as this will cause guest memory to be freed. */
+spice_debug("#draw=%d", display->priv->drawable_count);
 FOREACH_DCC(display, iter, dcc) {
 ImageEncoders *encoders = dcc_get_encoders(dcc);
 
-// encoding using the dictionary is prevented since the following 
operations might
-// change the dictionary
-if (image_encoders_glz_encode_lock(encoders)) {
-n = image_encoders_free_some_independent_glz_drawables(encoders);
-}
+left_to_free -= 
image_encoders_free_some_independent_glz_drawables(encoders, left_to_free);
 }
 
-while (!ring_is_empty(>priv->current_list) && n++ < 
RED_RELEASE_BUNCH_SIZE) {
-free_one_drawable(display, TRUE);
-}
+if (left_to_free > 0) {
+int saved_to_free = left_to_free;
 
-FOREACH_DCC(display, iter, dcc) {
-ImageEncoders *encoders = dcc_get_encoders(dcc);
+while (left_to_free > 0 && 
!ring_is_empty(>priv->current_list)) {
+free_one_drawable(display);
+--left_to_free;
+}
 
-image_encoders_glz_encode_unlock(encoders);
+/* We freed Drawables in the loop above but the underlaying 
RedDrawables
+ * could still be referenced by Glz so scan again the Glz for 
independent
+ * drawables. Note that there is a 1-to-1 relatioship between Drawable
+ * and RedDrawable so in theory there will be a maximum of 
saved_to_free
+ * RedDrawables to free. Use this limit in any case, this should not be
+ * a problem and will make sure we won't free more items that we are
+  

[Spice-devel] [PATCH spice-server 2/2] Add some debugging for GlzDictItem structure

2016-10-18 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/image-encoders.c | 27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/server/image-encoders.c b/server/image-encoders.c
index 951fe96..70eb24a 100644
--- a/server/image-encoders.c
+++ b/server/image-encoders.c
@@ -20,6 +20,7 @@
 #endif
 
 #include 
+#include 
 
 #include "image-encoders.h"
 #include "spice-bitmap-utils.h"
@@ -65,6 +66,23 @@ static void encoder_data_init(EncoderData *data);
 static void encoder_data_reset(EncoderData *data);
 static void image_encoders_release_glz(ImageEncoders *enc);
 
+#if GLZ_DEBUG
+static void glz_dict_item_check(GlzDictItem *glz_item)
+{
+spice_assert(glz_item);
+spice_assert(ring_item_is_linked(_item->glz_context_link));
+spice_assert(ring_item_is_linked(_item->retention_link));
+spice_assert(glz_item->enc);
+spice_assert(glz_item->red_drawable);
+if (ring_item_is_linked(_item->free_link)) {
+spice_assert(glz_item->dict_image_context == NULL);
+}
+}
+#else
+static inline void glz_dict_item_check(GlzDictItem *glz_item)
+{
+}
+#endif
 
 static SPICE_GNUC_NORETURN SPICE_GNUC_PRINTF(2, 3) void
 quic_usr_error(QuicUsrContext *usr, const char *fmt, ...)
@@ -370,6 +388,7 @@ static void glz_usr_free_image(GlzEncoderUsrContext *usr, 
GlzUsrImageContext *im
 GlzDictItem *glz_item = (GlzDictItem *)image;
 ImageEncoders *drawable_enc = glz_item->enc;
 ImageEncoders *this_enc = SPICE_CONTAINEROF(lz_data, ImageEncoders, 
glz_data);
+glz_dict_item_check(glz_item);
 glz_item->dict_image_context = NULL;
 if (this_enc == drawable_enc) {
 glz_context_free(glz_item);
@@ -385,6 +404,7 @@ static void glz_usr_free_image(GlzEncoderUsrContext *usr, 
GlzUsrImageContext *im
 ring_add_before(_item->free_link,
 _enc->glz_dict_items_to_free);
 pthread_mutex_unlock(_enc->glz_dict_items_to_free_lock);
+glz_dict_item_check(glz_item);
 }
 }
 
@@ -486,7 +506,7 @@ static gboolean glz_context_free(GlzDictItem *glz_item)
 {
 gboolean ret;
 
-spice_assert(glz_item);
+glz_dict_item_check(glz_item);
 
 ring_remove(_item->glz_context_link);
 ring_remove(_item->retention_link);
@@ -528,6 +548,7 @@ int 
image_encoders_free_some_independent_glz_drawables(ImageEncoders *enc, int m
 while (max_to_free > n
&& (ring_link = ring_get_head(>glz_orphans)) != NULL) {
 GlzDictItem *glz_item = SPICE_CONTAINEROF(ring_link, GlzDictItem, 
retention_link);
+glz_dict_item_check(glz_item);
 if (glz_context_free(glz_item)) {
 ++n;
 }
@@ -546,6 +567,7 @@ void 
image_encoders_free_glz_drawables_to_free(ImageEncoders* enc)
 pthread_mutex_lock(>glz_dict_items_to_free_lock);
 while ((ring_link = ring_get_head(>glz_dict_items_to_free))) {
 GlzDictItem * glz_item = SPICE_CONTAINEROF(ring_link, GlzDictItem, 
free_link);
+glz_dict_item_check(glz_item);
 glz_context_free(glz_item);
 }
 pthread_mutex_unlock(>glz_dict_items_to_free_lock);
@@ -566,6 +588,7 @@ void image_encoders_free_glz_drawables(ImageEncoders *enc)
 pthread_rwlock_wrlock(_dict->encode_lock);
 while ((ring_link = ring_get_head(>glz_dict_items))) {
 GlzDictItem *glz_item = SPICE_CONTAINEROF(ring_link, GlzDictItem, 
glz_context_link);
+glz_dict_item_check(glz_item);
 // no need to lock the to_free list, since we assured no other thread 
is encoding and
 // thus not other thread access the to_free list of the channel
 glz_context_free(glz_item);
@@ -581,6 +604,7 @@ void glz_retention_destroy(GlzImageRetention *retention)
 while ((head = ring_get_head(>ring)) != NULL) {
 GlzDictItem *glz_item = SPICE_CONTAINEROF(head, GlzDictItem, 
retention_link);
 
+glz_dict_item_check(glz_item);
 ring_remove(head);
 ring_add_before(head, _item->enc->glz_orphans);
 }
@@ -1091,6 +1115,7 @@ static GlzDictItem *get_glz_context(ImageEncoders *enc, 
RedDrawable *red_drawabl
 
 ring_add_before(>glz_context_link, >glz_dict_items);
 ring_add(_retention->ring, >retention_link);
+glz_dict_item_check(ret);
 return ret;
 }
 
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [client] gtk: Remove an obsolete comment

2016-10-18 Thread Francois Gouget
The GTK+ compatibility code has been gathered in a single file long ago.

Signed-off-by: Francois Gouget 
---

See commit c2356a71.

 src/spice-widget.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 06e332f..3ac0a7d 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -44,7 +44,6 @@
 #include "vncdisplaykeymap.h"
 #include "spice-grabsequence-priv.h"
 
-/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */
 
 /**
  * SECTION:spice-widget
-- 
2.9.3
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [client] gtk: Remove an obsolete comment

2016-10-18 Thread Frediano Ziglio
> 
> The GTK+ compatibility code has been gathered in a single file long ago.
> 

And I also think we removed support for Gtk2 too

Frediano

> Signed-off-by: Francois Gouget 
> ---
> 
> See commit c2356a71.
> 
>  src/spice-widget.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index 06e332f..3ac0a7d 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -44,7 +44,6 @@
>  #include "vncdisplaykeymap.h"
>  #include "spice-grabsequence-priv.h"
>  
> -/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */
>  
>  /**
>   * SECTION:spice-widget
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-common 2/2] Add protocol documentation for "channel" and "protocol"

2016-10-18 Thread Victor Toso
Hi,

On Tue, Oct 18, 2016 at 10:20:44AM +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio 

Acked-by: Victor Toso 
both patches

> ---
>  docs/spice_protocol.txt | 46 +-
>  1 file changed, 45 insertions(+), 1 deletion(-)
> 
> diff --git a/docs/spice_protocol.txt b/docs/spice_protocol.txt
> index 892872d..e982d26 100644
> --- a/docs/spice_protocol.txt
> +++ b/docs/spice_protocol.txt
> @@ -220,7 +220,51 @@ Example:
>  Channels
>  
>  
> -TODO
> +channel ::= "channel"  [ ":"  ] "{" 
>  "}"  ";" ;
> +channel_messages ::= 
> | ;
> +channel_message ::= "server:" | "client:" | "message"  [ "=" 
>  ] ;
> +
> +Example:
> +
> +channel ExampleChannel {
> +server:
> +   message {
> +  uint32 dummy;
> +   } Dummy;
> +};
> +
> +Note that every message is associated with a number which is used in the 
> protocol.
> +The assignment work in a similar way to enumeration in C beside first 
> message is
> +assigned 1 value and not 0. So first message (if no integer is specified) is 
> assigned
> +1, second 2 and so on.
> +
> +`server:` or `client:` specify the direction of messages following, `server` 
> specify
> +messages from server while `client` from client. If not specified is assumed 
> from
> +server.
> +
> +For each channel you can specify a parent channel. Derived channel inherite 
> all
> +messages specified in the parent.
> +Note that messages from parent can be overrided by derived channels.
> +
> +Protocol
> +
> +
> +protocol ::= "protocol"  "{"  "}" ";" ;
> +protocol_channels ::= 
> | ;
> +protocol_channel ::=   [ "="  ] ";" ;
> +
> +Example:
> +
> +protocol Example {
> +ExampleChannel first = 1001;
> +};
> +
> +Protocol specify the list of channel supported. Channel have an associated 
> number
> +assigned in a similar way of channels (incremented from one to the next with
> +first starting from 0 if not specified).
> +
> +*NOTE*: Due to the way currently code is generate you should use
> +small numbers.
>  
>  Attributes
>  --
> -- 
> 2.7.4
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] Remove Virgl status

2016-10-18 Thread Victor Toso
Hi,

On Tue, Oct 18, 2016 at 06:07:50AM -0400, Frediano Ziglio wrote:
> Hi,
>   has been a while since I posted a patchset on this.
> One reason is that the feature set of the series is not changed.
>
> Basically all pieces from DRM prime handling to VAAPI (hardware
> encoding acceleration), forcing streaming and fallback to software
> encoding are there.
>
> The main concern about these patches are the status of some
> implementation. The mainly hacks and fixes came from streaming.
> The idea of the streaming code currently is recognizing and
> optimizing video streaming done by virtual machine.
> With Virgl (using host rendering which is the current target)
> the streaming code is used continually so this part of code is
> quite stressed. Basically when Virgl kicks in all display become
> a big and continuous video.

Indeed. I wonder if we should drop the sized-stream code/messages when
we have this code in.

> This introduce some issues like the fact that if user interaction
> stops the frame rate fall down to a 0 average causing some
> computation problems.

In Spice streaming code or in GStreamer's pipeline (the actual
encoding) ?

> The other big problems came introducing hardware acceleration
> and DRM primes. Hardware accelerations means the use of different
> encoders (VAAPI was chosen). The status of these encoders and
> the gstreamer plugins (the part of code to use them) status is
> not so optimal like software encoders (for instance there is the
> lack for changing bit rate dynamically although supported by
> VAAPI). Also our gstreamer support code needs specific settings
> for every new encoders (for instance to support live streaming).
> Another problem with hardware encoders is license issues which
> could limit the usage and distribution of the required software;
> this lead to having to support fallback to software encoders
> to avoid blank screen.
>
> As said above all these are implemented but with lot of hacks
> and restrictions.

If one wants to play with the latest virgl branch, which one is it?
I'm guessing virgl2 at:

https://cgit.freedesktop.org/~fziglio/spice-server/refs/heads

>
> Reordering the patches and list of todos/bugs I realized that
> the main issues came from streaming. For this reason I decided
> to focus first of all on the streaming part. The first step
> will be the implementation of a proper test as a unit test
> for the encoding code checking for different aspect from
> encoders, formats (at the beginning just different bitmap
> formats, after DRM primes), clipping, bit rate handling.
> This will help in the next step to add support for different
> formats (DRM primes) and encoders (hardware ones).
>
> Frediano

Step by step, great work :)
  toso


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [spice-protocol v1] enums: Move auto generated SpiceDataCompressionType

2016-10-18 Thread Victor Toso
From: Victor Toso 

This header is auto generated from spice_codegen.py tool in
spice-common repository and thus, it changes what was included
manually.

Move SpiceDataCompressionType struct to comply with spice_codegen.py.
This header was generated with:

 ./spice_codegen.py -e spice.proto ../spice-protocol/spice/enums.h

Signed-off-by: Victor Toso 
---
 spice/enums.h | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/spice/enums.h b/spice/enums.h
index 1d0c2db..743a4a8 100644
--- a/spice/enums.h
+++ b/spice/enums.h
@@ -106,13 +106,6 @@ typedef enum SpiceMouseMode {
 SPICE_MOUSE_MODE_MASK = 0x3
 } SpiceMouseMode;
 
-typedef enum SpiceDataCompressionType {
-SPICE_DATA_COMPRESSION_TYPE_NONE,
-SPICE_DATA_COMPRESSION_TYPE_LZ4,
-
-SPICE_DATA_COMPRESSION_TYPE_ENUM_END
-} SpiceDataCompressionType;
-
 typedef enum SpicePubkeyType {
 SPICE_PUBKEY_TYPE_INVALID,
 SPICE_PUBKEY_TYPE_RSA,
@@ -128,6 +121,13 @@ typedef enum SpicePubkeyType {
 SPICE_PUBKEY_TYPE_ENUM_END
 } SpicePubkeyType;
 
+typedef enum SpiceDataCompressionType {
+SPICE_DATA_COMPRESSION_TYPE_NONE,
+SPICE_DATA_COMPRESSION_TYPE_LZ4,
+
+SPICE_DATA_COMPRESSION_TYPE_ENUM_END
+} SpiceDataCompressionType;
+
 typedef enum SpiceClipType {
 SPICE_CLIP_TYPE_NONE,
 SPICE_CLIP_TYPE_RECTS,
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH v4] !fixup Improve MainChannel encapsulation

2016-10-18 Thread Jonathon Jongsma
---
Changes since v3:
 - change _peek_migration_target() to _get_migration_target()
 - add separate 'success' argument to _on_migrate_connected()
 - revert to using asserts


 server/main-channel-client.c |  6 +++---
 server/main-channel.c| 12 +++-
 server/main-channel.h|  4 ++--
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 28d2839..b47b1e0 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -439,7 +439,7 @@ void 
main_channel_client_handle_migrate_connected(MainChannelClient *mcc,
 
 mcc->priv->mig_wait_connect = FALSE;
 mcc->priv->mig_connect_ok = success;
-main_channel_on_migrate_connected(main_channel, seamless && success);
+main_channel_on_migrate_connected(main_channel, success, seamless);
 } else {
 if (success) {
 spice_printerr("client %p MIGRATE_CANCEL", client);
@@ -872,7 +872,7 @@ static void main_channel_marshall_notify(RedChannelClient 
*rcc,
 static void main_channel_fill_migrate_dst_info(MainChannel *main_channel,
SpiceMigrationDstInfo *dst_info)
 {
-const RedsMigSpice *mig_dst = 
main_channel_peek_migration_target(main_channel);
+const RedsMigSpice *mig_dst = 
main_channel_get_migration_target(main_channel);
 dst_info->port = mig_dst->port;
 dst_info->sport = mig_dst->sport;
 dst_info->host_size = strlen(mig_dst->host) + 1;
@@ -936,7 +936,7 @@ static void 
main_channel_marshall_migrate_switch(SpiceMarshaller *m, RedChannelC
 spice_printerr("");
 red_channel_client_init_send_data(rcc, SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST, 
item);
 main_ch = SPICE_CONTAINEROF(channel, MainChannel, base);
-mig_target = main_channel_peek_migration_target(main_ch);
+mig_target = main_channel_get_migration_target(main_ch);
 migrate.port = mig_target->port;
 migrate.sport = mig_target->sport;
 migrate.host_size = strlen(mig_target->host) + 1;
diff --git a/server/main-channel.c b/server/main-channel.c
index 2d2783d..0b90c32 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -420,17 +420,19 @@ int main_channel_migrate_src_complete(MainChannel 
*main_chan, int success)
return semi_seamless_count;
 }
 
-void main_channel_on_migrate_connected(MainChannel *main_channel, gboolean 
seamless)
+void main_channel_on_migrate_connected(MainChannel *main_channel,
+   gboolean success,
+   gboolean seamless)
 {
-g_return_if_fail(main_channel->num_clients_mig_wait);
-g_warn_if_fail(!seamless || main_channel->num_clients_mig_wait == 1);
+spice_assert(main_channel->num_clients_mig_wait);
+spice_assert(!seamless || main_channel->num_clients_mig_wait == 1);
 if (!--main_channel->num_clients_mig_wait) {
 
reds_on_main_migrate_connected(red_channel_get_server(RED_CHANNEL(main_channel)),
-   seamless);
+   seamless && success);
 }
 }
 
-const RedsMigSpice* main_channel_peek_migration_target(MainChannel *main_chan)
+const RedsMigSpice* main_channel_get_migration_target(MainChannel *main_chan)
 {
 return _chan->mig_target;
 }
diff --git a/server/main-channel.h b/server/main-channel.h
index 529e7be..99022c7 100644
--- a/server/main-channel.h
+++ b/server/main-channel.h
@@ -78,9 +78,9 @@ void main_channel_migrate_switch(MainChannel *main_chan, 
RedsMigSpice *mig_targe
 int main_channel_migrate_connect(MainChannel *main_channel, RedsMigSpice 
*mig_target,
  int try_seamless);
 void main_channel_migrate_cancel_wait(MainChannel *main_chan);
-const RedsMigSpice* main_channel_peek_migration_target(MainChannel *main_chan);
+const RedsMigSpice* main_channel_get_migration_target(MainChannel *main_chan);
 /* returns the number of clients for which SPICE_MSG_MAIN_MIGRATE_END was 
sent*/
 int main_channel_migrate_src_complete(MainChannel *main_chan, int success);
-void main_channel_on_migrate_connected(MainChannel *main_channel, gboolean 
seamless);
+void main_channel_on_migrate_connected(MainChannel *main_channel, gboolean 
success, gboolean seamless);
 
 #endif
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server v4 0/4] Small updates to refactory patches

2016-10-18 Thread Jonathon Jongsma
Ugh, I was catching up on email today and started responding to the v3
series before I noticed that you had sent a new version of this series
already today. So the patches/emails I just sent may be out-of-date.
Will start looking at these. Sorry.


On Tue, 2016-10-18 at 12:13 +0100, Frediano Ziglio wrote:
> Added 2 fixup:
> - revert some changes that can cause regressions;
> - make compile if debug is enabled.
> 
> Frediano Ziglio (2):
>   fixup! Improve MainChannel encapsulation
>   fixup! Convert RedChannel hierarchy to GObject
> 
> Jonathon Jongsma (2):
>   Improve MainChannel encapsulation
>   Convert RedChannel hierarchy to GObject
> 
>  server/Makefile.am  |   2 +
>  server/common-graphics-channel.c| 111 --
>  server/common-graphics-channel.h|  42 ++-
>  server/cursor-channel.c | 135 
>  server/cursor-channel.h |  20 +-
>  server/dcc-send.c   |  11 +-
>  server/dcc.c|   1 +
>  server/dcc.h|   2 +-
>  server/display-channel-private.h|  76 +
>  server/display-channel.c| 234 ++---
>  server/display-channel.h| 100 ++
>  server/dummy-channel-client.c   |  17 +-
>  server/dummy-channel.c  |  49 +++
>  server/dummy-channel.h  |  60 
>  server/inputs-channel.c | 140 +---
>  server/inputs-channel.h |  20 +-
>  server/main-channel-client.c|  62 ++--
>  server/main-channel-client.h|   5 +-
>  server/main-channel.c   | 169 +++---
>  server/main-channel.h   |  36 +-
>  server/red-channel-client-private.h |  19 ++
>  server/red-channel-client.c | 179 ++
>  server/red-channel-client.h |   6 +-
>  server/red-channel.c| 649 
> 
>  server/red-channel.h| 183 +-
>  server/red-parse-qxl.h  |   2 +
>  server/red-qxl.c|  21 +-
>  server/red-replay-qxl.c |   2 +-
>  server/red-worker.c |  27 +-
>  server/red-worker.h |   2 -
>  server/reds-private.h   |   3 +-
>  server/reds.c   |  66 ++--
>  server/smartcard.c  | 138 ++--
>  server/sound.c  |  44 ++-
>  server/spicevmc.c   | 450 +++--
>  server/stream.c |   4 +-
>  36 files changed, 2109 insertions(+), 978 deletions(-)
>  create mode 100644 server/display-channel-private.h
>  create mode 100644 server/dummy-channel.c
>  create mode 100644 server/dummy-channel.h
> 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server 01/10] Define a compatibility include for GLib

2016-10-18 Thread Francois Gouget
On Tue, 18 Oct 2016, Pavel Grunt wrote:
[...]
> > +#if !GLIB_CHECK_VERSION(2,30,0)
> > +static inline gboolean
> > +g_queue_remove_boolean(GQueue *queue, gconstpointer data)
> > +{
> > +   GList *link = g_queue_find(queue, data);
> > +   if (!link) {
> > +   return FALSE;
> > +   }
> > +   g_queue_unlink(queue, link);
> > +   return TRUE;
> > +}
> > +#define g_queue_remove g_queue_remove_boolean
> 
> glib changed the function ?

g_queue_remove() used to return void, thus causing a compilation error 
where we assigned / returned its value.


-- 
Francois Gouget 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server 01/10] Define a compatibility include for GLib

2016-10-18 Thread Pavel Grunt
On Tue, 2016-10-18 at 10:38 +0200, Francois Gouget wrote:
> On Tue, 18 Oct 2016, Pavel Grunt wrote:
> [...]
> > > +#if !GLIB_CHECK_VERSION(2,30,0)
> > > +static inline gboolean
> > > +g_queue_remove_boolean(GQueue *queue, gconstpointer data)
> > > +{
> > > + GList *link = g_queue_find(queue, data);
> > > + if (!link) {
> > > + return FALSE;
> > > + }
> > > + g_queue_unlink(queue, link);
> > > + return TRUE;
> > > +}
> > > +#define g_queue_remove g_queue_remove_boolean
> > 
> > glib changed the function ?
> 
> g_queue_remove() used to return void, thus causing a compilation
> error 
> where we assigned / returned its value.
> 
I see, I don't like these api changes.. Even worse without updating
the documentation for the function.

Ack for the patch

(I don't have a el6 machine where i could test these stuff)

Pavel
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server 01/10] Define a compatibility include for GLib

2016-10-18 Thread Frediano Ziglio
> 
> On Tue, 2016-10-18 at 10:38 +0200, Francois Gouget wrote:
> > On Tue, 18 Oct 2016, Pavel Grunt wrote:
> > [...]
> > > > +#if !GLIB_CHECK_VERSION(2,30,0)
> > > > +static inline gboolean
> > > > +g_queue_remove_boolean(GQueue *queue, gconstpointer data)
> > > > +{
> > > > +   GList *link = g_queue_find(queue, data);
> > > > +   if (!link) {
> > > > +   return FALSE;
> > > > +   }
> > > > +   g_queue_unlink(queue, link);
> > > > +   return TRUE;
> > > > +}
> > > > +#define g_queue_remove g_queue_remove_boolean
> > > 
> > > glib changed the function ?
> > 
> > g_queue_remove() used to return void, thus causing a compilation
> > error
> > where we assigned / returned its value.
> > 
> I see, I don't like these api changes.. Even worse without updating
> the documentation for the function.
> 
> Ack for the patch
> 
> (I don't have a el6 machine where i could test these stuff)
> 
> Pavel
> 

https://github.com/GNOME/glib/commit/f065d7d60e2b6110705b1b32f050ccad0bcde62f

Frediano
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-common 2/2] Add protocol documentation for "channel" and "protocol"

2016-10-18 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 docs/spice_protocol.txt | 46 +-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/docs/spice_protocol.txt b/docs/spice_protocol.txt
index 892872d..e982d26 100644
--- a/docs/spice_protocol.txt
+++ b/docs/spice_protocol.txt
@@ -220,7 +220,51 @@ Example:
 Channels
 
 
-TODO
+channel ::= "channel"  [ ":"  ] "{" 
 "}"  ";" ;
+channel_messages ::= | 
;
+channel_message ::= "server:" | "client:" | "message"  [ "=" 
 ] ;
+
+Example:
+
+channel ExampleChannel {
+server:
+   message {
+  uint32 dummy;
+   } Dummy;
+};
+
+Note that every message is associated with a number which is used in the 
protocol.
+The assignment work in a similar way to enumeration in C beside first message 
is
+assigned 1 value and not 0. So first message (if no integer is specified) is 
assigned
+1, second 2 and so on.
+
+`server:` or `client:` specify the direction of messages following, `server` 
specify
+messages from server while `client` from client. If not specified is assumed 
from
+server.
+
+For each channel you can specify a parent channel. Derived channel inherite all
+messages specified in the parent.
+Note that messages from parent can be overrided by derived channels.
+
+Protocol
+
+
+protocol ::= "protocol"  "{"  "}" ";" ;
+protocol_channels ::= 
| ;
+protocol_channel ::=   [ "="  ] ";" ;
+
+Example:
+
+protocol Example {
+ExampleChannel first = 1001;
+};
+
+Protocol specify the list of channel supported. Channel have an associated 
number
+assigned in a similar way of channels (incremented from one to the next with
+first starting from 0 if not specified).
+
+*NOTE*: Due to the way currently code is generate you should use
+small numbers.
 
 Attributes
 --
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-common 1/2] Fix BNF notation in documentation

2016-10-18 Thread Frediano Ziglio
Definition names have no angular brackets.

Signed-off-by: Frediano Ziglio 
---
 docs/spice_protocol.txt | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/docs/spice_protocol.txt b/docs/spice_protocol.txt
index 1d45b34..892872d 100644
--- a/docs/spice_protocol.txt
+++ b/docs/spice_protocol.txt
@@ -180,9 +180,9 @@ Structures
 The simpler coumpound type is the structure. As in C is defined as a list of 
fields (any variable or swicth).
 But as a protocol definition there are no alignment or padding and every field 
(beside pointer values) follow each other.
 
- ::= "struct"  "{" [  ] "}"  ";" ;
- ::= | ;
- ::= |
+struct ::= "struct"  "{" [  ] "}"  ";" ;
+fields ::= | ;
+field ::= |
 
 Example:
 
@@ -197,7 +197,7 @@ Messages
 Messages have the same syntax of structure (beside `message`) with the 
different that they can
 be used directly inside channels.
 
- ::= "message"  "{" [  ] "}"  ";" 
;
+message ::= "message"  "{" [  ] "}"  ";" ;
 
 Switches
 
@@ -209,7 +209,7 @@ Type definitions
 
 Like C type definition allow to short types defining new ones.
 
- ::= "typedef"  ` ;
+typedef ::= "typedef";
 
 note that unlike C name came before the type.
 
-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server v3 2/3] Improve MainChannel encapsulation

2016-10-18 Thread Jonathon Jongsma
On Mon, 2016-10-17 at 06:55 -0400, Frediano Ziglio wrote:
> > 
> 
> I just realized that beside spice_assert replacement this test is
> different.
> Not seamless is the old "seamless && success" condition so this is
> equivalent

Oh, good catch.

> to 
> 
> g_warn_if_fail(!(seamless && success) || main_channel-
> >num_clients_mig_wait == 1);
> 
> which is
> 
> g_warn_if_fail(!seamless || !success || main_channel-
> >num_clients_mig_wait == 1);
> 
> we should probably pass seamless and success.
> 
> Perhaps would be more easier to define a new enum like
> 
> enum {
> MIG_CONNECT_STANDARD,
> MIG_CONNECT_SEAMLESS,
> MIG_CONNECT_ERROR
> };
> 
> that group success and seamless.
> 
> Still convinced that changing spice_assert has nothing to do which
> this patch rationale.
> 

I'll leave the asserts for now.

Jonathon
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server v3 2/3] Improve MainChannel encapsulation

2016-10-18 Thread Frediano Ziglio
> 
> On Mon, 2016-10-17 at 06:55 -0400, Frediano Ziglio wrote:
> > > 
> > 
> > I just realized that beside spice_assert replacement this test is
> > different.
> > Not seamless is the old "seamless && success" condition so this is
> > equivalent
> 
> Oh, good catch.
> 
> > to
> > 
> > g_warn_if_fail(!(seamless && success) || main_channel-
> > >num_clients_mig_wait == 1);
> > 
> > which is
> > 
> > g_warn_if_fail(!seamless || !success || main_channel-
> > >num_clients_mig_wait == 1);
> > 
> > we should probably pass seamless and success.
> > 
> > Perhaps would be more easier to define a new enum like
> > 
> > enum {
> > MIG_CONNECT_STANDARD,
> > MIG_CONNECT_SEAMLESS,
> > MIG_CONNECT_ERROR
> > };
> > 
> > that group success and seamless.
> > 
> > Still convinced that changing spice_assert has nothing to do which
> > this patch rationale.
> > 
> 
> I'll leave the asserts for now.
> 
> Jonathon
> 

I posted a fixup to revert some behaviour

Frediano
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [spice-gtk] support for multiple shared directories

2016-10-18 Thread Visarion Alexandru
From: Visarion Alexandru 

This patch offers the alternative of supplying a list
of shared directories instead of a single shared
directory.

This new API does not break the old one, meant for a
single shared folder.

Visarion Alexandru (1):
  session: add multiple-shared-dirs property

 src/spice-session-priv.h |  2 ++
 src/spice-session.c  | 91 
 2 files changed, 93 insertions(+)

-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server v4 4/4] fixup! Convert RedChannel hierarchy to GObject

2016-10-18 Thread Jonathon Jongsma
Hmm, that's kind of annoying, but OK. 

Acked-by: Jonathon Jongsma 


On Tue, 2016-10-18 at 12:13 +0100, Frediano Ziglio wrote:
> g_object_get require the object to be no-const.
> Avoid compiler error if statistics are enabled
> 
> Signed-off-by: Frediano Ziglio 
> ---
>  server/display-channel.c | 2 +-
>  server/display-channel.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/server/display-channel.c b/server/display-channel.c
> index 51d297c..b82af61 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -104,7 +104,7 @@ void
> display_channel_compress_stats_reset(DisplayChannel *display)
>  image_encoder_shared_stat_reset(>priv-
> >encoder_shared_data);
>  }
>  
> -void display_channel_compress_stats_print(const DisplayChannel
> *display_channel)
> +void display_channel_compress_stats_print(DisplayChannel
> *display_channel)
>  {
>  #ifdef COMPRESS_STAT
>  uint32_t id;
> diff --git a/server/display-channel.h b/server/display-channel.h
> index 48b4105..d782969 100644
> --- a/server/display-channel.h
> +++ b/server/display-channel.h
> @@ -231,7 +231,7 @@
> void   display_channel_set_video_codecs  
> (DisplayCha
>  
>   GArray *video_codecs);
>  intdisplay_channel_get_stream_video 
>  (DisplayChannel *display);
>  intdisplay_channel_get_streams_timeout  
>  (DisplayChannel *display);
> -void   display_channel_compress_stats_print 
>  (const DisplayChannel *display);
> +void   display_channel_compress_stats_print 
>  (DisplayChannel *display);
>  void   display_channel_compress_stats_reset 
>  (DisplayChannel *display);
>  void   display_channel_surface_unref
>  (DisplayChannel *display,
>  
>   uint32_t surface_id);
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server v4 2/4] fixup! Improve MainChannel encapsulation

2016-10-18 Thread Jonathon Jongsma
This looks basically the same as the fixup patch that I just sent, but
mine also includes the change from _peek_ to _get_. Feel free to choose
this one or mine.

Jonathon


On Tue, 2016-10-18 at 12:13 +0100, Frediano Ziglio wrote:
> Revert back spice_assert changes.
> Pass success to main_channel_on_migrate_connected to avoid
> changing check behaviour.
> 
> Signed-off-by: Frediano Ziglio 
> ---
>  server/main-channel-client.c | 2 +-
>  server/main-channel.c| 9 +
>  server/main-channel.h| 3 ++-
>  3 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/server/main-channel-client.c b/server/main-channel-
> client.c
> index 28d2839..f74de07 100644
> --- a/server/main-channel-client.c
> +++ b/server/main-channel-client.c
> @@ -439,7 +439,7 @@ void
> main_channel_client_handle_migrate_connected(MainChannelClient *mcc,
>  
>  mcc->priv->mig_wait_connect = FALSE;
>  mcc->priv->mig_connect_ok = success;
> -main_channel_on_migrate_connected(main_channel, seamless &&
> success);
> +main_channel_on_migrate_connected(main_channel, success,
> seamless);
>  } else {
>  if (success) {
>  spice_printerr("client %p MIGRATE_CANCEL", client);
> diff --git a/server/main-channel.c b/server/main-channel.c
> index 2d2783d..fe98b9d 100644
> --- a/server/main-channel.c
> +++ b/server/main-channel.c
> @@ -420,13 +420,14 @@ int
> main_channel_migrate_src_complete(MainChannel *main_chan, int
> success)
> return semi_seamless_count;
>  }
>  
> -void main_channel_on_migrate_connected(MainChannel *main_channel,
> gboolean seamless)
> +void main_channel_on_migrate_connected(MainChannel *main_channel,
> +   gboolean success, gboolean
> seamless)
>  {
> -g_return_if_fail(main_channel->num_clients_mig_wait);
> -g_warn_if_fail(!seamless || main_channel-
> >num_clients_mig_wait == 1);
> +spice_assert(main_channel->num_clients_mig_wait);
> +spice_assert(!seamless || main_channel->num_clients_mig_wait 
> == 1);
>  if (!--main_channel->num_clients_mig_wait) {
>  reds_on_main_migrate_connected(red_channel_get_server(RE
> D_CHANNEL(main_channel)),
> -   seamless);
> +   seamless && success);
>  }
>  }
>  
> diff --git a/server/main-channel.h b/server/main-channel.h
> index 529e7be..4d0c070 100644
> --- a/server/main-channel.h
> +++ b/server/main-channel.h
> @@ -81,6 +81,7 @@ void main_channel_migrate_cancel_wait(MainChannel
> *main_chan);
>  const RedsMigSpice* main_channel_peek_migration_target(MainChannel
> *main_chan);
>  /* returns the number of clients for which
> SPICE_MSG_MAIN_MIGRATE_END was sent*/
>  int main_channel_migrate_src_complete(MainChannel *main_chan, int
> success);
> -void main_channel_on_migrate_connected(MainChannel *main_channel,
> gboolean seamless);
> +void main_channel_on_migrate_connected(MainChannel *main_channel,
> +   gboolean success, gboolean
> seamless);
>  
>  #endif
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server v3 2/3] Improve MainChannel encapsulation

2016-10-18 Thread Jonathon Jongsma
On Fri, 2016-10-14 at 10:49 -0400, Frediano Ziglio wrote:
> > 
> > From: Jonathon Jongsma 
> > 
> > Encapsulate MainChannel a bit better in preparation for proting to
> > GObject.
> 
> Small typo
> proting -> porting
> 

right

> > 
> > 
> > diff --git a/server/main-channel.h b/server/main-channel.h
> > index e0858d0..529e7be 100644
> > --- a/server/main-channel.h
> > +++ b/server/main-channel.h
> > @@ -78,7 +78,9 @@ void main_channel_migrate_switch(MainChannel
> > *main_chan,
> > RedsMigSpice *mig_targe
> >  int main_channel_migrate_connect(MainChannel *main_channel,
> > RedsMigSpice
> >  *mig_target,
> >   int try_seamless);
> >  void main_channel_migrate_cancel_wait(MainChannel *main_chan);
> > +const RedsMigSpice* main_channel_peek_migration_target(MainChannel
> > *main_chan);
> 
> Why not main_channel_get_migration_target ?
> Agreed with the const.

Yeah, I wanted to make it clear that the function doesn't transfer
ownership and the main channel still owns the returned object. But
there's not much precedent to using this terminology in spice server,
so it looks out-of-place. I'll change it to _get_

Jonathon
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [spice-gtk] session: add multiple-shared-dirs property

2016-10-18 Thread Visarion Alexandru
From: Visarion Alexandru 

Allow to specify a list of directories at runtime via
properties, which are symlinked in a per-session temporary,
shared directory.

https://bugs.freedesktop.org/show_bug.cgi?id=95255
---
 src/spice-session-priv.h |  2 ++
 src/spice-session.c  | 91 
 2 files changed, 93 insertions(+)

diff --git a/src/spice-session-priv.h b/src/spice-session-priv.h
index 049973a..013265b 100644
--- a/src/spice-session-priv.h
+++ b/src/spice-session-priv.h
@@ -88,6 +88,8 @@ guint32 spice_session_get_playback_latency(SpiceSession 
*session);
 void spice_session_sync_playback_latency(SpiceSession *session);
 const gchar* spice_session_get_shared_dir(SpiceSession *session);
 void spice_session_set_shared_dir(SpiceSession *session, const gchar *dir);
+GStrv spice_session_get_multiple_shared_dirs(SpiceSession *session);
+void spice_session_set_multiple_shared_dirs(SpiceSession *session, GStrv 
shared_directories);
 gboolean spice_session_get_audio_enabled(SpiceSession *session);
 gboolean spice_session_get_smartcard_enabled(SpiceSession *session);
 gboolean spice_session_get_usbredir_enabled(SpiceSession *session);
diff --git a/src/spice-session.c b/src/spice-session.c
index db283d4..82e1fda 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #ifdef G_OS_UNIX
 #include 
 #endif
@@ -60,6 +61,7 @@ struct _SpiceSessionPrivate {
 gboolean  read_only;
 SpiceURI  *proxy;
 gchar *shared_dir;
+GStrv multiple_shared_dirs;
 gboolean  share_dir_ro;
 
 /* whether to enable audio */
@@ -200,6 +202,7 @@ enum {
 PROP_PROXY,
 PROP_SECURE_CHANNELS,
 PROP_SHARED_DIR,
+PROP_MULTIPLE_SHARED_DIRS,
 PROP_SHARE_DIR_RO,
 PROP_USERNAME,
 PROP_UNIX_PATH,
@@ -369,6 +372,7 @@ spice_session_finalize(GObject *gobject)
 g_strfreev(s->disable_effects);
 g_strfreev(s->secure_channels);
 g_free(s->shared_dir);
+g_strfreev(s->multiple_shared_dirs);
 
 g_clear_pointer(>images, cache_free);
 glz_decoder_window_destroy(s->glz_window);
@@ -683,6 +687,9 @@ static void spice_session_get_property(GObject*gobject,
 case PROP_SHARED_DIR:
 g_value_set_string(value, spice_session_get_shared_dir(session));
 break;
+case PROP_MULTIPLE_SHARED_DIRS:
+g_value_set_boxed(value, 
spice_session_get_multiple_shared_dirs(session));
+break;
 case PROP_SHARE_DIR_RO:
 g_value_set_boolean(value, s->share_dir_ro);
 break;
@@ -822,6 +829,9 @@ static void spice_session_set_property(GObject  
*gobject,
 case PROP_SHARED_DIR:
 spice_session_set_shared_dir(session, g_value_get_string(value));
 break;
+case PROP_MULTIPLE_SHARED_DIRS:
+spice_session_set_multiple_shared_dirs(session, 
g_value_dup_boxed(value));
+break;
 case PROP_SHARE_DIR_RO:
 s->share_dir_ro = g_value_get_boolean(value);
 break;
@@ -1421,6 +1431,22 @@ static void spice_session_class_init(SpiceSessionClass 
*klass)
  G_PARAM_STATIC_STRINGS));
 
 /**
+ * SpiceSession:multiple-shared-dirs:
+ *
+ * Location of the shared directory
+ *
+ * Since: 0.24
+ **/
+g_object_class_install_property
+(gobject_class, PROP_MULTIPLE_SHARED_DIRS,
+ g_param_spec_boxed("multiple-shared-dirs",
+ "Multiple shared directories",
+ "Multiple shared directories",
+ G_TYPE_STRV,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+/**
  * SpiceSession:share-dir-ro:
  *
  * Whether to share the directory read-only.
@@ -2595,6 +2621,71 @@ void spice_session_set_shared_dir(SpiceSession *session, 
const gchar *dir)
 s->shared_dir = g_strdup(dir);
 }
 
+G_GNUC_INTERNAL
+GStrv spice_session_get_multiple_shared_dirs(SpiceSession *session)
+{
+g_return_val_if_fail(SPICE_IS_SESSION(session), NULL);
+
+SpiceSessionPrivate *s = session->priv;
+return s->multiple_shared_dirs;
+}
+
+G_GNUC_INTERNAL
+void spice_session_set_multiple_shared_dirs(SpiceSession *session, GStrv 
directories)
+{
+g_return_if_fail(SPICE_IS_SESSION(session));
+
+SpiceSessionPrivate *s = session->priv;
+g_strfreev(s->multiple_shared_dirs);
+
+gint i, mode = S_IRWXU;
+
+gchar *conf_dir_name = g_strconcat("shared_folders_",  
g_strdup_printf("%d", s->connection_id), NULL);
+gchar *conf_dir = g_build_filename(g_get_tmp_dir(), "spice", 
conf_dir_name, NULL);
+
+g_free(conf_dir_name);
+
+GDir *dir = g_dir_open(conf_dir, 0, NULL);
+
+if (dir != NULL) {
+// remove any old symlinks belonging to this session
+const gchar *link = g_dir_read_name(dir);
+
+while (link != NULL) {
+

Re: [Spice-devel] [spice-gtk] session: add multiple-shared-dirs property

2016-10-18 Thread Marc-André Lureau
Hi

- Original Message -
> From: Visarion Alexandru 
> 
> Allow to specify a list of directories at runtime via
> properties, which are symlinked in a per-session temporary,
> shared directory.
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=95255
> ---

I think I'd rather leave that up to the application, because it can be done 
with current API, and share-dir would conflict with multiple-shared-dir.


>  src/spice-session-priv.h |  2 ++
>  src/spice-session.c  | 91
>  
>  2 files changed, 93 insertions(+)
> 
> diff --git a/src/spice-session-priv.h b/src/spice-session-priv.h
> index 049973a..013265b 100644
> --- a/src/spice-session-priv.h
> +++ b/src/spice-session-priv.h
> @@ -88,6 +88,8 @@ guint32 spice_session_get_playback_latency(SpiceSession
> *session);
>  void spice_session_sync_playback_latency(SpiceSession *session);
>  const gchar* spice_session_get_shared_dir(SpiceSession *session);
>  void spice_session_set_shared_dir(SpiceSession *session, const gchar *dir);
> +GStrv spice_session_get_multiple_shared_dirs(SpiceSession *session);
> +void spice_session_set_multiple_shared_dirs(SpiceSession *session, GStrv
> shared_directories);
>  gboolean spice_session_get_audio_enabled(SpiceSession *session);
>  gboolean spice_session_get_smartcard_enabled(SpiceSession *session);
>  gboolean spice_session_get_usbredir_enabled(SpiceSession *session);
> diff --git a/src/spice-session.c b/src/spice-session.c
> index db283d4..82e1fda 100644
> --- a/src/spice-session.c
> +++ b/src/spice-session.c
> @@ -19,6 +19,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #ifdef G_OS_UNIX
>  #include 
>  #endif
> @@ -60,6 +61,7 @@ struct _SpiceSessionPrivate {
>  gboolean  read_only;
>  SpiceURI  *proxy;
>  gchar *shared_dir;
> +GStrv multiple_shared_dirs;
>  gboolean  share_dir_ro;
>  
>  /* whether to enable audio */
> @@ -200,6 +202,7 @@ enum {
>  PROP_PROXY,
>  PROP_SECURE_CHANNELS,
>  PROP_SHARED_DIR,
> +PROP_MULTIPLE_SHARED_DIRS,
>  PROP_SHARE_DIR_RO,
>  PROP_USERNAME,
>  PROP_UNIX_PATH,
> @@ -369,6 +372,7 @@ spice_session_finalize(GObject *gobject)
>  g_strfreev(s->disable_effects);
>  g_strfreev(s->secure_channels);
>  g_free(s->shared_dir);
> +g_strfreev(s->multiple_shared_dirs);
>  
>  g_clear_pointer(>images, cache_free);
>  glz_decoder_window_destroy(s->glz_window);
> @@ -683,6 +687,9 @@ static void spice_session_get_property(GObject
> *gobject,
>  case PROP_SHARED_DIR:
>  g_value_set_string(value, spice_session_get_shared_dir(session));
>  break;
> +case PROP_MULTIPLE_SHARED_DIRS:
> +g_value_set_boxed(value,
> spice_session_get_multiple_shared_dirs(session));
> +break;
>  case PROP_SHARE_DIR_RO:
>  g_value_set_boolean(value, s->share_dir_ro);
>  break;
> @@ -822,6 +829,9 @@ static void spice_session_set_property(GObject
> *gobject,
>  case PROP_SHARED_DIR:
>  spice_session_set_shared_dir(session, g_value_get_string(value));
>  break;
> +case PROP_MULTIPLE_SHARED_DIRS:
> +spice_session_set_multiple_shared_dirs(session,
> g_value_dup_boxed(value));
> +break;
>  case PROP_SHARE_DIR_RO:
>  s->share_dir_ro = g_value_get_boolean(value);
>  break;
> @@ -1421,6 +1431,22 @@ static void spice_session_class_init(SpiceSessionClass
> *klass)
>   G_PARAM_STATIC_STRINGS));
>  
>  /**
> + * SpiceSession:multiple-shared-dirs:
> + *
> + * Location of the shared directory
> + *
> + * Since: 0.24
> + **/
> +g_object_class_install_property
> +(gobject_class, PROP_MULTIPLE_SHARED_DIRS,
> + g_param_spec_boxed("multiple-shared-dirs",
> + "Multiple shared directories",
> + "Multiple shared directories",
> + G_TYPE_STRV,
> + G_PARAM_READWRITE |
> + G_PARAM_STATIC_STRINGS));
> +
> +/**
>   * SpiceSession:share-dir-ro:
>   *
>   * Whether to share the directory read-only.
> @@ -2595,6 +2621,71 @@ void spice_session_set_shared_dir(SpiceSession
> *session, const gchar *dir)
>  s->shared_dir = g_strdup(dir);
>  }
>  
> +G_GNUC_INTERNAL
> +GStrv spice_session_get_multiple_shared_dirs(SpiceSession *session)
> +{
> +g_return_val_if_fail(SPICE_IS_SESSION(session), NULL);
> +
> +SpiceSessionPrivate *s = session->priv;
> +return s->multiple_shared_dirs;
> +}
> +
> +G_GNUC_INTERNAL
> +void spice_session_set_multiple_shared_dirs(SpiceSession *session, GStrv
> directories)
> +{
> +g_return_if_fail(SPICE_IS_SESSION(session));
> +
> +SpiceSessionPrivate *s = session->priv;
> +g_strfreev(s->multiple_shared_dirs);
> +
> +gint i, mode = S_IRWXU;
> +
> +gchar 

[Spice-devel] [client 00/10] Deprecation warning cleanup

2016-10-18 Thread Francois Gouget

This is another take on trying to clean up the deprecation warning 
situation in Spice-Gtk.

Let me know if it goes in the right direction.


With this patchset deprecation warnings are enabled again and there are 
no remaining warnings, except those in src/controller since they happen 
in generated code and I don't know how to modify it so it does not use 
the deprecated GSimpleAsyncResult class (and I don't really want to do 
the conversion to GTask either). Of course those could also be avoided 
by keeping the -Wno-deprecated-declarations in src/controller but then 
nobody will fix that code.


Francois Gouget (10):
  build-sys: Enable deprecation warnings instead of ignoring them entirely

First the Spice-Gtk situation is different from the Spice server one.

In Spice server the only deprecated APIs we use are Spice's own. So new 
uses will only result from changes in Spice's code. Thus it's ok to have 
them produce an error to prevent their use from spreading.

In Spice-Gtk the deprecated APIs are almost all GTK APIs. Those can be 
deprecated at any time independently of Spice-Gtk's code. Thus we don't 
want deprecation warnings to break the build.

But so far they have be completely disabled, thus ensuring no one 
will ever fix them. So the first patch turns them back to regular 
warnings with -Wno-error.


  gtk: Avoid gtk_vbox_new(); it is deprecated
  gtk: Avoid gtk_hbutton_box_new(); it is deprecated
  gtk: GtkTable is deprecated so use GtkGrid instead

These patches just fix usage of some deprecated APIs. Fixes that would 
likely have happened not long after GTK+ 2.0 support was dropped if 
deprecation warnings had not been disabled. Those should clearly be 
applied even if we don't enable deprecation warnings.


  gtk: Ignore GLib's too-new warnings where we explicitly check its version

GLib also issues warnings for APIs that are more recent than 
GLIB_VERSION_MIN_REQUIRED. But these happen in suitable #if sections and 
thus should be ignored.


  build-sys: Remove SPICE_NO_DEPRECATED
  build-sys: Use spice-protocol's deprecation macros

This one may be somewhat questionable since it spice-protocol's macros 
don't use GLib's helpers and thus don't support Clang and Visual C++. 
This means we may locally disable these warnings with 
G_GNUC_BEGIN_IGNORE_DEPRECATIONS when they would not have in fact been 
issued at all.
* It's not like this issue would cause compilation errors or 
  warnings (the opposite) so maybe it should just be ignored.
* Or maybe it means Spice-Gtk should keep using its own deprecation
  macros, but it would be a bit of a shame that spice-protocol's macros 
  cannot even be reused by all Spice's codebase.
* Or maybe  spice-protocol should use GLib's macros if available, 
  even if it is a bit distasteful.


  session: Disable the spice_audio_new() deprecation warning

I donsider this to be a "false positive", although maybe the code should 
be rewritten to avoid it.


  RFC: gtk: Temporarily ignore the keyboard/mouse grabbing deprecation warnings
  RFC: spicy: Temporarily ignore deprecation warnings

These two really just silence warnings that should be fixed. So if 
someone fixes these warnings they will not be needed. Otherwise I think 
it's still better than globally disabling the deprecation warnings 
because these patches are local and add nice FIXME warnings in the 
relevant places.


 m4/spice-compile-warnings.m4 |  2 +-
 src/Makefile.am  |  1 -
 src/controller/Makefile.am   |  1 -
 src/spice-channel.h  |  5 +++--
 src/spice-gtk-session.c  |  5 +
 src/spice-session.c  |  2 ++
 src/spice-util.h | 14 +++---
 src/spice-widget-egl.c   |  3 +++
 src/spice-widget.c   | 30 ++
 src/spicy-connect.c  | 22 +++---
 src/spicy.c  |  3 +++
 src/usb-device-manager.h |  2 +-
 12 files changed, 62 insertions(+), 28 deletions(-)

-- 
2.9.3
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [client 07/10] build-sys: Use spice-protocol's deprecation macros

2016-10-18 Thread Francois Gouget
Signed-off-by: Francois Gouget 
---
 src/spice-channel.h  | 5 +++--
 src/spice-util.h | 2 --
 src/usb-device-manager.h | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/spice-channel.h b/src/spice-channel.h
index 3b0bffb..aa0d9cb 100644
--- a/src/spice-channel.h
+++ b/src/spice-channel.h
@@ -24,6 +24,7 @@
 
 #include 
 
+#include 
 #include "spice-types.h"
 #include "spice-glib-enums.h"
 #include "spice-util.h"
@@ -136,9 +137,9 @@ gboolean spice_channel_test_common_capability(SpiceChannel 
*channel, guint32 cap
 void spice_channel_flush_async(SpiceChannel *channel, GCancellable 
*cancellable, GAsyncReadyCallback callback, gpointer user_data);
 gboolean spice_channel_flush_finish(SpiceChannel *channel, GAsyncResult 
*result, GError **error);
 #ifndef SPICE_DISABLE_DEPRECATED
-SPICE_DEPRECATED
+SPICE_GNUC_DEPRECATED
 void spice_channel_set_capability(SpiceChannel *channel, guint32 cap);
-SPICE_DEPRECATED
+SPICE_GNUC_DEPRECATED
 void spice_channel_destroy(SpiceChannel *channel);
 #endif
 
diff --git a/src/spice-util.h b/src/spice-util.h
index a01da0c..a2a7683 100644
--- a/src/spice-util.h
+++ b/src/spice-util.h
@@ -50,8 +50,6 @@ gchar* spice_uuid_to_string(const guint8 uuid[16]);
 #endif /* __GNUC__ */
 #endif
 
-#define SPICE_DEPRECATED  G_GNUC_DEPRECATED
-
 G_END_DECLS
 
 #endif /* SPICE_UTIL_H */
diff --git a/src/usb-device-manager.h b/src/usb-device-manager.h
index 6a8d0ac..219fe44 100644
--- a/src/usb-device-manager.h
+++ b/src/usb-device-manager.h
@@ -131,7 +131,7 @@ gboolean spice_usb_device_manager_disconnect_device_finish(
 SpiceUsbDeviceManager *self, GAsyncResult *res, GError **err);
 
 #ifndef SPICE_DISABLE_DEPRECATED
-SPICE_DEPRECATED
+SPICE_GNUC_DEPRECATED
 void spice_usb_device_manager_disconnect_device(SpiceUsbDeviceManager *manager,
 SpiceUsbDevice *device);
 #endif
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [client 04/10] gtk: Avoid gtk_hbutton_box_new(); it is deprecated

2016-10-18 Thread Francois Gouget
Spice-Gtk requires GTK+ > 3.12 which has gtk_button_box_new().

Signed-off-by: Francois Gouget 
---
 src/spicy-connect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/spicy-connect.c b/src/spicy-connect.c
index a1d895a..915eb06 100644
--- a/src/spicy-connect.c
+++ b/src/spicy-connect.c
@@ -189,7 +189,7 @@ gboolean spicy_connect_dialog(SpiceSession *session)
 gtk_box_pack_start(recent_box, label, FALSE, TRUE, 0);
 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
 
-button_box = GTK_BOX(gtk_hbutton_box_new());
+button_box = GTK_BOX(gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL));
 gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_END);
 gtk_box_set_spacing(button_box, 5);
 gtk_container_set_border_width(GTK_CONTAINER(button_box), 5);
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [client 09/10] RFC: gtk: Temporarily ignore the keyboard/mouse grabbing deprecation warnings

2016-10-18 Thread Francois Gouget
Signed-off-by: Francois Gouget 
---
 src/spice-widget.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 82adacf..f0681d6 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -812,6 +812,9 @@ SpiceGrabSequence *spice_display_get_grab_keys(SpiceDisplay 
*display)
 return d->grabseq;
 }
 
+/* FIXME: gdk_keyboard_grab/ungrab() is deprecated */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
 static void try_keyboard_grab(SpiceDisplay *display)
 {
 GtkWidget *widget = GTK_WIDGET(display);
@@ -878,6 +881,8 @@ static void try_keyboard_ungrab(SpiceDisplay *display)
 d->keyboard_grab_active = false;
 g_signal_emit(widget, signals[SPICE_DISPLAY_KEYBOARD_GRAB], 0, false);
 }
+G_GNUC_END_IGNORE_DEPRECATIONS
+
 
 static void update_keyboard_grab(SpiceDisplay *display)
 {
@@ -1002,6 +1007,8 @@ static gboolean do_pointer_grab(SpiceDisplay *display)
  * what window the pointer is actally over, so use 'FALSE' for
  * 'owner_events' parameter
  */
+/* FIXME: gdk_pointer_grab() is deprecated */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 status = gdk_pointer_grab(window, FALSE,
  GDK_POINTER_MOTION_MASK |
  GDK_BUTTON_PRESS_MASK |
@@ -1011,6 +1018,7 @@ static gboolean do_pointer_grab(SpiceDisplay *display)
  NULL,
  blank,
  GDK_CURRENT_TIME);
+G_GNUC_END_IGNORE_DEPRECATIONS
 grab_successful = (status == GDK_GRAB_SUCCESS);
 if (!grab_successful) {
 d->mouse_grab_active = false;
@@ -1101,8 +1109,11 @@ static void mouse_wrap(SpiceDisplay *display, 
GdkEventMotion *motion)
 /* FIXME: we try our best to ignore that next pointer move event.. */
 gdk_display_sync(gdk_screen_get_display(screen));
 
+/* FIXME: gdk_display_warp_pointer() is deprecated */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 gdk_display_warp_pointer(gtk_widget_get_display(GTK_WIDGET(display)),
  screen, xr, yr);
+G_GNUC_END_IGNORE_DEPRECATIONS
 d->mouse_last_x = -1;
 d->mouse_last_y = -1;
 }
@@ -1110,6 +1121,9 @@ static void mouse_wrap(SpiceDisplay *display, 
GdkEventMotion *motion)
 
 }
 
+/* FIXME: gdk_pointer_ungrab()/gdk_display_warp_pointer() are deprecated */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
 static void try_mouse_ungrab(SpiceDisplay *display)
 {
 SpiceDisplayPrivate *d = display->priv;
@@ -1142,6 +1156,7 @@ static void try_mouse_ungrab(SpiceDisplay *display)
 g_signal_emit(display, signals[SPICE_DISPLAY_MOUSE_GRAB], 0, false);
 spice_gtk_session_set_pointer_grabbed(d->gtk_session, false);
 }
+G_GNUC_END_IGNORE_DEPRECATIONS
 
 static void update_mouse_grab(SpiceDisplay *display)
 {
@@ -1985,7 +2000,10 @@ static gboolean button_event(GtkWidget *widget, 
GdkEventButton *button)
FIXME: should be multiple widget grab, but how?
or should know the position of the other widgets?
 */
+/* FIXME: gdk_pointer_ungrab() is deprecated */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 gdk_pointer_ungrab(GDK_CURRENT_TIME);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
 if (!d->inputs)
 return true;
@@ -2355,7 +2373,10 @@ static void update_mouse_mode(SpiceChannel *channel, 
gpointer data)
 
 if (window != NULL) {
 GdkModifierType modifiers;
+/* FIXME: gdk_window_get_pointer() is deprecated */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 gdk_window_get_pointer(window, NULL, NULL, );
+G_GNUC_END_IGNORE_DEPRECATIONS
 
 if (modifiers & SPICE_GDK_BUTTONS_MASK)
 try_mouse_grab(display);
@@ -2771,7 +2792,10 @@ static void gl_draw(SpiceDisplay *display,
 GtkWidget *gl = gtk_stack_get_child_by_name(d->stack, "gl-area");
 
 if (gtk_stack_get_visible_child(d->stack) == gl) {
+/* Ignore GLib's too-new warnings */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 gtk_gl_area_queue_render(GTK_GL_AREA(gl));
+G_GNUC_END_IGNORE_DEPRECATIONS
 d->egl.call_draw_done = TRUE;
 } else
 #endif
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [client 08/10] session: Disable the spice_audio_new() deprecation warning

2016-10-18 Thread Francois Gouget
Third parties are not supposed to use spice_audio_new() anymore, but
internally it is used to implement its replacement, spice_audio_get().

Signed-off-by: Francois Gouget 
---
 src/spice-session.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/spice-session.c b/src/spice-session.c
index 238b5cb..7d7d7a9 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -2641,7 +2641,9 @@ SpiceAudio *spice_audio_get(SpiceSession *session, 
GMainContext *context)
 g_mutex_lock();
 self = session->priv->audio_manager;
 if (self == NULL) {
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 self = spice_audio_new(session, context, NULL);
+G_GNUC_END_IGNORE_DEPRECATIONS
 session->priv->audio_manager = self;
 }
 g_mutex_unlock();
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [client 01/10] build-sys: Enable deprecation warnings instead of ignoring them entirely

2016-10-18 Thread Francois Gouget
For Spice-gtk most deprecation issues come from changes outside Spice
(GLib) and thus should not be treated as errors to not break
compilation for users who have newer third-party libraries.
However they must be visible otherwise Spice developers will not be
aware of them and thus will not fix them before breakage happens.

Signed-off-by: Francois Gouget 
---
 m4/spice-compile-warnings.m4 | 2 +-
 src/controller/Makefile.am   | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/m4/spice-compile-warnings.m4 b/m4/spice-compile-warnings.m4
index 533bac6..dfa88fe 100644
--- a/m4/spice-compile-warnings.m4
+++ b/m4/spice-compile-warnings.m4
@@ -85,7 +85,7 @@ AC_DEFUN([SPICE_COMPILE_WARNINGS],[
 gl_WARN_ADD([-Wno-format-nonliteral])
 # We use some deprecated functions to avoid #ifdef hell while maintaining
 # compat with older gtk / glib versions
-gl_WARN_ADD([-Wno-deprecated-declarations])
+gl_WARN_ADD([-Wno-error=deprecated-declarations])
 
 
 
diff --git a/src/controller/Makefile.am b/src/controller/Makefile.am
index fb56986..00552e8 100644
--- a/src/controller/Makefile.am
+++ b/src/controller/Makefile.am
@@ -4,7 +4,6 @@ AM_CPPFLAGS =   \
-DG_LOG_DOMAIN=\"GSpiceController\" \
$(GIO_CFLAGS)   \
$(COMMON_CFLAGS)\
-   -Wno-deprecated-declarations\
$(NULL)
 
 # 
http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [client 02/10] gtk: Ignore GLib's too-new warnings where we explicitly check its version

2016-10-18 Thread Francois Gouget
Signed-off-by: Francois Gouget 
---
 src/spice-gtk-session.c | 5 +
 src/spice-widget-egl.c  | 3 +++
 src/spice-widget.c  | 6 ++
 3 files changed, 14 insertions(+)

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 3e0ec74..7ec2a57 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -126,6 +126,8 @@ static guint32 get_keyboard_lock_modifiers(void)
 {
 guint32 modifiers = 0;
 #if GTK_CHECK_VERSION(3,18,0)
+/* Ignore GLib's too-new warnings */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 GdkKeymap *keyboard = gdk_keymap_get_default();
 
 if (gdk_keymap_get_caps_lock_state(keyboard)) {
@@ -139,6 +141,7 @@ static guint32 get_keyboard_lock_modifiers(void)
 if (gdk_keymap_get_scroll_lock_state(keyboard)) {
 modifiers |= SPICE_INPUTS_SCROLL_LOCK;
 }
+G_GNUC_END_IGNORE_DEPRECATIONS
 #else
 #ifdef HAVE_X11_XKBLIB_H
 Display *x_display = NULL;
@@ -807,9 +810,11 @@ static void clipboard_get(GtkClipboard *clipboard,
 
 /* apparently, this is needed to avoid dead-lock, from
gtk_dialog_run */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 gdk_threads_leave();
 g_main_loop_run(ri.loop);
 gdk_threads_enter();
+G_GNUC_END_IGNORE_DEPRECATIONS
 
 cleanup:
 g_clear_pointer(, g_main_loop_unref);
diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
index 0698af3..3cc1098 100644
--- a/src/spice-widget-egl.c
+++ b/src/spice-widget-egl.c
@@ -303,9 +303,12 @@ gl_make_current(SpiceDisplay *display, GError **err)
 }
 #if GTK_CHECK_VERSION(3,16,0)
 else {
+/* Ignore GLib's too-new warnings */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 GtkWidget *area = gtk_stack_get_child_by_name(d->stack, "gl-area");
 
 gtk_gl_area_make_current(GTK_GL_AREA(area));
+G_GNUC_END_IGNORE_DEPRECATIONS
 }
 #endif
 
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 3ac0a7d..82adacf 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -567,6 +567,8 @@ static void grab_notify(SpiceDisplay *display, gboolean 
was_grabbed)
 
 #if GTK_CHECK_VERSION(3,16,0)
 #ifndef G_OS_WIN32
+/* Ignore GLib's too-new warnings */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 static gboolean
 gl_area_render(GtkGLArea *area, GdkGLContext *context, gpointer user_data)
 {
@@ -598,6 +600,7 @@ gl_area_realize(GtkGLArea *area, gpointer user_data)
 g_clear_error();
 }
 }
+G_GNUC_END_IGNORE_DEPRECATIONS
 #endif
 #endif
 
@@ -636,6 +639,8 @@ static void spice_display_init(SpiceDisplay *display)
 
 #if GTK_CHECK_VERSION(3,16,0)
 #ifndef G_OS_WIN32
+/* Ignore GLib's too-new warnings */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 area = gtk_gl_area_new();
 gtk_gl_area_set_required_version(GTK_GL_AREA(area), 3, 2);
 gtk_gl_area_set_auto_render(GTK_GL_AREA(area), false);
@@ -645,6 +650,7 @@ static void spice_display_init(SpiceDisplay *display)
  NULL);
 gtk_stack_add_named(d->stack, area, "gl-area");
 gtk_widget_show_all(widget);
+G_GNUC_END_IGNORE_DEPRECATIONS
 #endif
 #endif
 
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [client 03/10] gtk: Avoid gtk_vbox_new(); it is deprecated

2016-10-18 Thread Francois Gouget
Spice-Gtk requires GTK+ > 3.12 which has gtk_box_new().

Signed-off-by: Francois Gouget 
---
 src/spicy-connect.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/spicy-connect.c b/src/spicy-connect.c
index c471df5..a1d895a 100644
--- a/src/spicy-connect.c
+++ b/src/spicy-connect.c
@@ -156,7 +156,7 @@ gboolean spicy_connect_dialog(SpiceSession *session)
 gtk_window_set_resizable(window, FALSE);
 gtk_container_set_border_width(GTK_CONTAINER(window), 5);
 
-main_box = GTK_BOX(gtk_vbox_new(FALSE, 0));
+main_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
 gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(main_box));
 
 table = GTK_TABLE(gtk_table_new(3, 2, 0));
@@ -181,7 +181,7 @@ gboolean spicy_connect_dialog(SpiceSession *session)
 }
 }
 
-recent_box = GTK_BOX(gtk_vbox_new(FALSE, 0));
+recent_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
 gtk_box_pack_start(main_box, GTK_WIDGET(recent_box), TRUE, TRUE, 0);
 gtk_container_set_border_width(GTK_CONTAINER(recent_box), 5);
 
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [client 05/10] gtk: GtkTable is deprecated so use GtkGrid instead

2016-10-18 Thread Francois Gouget
Signed-off-by: Francois Gouget 
---
 src/spicy-connect.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/spicy-connect.c b/src/spicy-connect.c
index 915eb06..39555a6 100644
--- a/src/spicy-connect.c
+++ b/src/spicy-connect.c
@@ -141,7 +141,7 @@ gboolean spicy_connect_dialog(SpiceSession *session)
 GtkWidget *connect_button, *cancel_button, *label;
 GtkBox *main_box, *recent_box, *button_box;
 GtkWindow *window;
-GtkTable *table;
+GtkGrid *grid;
 int i;
 
 ConnectionInfo info = {
@@ -159,19 +159,19 @@ gboolean spicy_connect_dialog(SpiceSession *session)
 main_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
 gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(main_box));
 
-table = GTK_TABLE(gtk_table_new(3, 2, 0));
-gtk_box_pack_start(main_box, GTK_WIDGET(table), FALSE, TRUE, 0);
-gtk_container_set_border_width(GTK_CONTAINER(table), 5);
-gtk_table_set_row_spacings(table, 5);
-gtk_table_set_col_spacings(table, 5);
+grid = GTK_GRID(gtk_grid_new());
+gtk_box_pack_start(main_box, GTK_WIDGET(grid), FALSE, TRUE, 0);
+gtk_container_set_border_width(GTK_CONTAINER(grid), 5);
+gtk_grid_set_row_spacing(grid, 5);
+gtk_grid_set_column_spacing(grid, 5);
 
 for (i = 0; i < SPICE_N_ELEMENTS(connect_entries); i++) {
 gchar *txt;
 label = gtk_label_new(connect_entries[i].text);
 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-gtk_table_attach_defaults(table, label, 0, 1, i, i+1);
+gtk_grid_attach(grid, label, 0, i, 1, 1);
 connect_entries[i].entry = GTK_WIDGET(gtk_entry_new());
-gtk_table_attach_defaults(table, connect_entries[i].entry, 1, 2, i, 
i+1);
+gtk_grid_attach(grid, connect_entries[i].entry, 1, i, 1, 1);
 g_object_get(session, connect_entries[i].prop, , NULL);
 SPICE_DEBUG("%s: #%i [%s]: \"%s\"",
 __FUNCTION__, i, connect_entries[i].prop, txt);
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [client 03/10] gtk: Avoid gtk_vbox_new(); it is deprecated

2016-10-18 Thread Marc-André Lureau
please use "spicy:" for code touching spicy, 

thanks

- Original Message -
> Spice-Gtk requires GTK+ > 3.12 which has gtk_box_new().
> 
> Signed-off-by: Francois Gouget 
> ---
>  src/spicy-connect.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/spicy-connect.c b/src/spicy-connect.c
> index c471df5..a1d895a 100644
> --- a/src/spicy-connect.c
> +++ b/src/spicy-connect.c
> @@ -156,7 +156,7 @@ gboolean spicy_connect_dialog(SpiceSession *session)
>  gtk_window_set_resizable(window, FALSE);
>  gtk_container_set_border_width(GTK_CONTAINER(window), 5);
>  
> -main_box = GTK_BOX(gtk_vbox_new(FALSE, 0));
> +main_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
>  gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(main_box));
>  
>  table = GTK_TABLE(gtk_table_new(3, 2, 0));
> @@ -181,7 +181,7 @@ gboolean spicy_connect_dialog(SpiceSession *session)
>  }
>  }
>  
> -recent_box = GTK_BOX(gtk_vbox_new(FALSE, 0));
> +recent_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
>  gtk_box_pack_start(main_box, GTK_WIDGET(recent_box), TRUE, TRUE, 0);
>  gtk_container_set_border_width(GTK_CONTAINER(recent_box), 5);
>  
> --
> 2.9.3

looks good,
Reviewed-by: Marc-André Lureau 

> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
> 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server v4 2/4] fixup! Improve MainChannel encapsulation

2016-10-18 Thread Frediano Ziglio
> 
> This looks basically the same as the fixup patch that I just sent, but
> mine also includes the change from _peek_ to _get_. Feel free to choose
> this one or mine.
> 
> Jonathon
> 

Got a mix (just space changes of your, there was a long line).

Frediano

> 
> On Tue, 2016-10-18 at 12:13 +0100, Frediano Ziglio wrote:
> > Revert back spice_assert changes.
> > Pass success to main_channel_on_migrate_connected to avoid
> > changing check behaviour.
> > 
> > Signed-off-by: Frediano Ziglio 
> > ---
> >  server/main-channel-client.c | 2 +-
> >  server/main-channel.c| 9 +
> >  server/main-channel.h| 3 ++-
> >  3 files changed, 8 insertions(+), 6 deletions(-)
> > 
> > diff --git a/server/main-channel-client.c b/server/main-channel-
> > client.c
> > index 28d2839..f74de07 100644
> > --- a/server/main-channel-client.c
> > +++ b/server/main-channel-client.c
> > @@ -439,7 +439,7 @@ void
> > main_channel_client_handle_migrate_connected(MainChannelClient *mcc,
> >  
> >  mcc->priv->mig_wait_connect = FALSE;
> >  mcc->priv->mig_connect_ok = success;
> > -main_channel_on_migrate_connected(main_channel, seamless &&
> > success);
> > +main_channel_on_migrate_connected(main_channel, success,
> > seamless);
> >  } else {
> >  if (success) {
> >  spice_printerr("client %p MIGRATE_CANCEL", client);
> > diff --git a/server/main-channel.c b/server/main-channel.c
> > index 2d2783d..fe98b9d 100644
> > --- a/server/main-channel.c
> > +++ b/server/main-channel.c
> > @@ -420,13 +420,14 @@ int
> > main_channel_migrate_src_complete(MainChannel *main_chan, int
> > success)
> > return semi_seamless_count;
> >  }
> >  
> > -void main_channel_on_migrate_connected(MainChannel *main_channel,
> > gboolean seamless)
> > +void main_channel_on_migrate_connected(MainChannel *main_channel,
> > +   gboolean success, gboolean
> > seamless)
> >  {
> > -g_return_if_fail(main_channel->num_clients_mig_wait);
> > -g_warn_if_fail(!seamless || main_channel-
> > >num_clients_mig_wait == 1);
> > +spice_assert(main_channel->num_clients_mig_wait);
> > +spice_assert(!seamless || main_channel->num_clients_mig_wait
> > == 1);
> >  if (!--main_channel->num_clients_mig_wait) {
> >  reds_on_main_migrate_connected(red_channel_get_server(RE
> > D_CHANNEL(main_channel)),
> > -   seamless);
> > +   seamless && success);
> >  }
> >  }
> >  
> > diff --git a/server/main-channel.h b/server/main-channel.h
> > index 529e7be..4d0c070 100644
> > --- a/server/main-channel.h
> > +++ b/server/main-channel.h
> > @@ -81,6 +81,7 @@ void main_channel_migrate_cancel_wait(MainChannel
> > *main_chan);
> >  const RedsMigSpice* main_channel_peek_migration_target(MainChannel
> > *main_chan);
> >  /* returns the number of clients for which
> > SPICE_MSG_MAIN_MIGRATE_END was sent*/
> >  int main_channel_migrate_src_complete(MainChannel *main_chan, int
> > success);
> > -void main_channel_on_migrate_connected(MainChannel *main_channel,
> > gboolean seamless);
> > +void main_channel_on_migrate_connected(MainChannel *main_channel,
> > +   gboolean success, gboolean
> > seamless);
> >  
> >  #endif
> 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [client 06/10] build-sys: Remove SPICE_NO_DEPRECATED

2016-10-18 Thread Francois Gouget
Deprecation warnings no longer cause compilation errors.
Also they should either be fixed or ignored with
G_GNUC_{BEGIN,END}_IGNORE_DEPRECATIONS.

Signed-off-by: Francois Gouget 
---
 src/Makefile.am  |  1 -
 src/spice-util.h | 12 +++-
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 78953dd..3f81866 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -77,7 +77,6 @@ KEYMAP_GEN = $(srcdir)/keymap-gen.pl
 SPICE_COMMON_CPPFLAGS =\
-DSPICE_COMPILATION \
-DG_LOG_DOMAIN=\"GSpice\"   \
-   -DSPICE_NO_DEPRECATED   \
-DSPICE_GTK_LOCALEDIR=\"${SPICE_GTK_LOCALEDIR}\"\
-DPNP_IDS=\""$(PNP_IDS)"\"  \
-DUSB_IDS=\""$(USB_IDS)"\"  \
diff --git a/src/spice-util.h b/src/spice-util.h
index 88e3a57..a01da0c 100644
--- a/src/spice-util.h
+++ b/src/spice-util.h
@@ -41,22 +41,16 @@ gchar* spice_uuid_to_string(const guint8 uuid[16]);
 #define SPICE_RESERVED_PADDING (10 * sizeof(void*))
 
 /* need to be in a public header */
-#ifndef SPICE_GNUC_DEPRECATED_FOR
+#ifndef SPICE_DEPRECATED_FOR
 #if__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
-#define SPICE_GNUC_DEPRECATED_FOR(f)\
+#define SPICE_DEPRECATED_FOR(f)\
   __attribute__((deprecated("Use " #f " instead")))
 #else
-#define SPICE_GNUC_DEPRECATED_FOR(f)G_GNUC_DEPRECATED
+#define SPICE_DEPRECATED_FOR(f)G_GNUC_DEPRECATED
 #endif /* __GNUC__ */
 #endif
 
-#ifndef SPICE_NO_DEPRECATED
-#define SPICE_DEPRECATED_FOR(f)  SPICE_GNUC_DEPRECATED_FOR(f)
 #define SPICE_DEPRECATED  G_GNUC_DEPRECATED
-#else
-#define SPICE_DEPRECATED_FOR(f)
-#define SPICE_DEPRECATED
-#endif
 
 G_END_DECLS
 
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [client 10/10] RFC: spicy: Temporarily ignore deprecation warnings

2016-10-18 Thread Francois Gouget
GtkAction and lots of GtkUI APIs are deprecated.

Signed-off-by: Francois Gouget 
---
 src/spicy.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/spicy.c b/src/spicy.c
index c502428..c4a6c7d 100644
--- a/src/spicy.c
+++ b/src/spicy.c
@@ -38,6 +38,9 @@
 
 #include "spicy-connect.h"
 
+/* FIXME: GtkAction and lots of GtkUI APIs are deprecated */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
 typedef struct spice_connection spice_connection;
 
 enum {
-- 
2.9.3
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server 06/10] Include directly used header in dcc.h

2016-10-18 Thread Jonathon Jongsma
Acked-by: Jonathon Jongsma 


On Mon, 2016-10-17 at 14:26 +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio 
> ---
>  server/dcc.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/server/dcc.h b/server/dcc.h
> index 2456f09..7a07981 100644
> --- a/server/dcc.h
> +++ b/server/dcc.h
> @@ -25,6 +25,7 @@
>  #include "pixmap-cache.h"
>  #include "red-worker.h"
>  #include "display-limits.h"
> +#include "red-channel-client.h"
>  
>  G_BEGIN_DECLS
>  
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [client] gtk: Remove an obsolete comment

2016-10-18 Thread Francois Gouget
On Tue, 18 Oct 2016, Pavel Grunt wrote:

> On Tue, 2016-10-18 at 05:30 -0400, Frediano Ziglio wrote:
> > > 
> > > The GTK+ compatibility code has been gathered in a single file
> > > long ago.
> > > 
> > 
> similar thing is in vncdisplaykeymap.c

It's a bit different. Those comments still have the corresponding 
compatibility defines. They can probably be removed but I'll let 
specialists verify that it won't introduce compatibility issues.


-- 
Francois Gouget 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server v5] Updated refactory patches

2016-10-18 Thread Frediano Ziglio
Just removed acked and pushed patches and merged
acknowledged fixup (1).

Jonathon Jongsma (1):
  Convert RedChannel hierarchy to GObject

 server/Makefile.am  |   2 +
 server/common-graphics-channel.c| 111 --
 server/common-graphics-channel.h|  42 ++-
 server/cursor-channel.c | 135 
 server/cursor-channel.h |  20 +-
 server/dcc-send.c   |  11 +-
 server/dcc.c|   1 +
 server/dcc.h|   2 +-
 server/display-channel-private.h|  76 +
 server/display-channel.c| 234 ++---
 server/display-channel.h| 100 ++
 server/dummy-channel-client.c   |  17 +-
 server/dummy-channel.c  |  49 +++
 server/dummy-channel.h  |  60 
 server/inputs-channel.c | 140 +---
 server/inputs-channel.h |  20 +-
 server/main-channel-client.c|  38 ++-
 server/main-channel-client.h|   5 +-
 server/main-channel.c   | 153 ++---
 server/main-channel.h   |  33 +-
 server/red-channel-client-private.h |  19 ++
 server/red-channel-client.c | 179 ++
 server/red-channel-client.h |   6 +-
 server/red-channel.c| 649 
 server/red-channel.h| 183 +-
 server/red-parse-qxl.h  |   2 +
 server/red-qxl.c|  21 +-
 server/red-replay-qxl.c |   2 +-
 server/red-worker.c |  27 +-
 server/red-worker.h |   2 -
 server/reds-private.h   |   3 +-
 server/reds.c   |  66 ++--
 server/smartcard.c  | 138 ++--
 server/sound.c  |  44 ++-
 server/spicevmc.c   | 450 +++--
 server/stream.c |   4 +-
 36 files changed, 2079 insertions(+), 965 deletions(-)
 create mode 100644 server/display-channel-private.h
 create mode 100644 server/dummy-channel.c
 create mode 100644 server/dummy-channel.h

-- 
2.7.4

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [spice-gtk v1 4/4] channel-display-gst: early return if gst_init failed

2016-10-18 Thread Victor Toso
From: Victor Toso 

If gst_init() fails, gstvideo_init() will warn once about the issue
and never attempt to try again, which is probably fine.

All the other APIs that might be called such as
create_gstreamer_decoder() should not fail silently.

Signed-off-by: Victor Toso 
---
 src/channel-display-gst.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index c0f0a1e..c102966 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -459,23 +459,23 @@ static gboolean gstvideo_init(void)
 G_GNUC_INTERNAL
 VideoDecoder* create_gstreamer_decoder(int codec_type, display_stream *stream)
 {
-SpiceGstDecoder *decoder = NULL;
-
-if (gstvideo_init()) {
-decoder = spice_new0(SpiceGstDecoder, 1);
-decoder->base.destroy = spice_gst_decoder_destroy;
-decoder->base.reschedule = spice_gst_decoder_reschedule;
-decoder->base.queue_frame = spice_gst_decoder_queue_frame;
-decoder->base.codec_type = codec_type;
-decoder->base.stream = stream;
-g_mutex_init(>queues_mutex);
-decoder->decoding_queue = g_queue_new();
-decoder->display_queue = g_queue_new();
-
-if (!create_pipeline(decoder)) {
-decoder->base.destroy((VideoDecoder*)decoder);
-decoder = NULL;
-}
+SpiceGstDecoder *decoder;
+
+g_return_val_if_fail(gstvideo_init(), NULL);
+
+decoder = spice_new0(SpiceGstDecoder, 1);
+decoder->base.destroy = spice_gst_decoder_destroy;
+decoder->base.reschedule = spice_gst_decoder_reschedule;
+decoder->base.queue_frame = spice_gst_decoder_queue_frame;
+decoder->base.codec_type = codec_type;
+decoder->base.stream = stream;
+g_mutex_init(>queues_mutex);
+decoder->decoding_queue = g_queue_new();
+decoder->display_queue = g_queue_new();
+
+if (!create_pipeline(decoder)) {
+decoder->base.destroy((VideoDecoder*)decoder);
+return NULL;
 }
 
 return (VideoDecoder*)decoder;
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [spice-gtk v1 1/4] channel-display-gst: style changes in create_pipeline

2016-10-18 Thread Victor Toso
From: Victor Toso 

Move declaration of variable to top and break big g_strdup_printf
line.

Signed-off-by: Victor Toso 
---
 src/channel-display-gst.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index 430bb95..de774f2 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -250,6 +250,10 @@ static void free_pipeline(SpiceGstDecoder *decoder)
 static gboolean create_pipeline(SpiceGstDecoder *decoder)
 {
 const gchar *src_caps, *gstdec_name;
+gchar *desc;
+GstAppSinkCallbacks appsink_cbs = { 0 };
+GError *err = NULL;
+
 switch (decoder->base.codec_type) {
 case SPICE_VIDEO_CODEC_TYPE_MJPEG:
 src_caps = "caps=image/jpeg";
@@ -293,10 +297,12 @@ static gboolean create_pipeline(SpiceGstDecoder *decoder)
  * - Set max-bytes=0 on appsrc so it does not drop frames that may be
  *   needed by those that follow.
  */
-gchar *desc = g_strdup_printf("appsrc name=src is-live=true format=time 
max-bytes=0 block=true %s ! %s ! videoconvert ! appsink name=sink 
caps=video/x-raw,format=BGRx sync=false drop=false", src_caps, gstdec_name);
+desc = g_strdup_printf("appsrc name=src is-live=true format=time 
max-bytes=0 block=true "
+   "%s ! %s ! videoconvert ! appsink name=sink "
+   "caps=video/x-raw,format=BGRx sync=false 
drop=false",
+   src_caps, gstdec_name);
 SPICE_DEBUG("GStreamer pipeline: %s", desc);
 
-GError *err = NULL;
 decoder->pipeline = gst_parse_launch_full(desc, NULL, 
GST_PARSE_FLAG_FATAL_ERRORS, );
 g_free(desc);
 if (!decoder->pipeline) {
@@ -307,7 +313,8 @@ static gboolean create_pipeline(SpiceGstDecoder *decoder)
 
 decoder->appsrc = 
GST_APP_SRC(gst_bin_get_by_name(GST_BIN(decoder->pipeline), "src"));
 decoder->appsink = 
GST_APP_SINK(gst_bin_get_by_name(GST_BIN(decoder->pipeline), "sink"));
-GstAppSinkCallbacks appsink_cbs = {NULL, NULL, _sample, {NULL}};
+
+appsink_cbs.new_sample = _sample;
 gst_app_sink_set_callbacks(decoder->appsink, _cbs, decoder, NULL);
 
 decoder->clock = gst_pipeline_get_clock(GST_PIPELINE(decoder->pipeline));
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [spice-gtk v1 3/4] channel-display-gst: improve check for decoder element

2016-10-18 Thread Victor Toso
From: Victor Toso 

Instead of creating the whole pipeline and check for errors (which
would create and destroy the SpiceGstDecoder), let's use
gst_element_factory_find() function.

Signed-off-by: Victor Toso 
---
 src/channel-display-gst.c | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index 68ebd1f..c0f0a1e 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -484,13 +484,24 @@ VideoDecoder* create_gstreamer_decoder(int codec_type, 
display_stream *stream)
 G_GNUC_INTERNAL
 gboolean gstvideo_has_codec(int codec_type)
 {
-gboolean has_codec = FALSE;
+gint i;
+gchar **elements;
 
-VideoDecoder *decoder = create_gstreamer_decoder(codec_type, NULL);
-if (decoder) {
-has_codec = TRUE;
-decoder->destroy(decoder);
-}
+g_return_val_if_fail(gstvideo_init(), FALSE);
+g_return_val_if_fail(VALID_VIDEO_CODEC_TYPE(codec_type), FALSE);
+
+elements = g_strsplit(gst_opts[codec_type].dec_name, "!", 0);
+for (i = 0; elements[i] != NULL; i++) {
+GstElementFactory *factory;
 
-return has_codec;
+factory = gst_element_factory_find(g_strstrip(elements[i]));
+if (factory == NULL) {
+SPICE_DEBUG("no element %s", elements[i]);
+g_strfreev(elements);
+return FALSE;
+}
+gst_object_unref(factory);
+}
+g_strfreev(elements);
+return TRUE;
 }
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [spice-gtk v1 2/4] channel-display-gst: use a static array for gst options

2016-10-18 Thread Victor Toso
From: Victor Toso 

Signed-off-by: Victor Toso 
---
 src/channel-display-gst.c | 78 +--
 1 file changed, 42 insertions(+), 36 deletions(-)

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index de774f2..68ebd1f 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -50,6 +50,37 @@ typedef struct SpiceGstDecoder {
 guint timer_id;
 } SpiceGstDecoder;
 
+static struct {
+const gchar *dec_name;
+const gchar *dec_caps;
+} gst_opts[] = {
+/* decodebin will use vaapi if installed, which for a time could
+ * intentionally crash the application. So only use decodebin as a
+ * fallback or when SPICE_GSTVIDEO_AUTO is set.
+ * See: https://bugs.freedesktop.org/show_bug.cgi?id=90884
+ */
+{ "decodebin", "" },
+
+/* SPICE_VIDEO_CODEC_TYPE_MJPEG */
+{ "jpegdec", "caps=image/jpeg" },
+
+/* SPICE_VIDEO_CODEC_TYPE_VP8
+ *
+ * typefind is unable to identify VP8 streams by design.
+ * See: https://bugzilla.gnome.org/show_bug.cgi?id=756457
+ */
+{ "vp8dec", "caps=video/x-vp8" },
+
+/* SPICE_VIDEO_CODEC_TYPE_H264
+ * h264 streams detection works fine and setting an incomplete cap
+ * causes errors. So let typefind do all the work.
+ */
+{ "h264parse ! avdec_h264", "" },
+
+};
+
+#define VALID_VIDEO_CODEC_TYPE(codec) \
+(codec > 0 && codec < SPICE_VIDEO_CODEC_TYPE_ENUM_END)
 
 /* -- SpiceFrame -- */
 
@@ -249,45 +280,20 @@ static void free_pipeline(SpiceGstDecoder *decoder)
 
 static gboolean create_pipeline(SpiceGstDecoder *decoder)
 {
-const gchar *src_caps, *gstdec_name;
 gchar *desc;
+gboolean auto_enabled;
+guint opt;
 GstAppSinkCallbacks appsink_cbs = { 0 };
 GError *err = NULL;
 
-switch (decoder->base.codec_type) {
-case SPICE_VIDEO_CODEC_TYPE_MJPEG:
-src_caps = "caps=image/jpeg";
-gstdec_name = "jpegdec";
-break;
-case SPICE_VIDEO_CODEC_TYPE_VP8:
-/* typefind is unable to identify VP8 streams by design.
- * See: https://bugzilla.gnome.org/show_bug.cgi?id=756457
- */
-src_caps = "caps=video/x-vp8";
-gstdec_name = "vp8dec";
-break;
-case SPICE_VIDEO_CODEC_TYPE_H264:
-/* h264 streams detection works fine and setting an incomplete cap
- * causes errors. So let typefind do all the work.
- */
-src_caps = "";
-gstdec_name = "h264parse ! avdec_h264";
-break;
-default:
-SPICE_DEBUG("Unknown codec type %d. Trying decodebin.",
-decoder->base.codec_type);
-src_caps = "";
-gstdec_name = NULL;
-break;
-}
-
-/* decodebin will use vaapi if installed, which for a time could
- * intentionally crash the application. So only use decodebin as a
- * fallback or when SPICE_GSTVIDEO_AUTO is set.
- * See: https://bugs.freedesktop.org/show_bug.cgi?id=90884
- */
-if (gstdec_name == NULL || g_getenv("SPICE_GSTVIDEO_AUTO") != NULL) {
-gstdec_name = "decodebin";
+auto_enabled = (g_getenv("SPICE_GSTVIDEO_AUTO") != NULL);
+if (auto_enabled || !VALID_VIDEO_CODEC_TYPE(decoder->base.codec_type)) {
+SPICE_DEBUG("Trying %s for codec type %d %s",
+gst_opts[0].dec_name, decoder->base.codec_type,
+(auto_enabled) ? "(SPICE_GSTVIDEO_AUTO is set)" : "");
+opt = 0;
+} else {
+opt = decoder->base.codec_type;
 }
 
 /* - We schedule the frame display ourselves so set sync=false on appsink
@@ -300,7 +306,7 @@ static gboolean create_pipeline(SpiceGstDecoder *decoder)
 desc = g_strdup_printf("appsrc name=src is-live=true format=time 
max-bytes=0 block=true "
"%s ! %s ! videoconvert ! appsink name=sink "
"caps=video/x-raw,format=BGRx sync=false 
drop=false",
-   src_caps, gstdec_name);
+   gst_opts[opt].dec_caps, gst_opts[opt].dec_name);
 SPICE_DEBUG("GStreamer pipeline: %s", desc);
 
 decoder->pipeline = gst_parse_launch_full(desc, NULL, 
GST_PARSE_FLAG_FATAL_ERRORS, );
-- 
2.9.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server 01/12] Remove red_pipe_add_verb family function

2016-10-18 Thread Jonathon Jongsma
It seems that 

On Tue, 2016-10-18 at 10:09 +0100, Frediano Ziglio wrote:
> These functions were implementing the same stuff as empty
> messages functions provided by RedChannel so reuse them.
> 
> The implementation seems a bit different but the result
> is the same. Specifically:
> - RedEmptyMsgPipeItem::msg is int while RedVerbItem::verb was
>   uint16_t however this data goes into the message type which
>   is uint16_t (a 16 bit on the network protocol);

Should we change 'msg' to uint16_t then?

> - red_channel_client_send_empty_msg calls
>   red_channel_client_begin_send_message while red_marshall_verb
>   not. However cursor_channel_send_item and dcc_send_item call
>   red_channel_client_begin_send_message always after calling
>   red_marshall_verb and dcc_send_item calls.

This sentence ends kind of abrubtly and is a bit confusing.

>   You can be mistaken in dcc_send_item by
>   red_channel_client_send_message_pending check however this is
>   false only if during a marshalling a cache notify was added
>   which does not happen for red_marshall_verb;


Possible re-wording:

"Previously, there was one situation where dcc_send_item() did not call
red_channel_client_begin_send_message(): when
red_channel_client_send_message_pending() returned FALSE. This scenario
only occurs when a cache notify was added during marshalling"

However, I'm not totally sure what you mean by "cache notify was added"


> - when a PipeItem is created red_channel_client_pipe_add_empty_msg
>   calls red_channel_client_push while red_pipe_add_verb does not.
>   This actually make very few difference as this kind of item are

few -> little

"these kinds of items"

>   never removed from the queue and a push is forced in every case
>   running the event handler for the stream watch (see
>   prepare_pipe_add and red_channel_client_event).


I don't understand this part.



> 
> Signed-off-by: Frediano Ziglio 
> ---
>  server/common-graphics-channel.h | 34 +-
> 
>  server/cursor-channel.c  |  5 +
>  server/dcc-send.c|  3 ---
>  server/dcc.c |  2 +-
>  server/display-channel.c |  2 +-
>  server/red-worker.c  |  4 ++--
>  6 files changed, 6 insertions(+), 44 deletions(-)
> 
> diff --git a/server/common-graphics-channel.h b/server/common-
> graphics-channel.h
> index 97cd63b..2a03414 100644
> --- a/server/common-graphics-channel.h
> +++ b/server/common-graphics-channel.h
> @@ -39,43 +39,11 @@ gboolean
> common_graphics_channel_get_during_target_migrate(CommonGraphicsChann
> el
>  QXLInstance* common_graphics_channel_get_qxl(CommonGraphicsChannel
> *self);
>  
>  enum {
> -RED_PIPE_ITEM_TYPE_VERB = RED_PIPE_ITEM_TYPE_CHANNEL_BASE,
> -RED_PIPE_ITEM_TYPE_INVAL_ONE,
> +RED_PIPE_ITEM_TYPE_INVAL_ONE = RED_PIPE_ITEM_TYPE_CHANNEL_BASE,
>  
>  RED_PIPE_ITEM_TYPE_COMMON_LAST
>  };
>  
> -typedef struct RedVerbItem {
> -RedPipeItem base;
> -uint16_t verb;
> -} RedVerbItem;
> -
> -static inline void red_marshall_verb(RedChannelClient *rcc,
> RedVerbItem *item)
> -{
> -red_channel_client_init_send_data(rcc, item->verb, NULL);
> -}
> -
> -static inline void red_pipe_add_verb(RedChannelClient* rcc, uint16_t
> verb)
> -{
> -RedVerbItem *item = spice_new(RedVerbItem, 1);
> -
> -red_pipe_item_init(>base, RED_PIPE_ITEM_TYPE_VERB);
> -item->verb = verb;
> -red_channel_client_pipe_add(rcc, >base);
> -}
> -
> -static inline void red_pipe_add_verb_proxy(RedChannelClient *rcc,
> gpointer data)
> -{
> -uint16_t verb = GPOINTER_TO_UINT(data);
> -red_pipe_add_verb(rcc, verb);
> -}
> -
> -
> -static inline void red_pipes_add_verb(RedChannel *channel, uint16_t
> verb)
> -{
> -red_channel_apply_clients_data(channel, red_pipe_add_verb_proxy,
> GUINT_TO_POINTER(verb));
> -}
> -
>  CommonGraphicsChannel* common_graphics_channel_new(RedsState
> *server,
> QXLInstance *qxl,
> const
> SpiceCoreInterfaceInternal *core,
> diff --git a/server/cursor-channel.c b/server/cursor-channel.c
> index 28a6d54..7df8763 100644
> --- a/server/cursor-channel.c
> +++ b/server/cursor-channel.c
> @@ -292,9 +292,6 @@ static void
> cursor_channel_send_item(RedChannelClient *rcc, RedPipeItem *pipe_it
>  case RED_PIPE_ITEM_TYPE_INVAL_ONE:
>  red_marshall_inval(rcc, m, SPICE_CONTAINEROF(pipe_item,
> RedCacheItem, u.pipe_data));
>  break;
> -case RED_PIPE_ITEM_TYPE_VERB:
> -red_marshall_verb(rcc, SPICE_UPCAST(RedVerbItem,
> pipe_item));
> -break;
>  case RED_PIPE_ITEM_TYPE_CURSOR_INIT:
>  cursor_channel_client_reset_cursor_cache(rcc);
>  red_marshall_cursor_init(ccc, m, pipe_item);
> @@ -392,7 +389,7 @@ void cursor_channel_reset(CursorChannel *cursor)
>  if (red_channel_is_connected(channel)) {
>  red_channel_pipes_add_type(channel,
> 

Re: [Spice-devel] [PATCH spice-server 03/12] Remove warnings from reds_stat utility

2016-10-18 Thread Jonathon Jongsma
Acked-by: Jonathon Jongsma 


On Tue, 2016-10-18 at 10:09 +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio 
> ---
>  tools/reds_stat.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/reds_stat.c b/tools/reds_stat.c
> index 9aca1ad..3e966d4 100644
> --- a/tools/reds_stat.c
> +++ b/tools/reds_stat.c
> @@ -24,6 +24,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #define TAB_LEN 4
> @@ -33,15 +34,14 @@
>  static SpiceStat *reds_stat = (SpiceStat *)MAP_FAILED;
>  static uint64_t *values = NULL;
>  
> -void print_stat_tree(int32_t node_index, int depth)
> +static void print_stat_tree(int32_t node_index, int depth)
>  {
>  SpiceStatNode *node = _stat->nodes[node_index];
> -int i;
>  
>  if ((node->flags & SPICE_STAT_NODE_MASK_SHOW) ==
> SPICE_STAT_NODE_MASK_SHOW) {
>  printf("%*s%s", depth * TAB_LEN, "", node->name);
>  if (node->flags & SPICE_STAT_NODE_FLAG_VALUE) {
> -printf(":%*s%llu (%llu)\n", (VALUE_TABS - depth) *
> TAB_LEN - strlen(node->name) - 1, "",
> +printf(":%*s%"PRIu64" (%"PRIu64")\n", (int) ((VALUE_TABS
> - depth) * TAB_LEN - strlen(node->name) - 1), "",
> node->value, node->value - values[node_index]);
>  values[node_index] = node->value;
>  } else {
> @@ -60,7 +60,6 @@ int main(int argc, char **argv)
>  {
>  char *shm_name;
>  pid_t kvm_pid;
> -uint64_t *val;
>  uint32_t num_of_nodes = 0;
>  size_t shm_size;
>  size_t shm_old_size;
> @@ -98,7 +97,9 @@ int main(int argc, char **argv)
>  goto error;
>  }
>  while (1) {
> -system("clear");
> +if (system("clear") != 0) {
> +printf("\n\n\n");
> +}
>  printf("spice statistics\n\n");
>  if (num_of_nodes != reds_stat->num_of_nodes) {
>  num_of_nodes = reds_stat->num_of_nodes;
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel