Re: [Spice-devel] [PATCH v6 07/10] win-usbredir: Only match USB devices by VID:PID when WinUsb used

2016-02-04 Thread Jonathon Jongsma
On Thu, 2015-10-29 at 17:26 +0200, Dmitry Fleytman wrote:
> In other cases match devices by BUS:ADDR.
> 
> Signed-off-by: Dmitry Fleytman 
> ---
>  src/usb-device-manager.c | 78 +--
> -
>  1 file changed, 40 insertions(+), 38 deletions(-)
> 
> diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
> index 55533f9..dd55276 100644
> --- a/src/usb-device-manager.c
> +++ b/src/usb-device-manager.c
> @@ -653,13 +653,15 @@ static gboolean
> spice_usb_device_manager_get_udev_bus_n_address(
>  
>  *bus = *address = 0;
>  
> -#ifndef G_OS_WIN32
> -bus_str = g_udev_device_get_property(udev, "BUSNUM");
> -address_str = g_udev_device_get_property(udev, "DEVNUM");
> -#else /* Windows -- request vid:pid instead */
> -bus_str = g_udev_device_get_property(udev, "VID");
> -address_str = g_udev_device_get_property(udev, "PID");
> -#endif
> +if (manager->priv->use_usbclerk) {
> +   /* Windows WinUsb/UsbClerk -- request vid:pid instead */
> +bus_str = g_udev_device_get_property(udev, "VID");
> +address_str = g_udev_device_get_property(udev, "PID");
> +} else {
> +   /* Linux or UsbDk backend on Windows*/
> +bus_str = g_udev_device_get_property(udev, "BUSNUM");
> +address_str = g_udev_device_get_property(udev, "DEVNUM");
> +}
>  if (bus_str)
>  *bus = atoi(bus_str);
>  if (address_str)
> @@ -798,13 +800,17 @@ static void
> spice_usb_device_manager_auto_connect_cb(GObject  *gobject,
>  spice_usb_device_unref(device);
>  }
>  
> -#ifndef G_OS_WIN32 /* match functions for Linux -- match by bus.addr */
>  static gboolean
>  spice_usb_device_manager_device_match(SpiceUsbDeviceManager *self,
> SpiceUsbDevice *device,
>const int bus, const int address)
>  {
> -return (spice_usb_device_get_busnum(device) == bus &&
> -spice_usb_device_get_devaddr(device) == address);
> +   if (self->priv->use_usbclerk) {
> +return (spice_usb_device_get_vid(device) == bus &&
> +spice_usb_device_get_pid(device) == address);
> +} else {
> +return (spice_usb_device_get_busnum(device) == bus &&
> +spice_usb_device_get_devaddr(device) == address);
> +}
>  }
>  
>  #ifdef USE_GUDEV
> @@ -812,32 +818,21 @@ static gboolean
>  spice_usb_device_manager_libdev_match(SpiceUsbDeviceManager *self,
> libusb_device *libdev,
>const int bus, const int address)
>  {
> -return (libusb_get_bus_number(libdev) == bus &&
> -libusb_get_device_address(libdev) == address);
> -}
> -#endif
> -
> -#else /* Win32 -- match functions for Windows -- match by vid:pid */
> -static gboolean
> -spice_usb_device_manager_device_match(SpiceUsbDeviceManager *self,
> SpiceUsbDevice *device,
> -  const int vid, const int pid)
> -{
> -return (spice_usb_device_get_vid(device) == vid &&
> -spice_usb_device_get_pid(device) == pid);
> -}
> +if (self->priv->use_usbclerk) {
> +/* WinUSB -- match functions for Windows -- match by vid:pid */
> +int vid, pid;
>  
> -static gboolean
> -spice_usb_device_manager_libdev_match(SpiceUsbDeviceManager *self,
> libusb_device *libdev,
> -  const int vid, const int pid)
> -{
> -int vid2, pid2;
> -
> -if (!spice_usb_device_manager_get_libdev_vid_pid(libdev, , )) {
> -return FALSE;
> +if (!spice_usb_device_manager_get_libdev_vid_pid(libdev, , ))
> {
> +return FALSE;
> +}
> +return (bus == vid && address == pid);
> +} else {
> +/* match functions for Linux/UsbDk -- match by bus.addr */
> +return (libusb_get_bus_number(libdev) == bus &&
> +libusb_get_device_address(libdev) == address);
>  }
> -return (vid == vid2 && pid == pid2);
>  }
> -#endif /* of Win32 -- match functions */
> +#endif
>  
>  static SpiceUsbDevice*
>  spice_usb_device_manager_find_device(SpiceUsbDeviceManager *self,
> @@ -1908,14 +1903,21 @@
> spice_usb_manager_device_equal_libdev(SpiceUsbDeviceManager *manager,
>SpiceUsbDevice *device,
>libusb_device  *libdev)
>  {
> -int vid, pid;
> +   int busnum, devaddr;

indentation change

>  
>  if ((device == NULL) || (libdev == NULL))
> -return FALSE;
> +   return FALSE;

indentation change

> +
> +if (manager->priv->use_usbclerk) {
> +busnum = spice_usb_device_get_vid(device);
> +devaddr = spice_usb_device_get_pid(device);
> +} else {
> +busnum = spice_usb_device_get_busnum(device);
> +devaddr = spice_usb_device_get_devaddr(device);
> +}
>  
> -vid = spice_usb_device_get_vid(device);
> -pid = spice_usb_device_get_pid(device);
> -return 

[Spice-devel] [PATCH v4 2/5] Add spice_channel_unix_read_fd()

2016-02-04 Thread Marc-André Lureau
From: Marc-André Lureau 

Utility function used in the messages with socket ancillary fd.

Signed-off-by: Marc-André Lureau 
---
 src/spice-channel-priv.h |  3 +++
 src/spice-channel.c  | 68 
 2 files changed, 71 insertions(+)

diff --git a/src/spice-channel-priv.h b/src/spice-channel-priv.h
index d60ea73..526b661 100644
--- a/src/spice-channel-priv.h
+++ b/src/spice-channel-priv.h
@@ -205,6 +205,9 @@ void spice_vmc_write_async(SpiceChannel *self,
gpointer user_data);
 gssize spice_vmc_write_finish(SpiceChannel *self,
   GAsyncResult *result, GError **error);
+#ifdef G_OS_UNIX
+gint spice_channel_unix_read_fd(SpiceChannel *channel);
+#endif
 
 G_END_DECLS
 
diff --git a/src/spice-channel.c b/src/spice-channel.c
index ff85715..db2e5c2 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -872,6 +872,74 @@ static void spice_channel_write_msg(SpiceChannel *channel, 
SpiceMsgOut *out)
 spice_msg_out_unref(out);
 }
 
+#ifdef G_OS_UNIX
+static ssize_t read_fd(int fd, int *msgfd)
+{
+struct msghdr msg = { NULL, };
+struct iovec iov[1];
+union {
+struct cmsghdr cmsg;
+char control[CMSG_SPACE(sizeof(int))];
+} msg_control;
+struct cmsghdr *cmsg;
+ssize_t ret;
+char c;
+
+iov[0].iov_base = 
+iov[0].iov_len = 1;
+
+msg.msg_iov = iov;
+msg.msg_iovlen = 1;
+msg.msg_control = _control;
+msg.msg_controllen = sizeof(msg_control);
+
+ret = recvmsg(fd, , 0);
+if (ret > 0) {
+for (cmsg = CMSG_FIRSTHDR();
+ cmsg;
+ cmsg = CMSG_NXTHDR(, cmsg)) {
+if (cmsg->cmsg_len != CMSG_LEN(sizeof(int)) ||
+cmsg->cmsg_level != SOL_SOCKET ||
+cmsg->cmsg_type != SCM_RIGHTS) {
+continue;
+}
+
+memcpy(msgfd, CMSG_DATA(cmsg), sizeof(int));
+if (*msgfd < 0) {
+continue;
+}
+}
+}
+return ret;
+}
+
+G_GNUC_INTERNAL
+gint spice_channel_unix_read_fd(SpiceChannel *channel)
+{
+SpiceChannelPrivate *c = channel->priv;
+gint fd = -1;
+
+g_return_val_if_fail(g_socket_get_family(c->sock) == G_SOCKET_FAMILY_UNIX, 
-1);
+
+while (1) {
+/* g_socket_receive_message() is not convenient here because it
+ * reads all control messages, and overly complicated to deal with */
+if (read_fd(g_socket_get_fd(c->sock), ) > 0) {
+break;
+}
+
+if (errno == EWOULDBLOCK) {
+g_coroutine_socket_wait(>coroutine, c->sock, G_IO_IN);
+} else {
+g_warning("failed to get fd: %s", g_strerror(errno));
+return -1;
+}
+}
+
+return fd;
+}
+#endif
+
 /*
  * Read at least 1 more byte of data straight off the wire
  * into the requested buffer.
-- 
2.5.0

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


[Spice-devel] [PATCH v4 5/5] gtk: add spice-widget GL scanout support

2016-02-04 Thread Marc-André Lureau
From: Marc-André Lureau 

Hook to spice-glib events to show the GL scanout.

The opengl context is created with egl, and is currently
x11-only (supporting wayland with bare-egl doesn't seem trivial).

Using GtkGLArea is left for a future series, since SpiceDisplay widget
is a GtkDrawingArea and can't be replaced without breaking
ABI. Furthermore, GtkGLArea won't work on non-egl contexts, so this
approach is necessary on gtk+ < 3.16 or X11 (because gdk/x11 uses glx).

Signed-off-by: Marc-André Lureau 
---
 src/Makefile.am |   9 +
 src/spice-widget-egl.c  | 576 
 src/spice-widget-priv.h |  30 +++
 src/spice-widget.c  | 151 +++--
 4 files changed, 746 insertions(+), 20 deletions(-)
 create mode 100644 src/spice-widget-egl.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 37b89fe..68884e6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -122,6 +122,7 @@ SPICE_GTK_LIBADD_COMMON =   \
libspice-client-glib-2.0.la \
$(GTK_LIBS) \
$(CAIRO_LIBS)   \
+   $(EPOXY_LIBS)   \
$(LIBM) \
$(NULL)
 
@@ -160,17 +161,25 @@ SPICE_GTK_SOURCES_COMMON +=   \
 endif
 
 if WITH_GTK
+if WITH_EPOXY
+SPICE_GTK_SOURCES_COMMON +=\
+   spice-widget-egl.c  \
+   $(NULL)
+endif
+
 if HAVE_GTK_2
 libspice_client_gtk_2_0_la_DEPEDENCIES = $(GTK_SYMBOLS_FILE)
 libspice_client_gtk_2_0_la_LDFLAGS = $(SPICE_GTK_LDFLAGS_COMMON)
 libspice_client_gtk_2_0_la_LIBADD = $(SPICE_GTK_LIBADD_COMMON)
 libspice_client_gtk_2_0_la_SOURCES = $(SPICE_GTK_SOURCES_COMMON)
+libspice_client_gtk_2_0_la_CFLAGS = $(EPOXY_CFLAGS)
 nodist_libspice_client_gtk_2_0_la_SOURCES = $(nodist_SPICE_GTK_SOURCES_COMMON)
 else
 libspice_client_gtk_3_0_la_DEPEDENCIES = $(GTK_SYMBOLS_FILE)
 libspice_client_gtk_3_0_la_LDFLAGS = $(SPICE_GTK_LDFLAGS_COMMON)
 libspice_client_gtk_3_0_la_LIBADD = $(SPICE_GTK_LIBADD_COMMON)
 libspice_client_gtk_3_0_la_SOURCES = $(SPICE_GTK_SOURCES_COMMON)
+libspice_client_gtk_3_0_la_CFLAGS = $(EPOXY_CFLAGS)
 nodist_libspice_client_gtk_3_0_la_SOURCES = $(nodist_SPICE_GTK_SOURCES_COMMON)
 endif
 
diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
new file mode 100644
index 000..b7fd3d9
--- /dev/null
+++ b/src/spice-widget-egl.c
@@ -0,0 +1,576 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   Copyright (C) 2014-2015 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 .
+*/
+#include "config.h"
+
+#include 
+
+#define EGL_EGLEXT_PROTOTYPES
+#define GL_GLEXT_PROTOTYPES
+
+#include "spice-widget.h"
+#include "spice-widget-priv.h"
+#include "spice-gtk-session-priv.h"
+#include 
+
+#include 
+
+static const char *spice_egl_vertex_src =   \
+"   \
+  #version 130\n\
+\
+  in vec4 position; \
+  in vec2 texcoords;\
+  out vec2 tcoords; \
+  uniform mat4 mproj;   \
+\
+  void main()   \
+  { \
+tcoords = texcoords;\
+gl_Position = mproj * position; \
+  } \
+";
+
+static const char *spice_egl_fragment_src = \
+"   \
+  #version 130\n\
+\
+  in vec2 tcoords;  \
+  out vec4 fragmentColor;   \
+  uniform sampler2D samp;   \
+\
+  void  main()  \
+  { \
+fragmentColor = texture2D(samp, tcoords);   \
+  } \
+";
+
+static void apply_ortho(guint mproj, float left, float right,
+float bottom, float top, float near, float far)
+
+{
+float a = 2.0f / (right - left);
+float b = 2.0f / 

[Spice-devel] [PATCH v4 4/5] glib: add local GL scanout support

2016-02-04 Thread Marc-André Lureau
From: Marc-André Lureau 

Add spice-glib support for gl scanout messages.

A note about SpiceGlScanout: it is struct with scanout details,
registered as a boxed type, with associated gl-scanout property. That
way, it doesn't need a seperate signal for change notification and the
current scanout can be retrieve with gobject getter. Since boxed
property are always duplicated by g_object_get(), an additional
spice_display_get_gl_scanout() method returns the current scanout
without duplication (that's what spice-gtk display widget will use).

Signed-off-by: Marc-André Lureau 
---
 doc/reference/spice-gtk-sections.txt |   1 +
 src/channel-display.c| 170 ++-
 src/channel-display.h|  19 
 src/map-file |   4 +
 src/spice-glib-sym-file  |   4 +
 src/spice-marshal.txt|   1 +
 6 files changed, 196 insertions(+), 3 deletions(-)

diff --git a/doc/reference/spice-gtk-sections.txt 
b/doc/reference/spice-gtk-sections.txt
index f156a3f..a108386 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -158,6 +158,7 @@ SpiceAudioPrivate
 SpiceDisplayChannel
 SpiceDisplayChannelClass
 
+spice_display_get_gl_scanout
 spice_display_get_primary
 spice_display_change_preferred_compression
 
diff --git a/src/channel-display.c b/src/channel-display.c
index 6a474b1..8f99e94 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -82,6 +82,7 @@ struct _SpiceDisplayChannelPrivate {
 #ifdef G_OS_WIN32
 HDC dc;
 #endif
+SpiceGlScanout scanout;
 };
 
 G_DEFINE_TYPE(SpiceDisplayChannel, spice_display_channel, SPICE_TYPE_CHANNEL)
@@ -92,7 +93,8 @@ enum {
 PROP_WIDTH,
 PROP_HEIGHT,
 PROP_MONITORS,
-PROP_MONITORS_MAX
+PROP_MONITORS_MAX,
+PROP_GL_SCANOUT,
 };
 
 enum {
@@ -100,6 +102,7 @@ enum {
 SPICE_DISPLAY_PRIMARY_DESTROY,
 SPICE_DISPLAY_INVALIDATE,
 SPICE_DISPLAY_MARK,
+SPICE_DISPLAY_GL_DRAW,
 
 SPICE_DISPLAY_LAST_SIGNAL,
 };
@@ -118,9 +121,33 @@ static void 
spice_display_channel_reset_capabilities(SpiceChannel *channel);
 static void destroy_canvas(display_surface *surface);
 static void _msg_in_unref_func(gpointer data, gpointer user_data);
 static void display_session_mm_time_reset_cb(SpiceSession *session, gpointer 
data);
+static SpiceGlScanout* spice_gl_scanout_copy(const SpiceGlScanout *scanout);
+
+G_DEFINE_BOXED_TYPE(SpiceGlScanout, spice_gl_scanout,
+(GBoxedCopyFunc)spice_gl_scanout_copy,
+(GBoxedFreeFunc)spice_gl_scanout_free)
 
 /* -- */
 
+static SpiceGlScanout*
+spice_gl_scanout_copy(const SpiceGlScanout *scanout)
+{
+SpiceGlScanout *so = g_new(SpiceGlScanout, 1);
+
+*so = *scanout;
+so->fd = dup(so->fd);
+
+return so;
+}
+
+void
+spice_gl_scanout_free(SpiceGlScanout *scanout)
+{
+close(scanout->fd);
+
+g_free(scanout);
+}
+
 static void spice_display_channel_dispose(GObject *object)
 {
 SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(object)->priv;
@@ -130,6 +157,11 @@ static void spice_display_channel_dispose(GObject *object)
 c->mark_false_event_id = 0;
 }
 
+if (c->scanout.fd >= 0) {
+close(c->scanout.fd);
+c->scanout.fd = -1;
+}
+
 if (G_OBJECT_CLASS(spice_display_channel_parent_class)->dispose)
 G_OBJECT_CLASS(spice_display_channel_parent_class)->dispose(object);
 }
@@ -171,13 +203,13 @@ static void spice_display_channel_constructed(GObject 
*object)
 
G_OBJECT_CLASS(spice_display_channel_parent_class)->constructed(object);
 }
 
-
 static void spice_display_get_property(GObject*object,
guint   prop_id,
GValue *value,
GParamSpec *pspec)
 {
-SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(object)->priv;
+SpiceDisplayChannel *channel = SPICE_DISPLAY_CHANNEL(object);
+SpiceDisplayChannelPrivate *c = channel->priv;
 
 switch (prop_id) {
 case PROP_WIDTH: {
@@ -196,6 +228,10 @@ static void spice_display_get_property(GObject*object,
 g_value_set_uint(value, c->monitors_max);
 break;
 }
+case PROP_GL_SCANOUT: {
+g_value_set_static_boxed(value, spice_display_get_gl_scanout(channel));
+break;
+}
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
 break;
@@ -292,6 +328,23 @@ static void 
spice_display_channel_class_init(SpiceDisplayChannelClass *klass)
G_PARAM_STATIC_STRINGS));
 
 /**
+ * SpiceDisplayChannel:gl-scanout:
+ * @display: the #SpiceDisplayChannel that emitted the signal
+ *
+ * The last #SpiceGlScanout received.
+ *
+ * Since: 0.31
+ */
+

[Spice-devel] [PATCH v4 3/5] build-sys: check for epoxy-egl support

2016-02-04 Thread Marc-André Lureau
From: Marc-André Lureau 

The following code requires epoxy with egl support. Check for pkg-config
and egl headers.

Signed-off-by: Marc-André Lureau 
---
 configure.ac | 25 +
 1 file changed, 25 insertions(+)

diff --git a/configure.ac b/configure.ac
index 0beec7c..d59d6d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -243,6 +243,30 @@ AS_IF([test "x$have_phodav" = "xyes"],
 
 AM_CONDITIONAL([WITH_PHODAV], [test "x$have_phodav" = "xyes"])
 
+AC_ARG_ENABLE([epoxy],
+  AS_HELP_STRING([--enable-epoxy=@<:@auto/yes/no@:>@],
+  [Enable egl/epoxy support @<:@default=auto@:>@]),
+  [],
+  [enable_epoxy="auto"])
+
+if test "x$enable_epoxy" = "xno"; then
+  have_epoxy="no"
+else
+  PKG_CHECK_MODULES(EPOXY, [epoxy], [have_epoxy=yes], [have_epoxy=no])
+  AC_SUBST(EPOXY_CFLAGS)
+  AC_SUBST(EPOXY_LIBS)
+  if test "x$have_epoxy" = "xyes"; then
+AC_CHECK_HEADER([epoxy/egl.h],,have_epoxy=no)
+  fi
+  if test "x$have_epoxy" = "xno" && test "x$enable_epoxy" = "xyes"; then
+AC_MSG_ERROR([epoxy support explicitly requested, but required package is 
not available])
+  fi
+fi
+AS_IF([test "x$have_epoxy" = "xyes"],
+  AC_DEFINE(USE_EPOXY, [1], [Define if supporting epoxy]))
+
+AM_CONDITIONAL([WITH_EPOXY], [test "x$have_epoxy" = "xyes"])
+
 AC_ARG_WITH([audio],
   AS_HELP_STRING([--with-audio=@<:@gstreamer/pulse/auto/no@:>@], [For legacy 
compatibility only]),
   [SPICE_WARNING([--with-audio is deprecated. Use --enable-pulse and/or 
--enable-gstaudio instead])
@@ -705,6 +729,7 @@ AC_MSG_NOTICE([
 DBus: ${have_dbus}
 WebDAV support:   ${have_phodav}
 LZ4 support:  ${enable_lz4}
+epoxy:${have_epoxy}
 
 Now type 'make' to build $PACKAGE
 
-- 
2.5.0

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


[Spice-devel] [PATCH v4 0/5] Add OpenGL scanout drawing

2016-02-04 Thread Marc-André Lureau
The following series implements the x11 client-side support for
local-only shared OpenGL scanout rendering.

The implementation doesn't rely on gtkglarea since:
- it's quite recent (3.16 while rhel7 is currently 3.14)
- using gtkglarea isn't possible without either uncovenient API
  changes (new widget) or ABI break (SpiceDisplay widget to inherit
  from something more flexible than GtkDrawingArea)
- gtkglarea uses various gdk backends to setup GL context, such as
  glx, however dmabuf import requires egl.

I have a gtk3/gtkglarea-based branch, which will bring wayland
support. I would suggest to do first a release with gtk2/x11/egl
support before deprecating gtk2 and bumping gtk requirements.

v3->v4:
- fix rebase

v2->v3: after code review session with the team
- remove gslice usage
- drop gles in favour of desktop gl (probably more appropriate)
- explain the rationale for boxed scanout property and const getter in
  commit details
- some indent fixes

v1->v2:
- add some error handling code, fix gl objects leaks
- improve egl code to be compatible with future wayland series
- misc spellings

Marc-André Lureau (5):
  build-sys: bump to spice-protocol 0.12.11
  Add spice_channel_unix_read_fd()
  build-sys: check for epoxy-egl support
  glib: add local GL scanout support
  gtk: add spice-widget GL scanout support

 configure.ac |  27 +-
 doc/reference/spice-gtk-sections.txt |   1 +
 src/Makefile.am  |   9 +
 src/channel-display.c| 170 ++-
 src/channel-display.h|  19 ++
 src/map-file |   4 +
 src/spice-channel-priv.h |   3 +
 src/spice-channel.c  |  68 +
 src/spice-glib-sym-file  |   4 +
 src/spice-marshal.txt|   1 +
 src/spice-widget-egl.c   | 576 +++
 src/spice-widget-priv.h  |  30 ++
 src/spice-widget.c   | 151 +++--
 13 files changed, 1039 insertions(+), 24 deletions(-)
 create mode 100644 src/spice-widget-egl.c

-- 
2.5.0

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


[Spice-devel] [PATCH v4 1/5] build-sys: bump to spice-protocol 0.12.11

2016-02-04 Thread Marc-André Lureau
Needed for GL messages

Signed-off-by: Marc-André Lureau 
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 38db8b5..0beec7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,7 +70,7 @@ AC_CHECK_LIBM
 AC_SUBST(LIBM)
 
 AC_CONFIG_SUBDIRS([spice-common])
-PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= 0.12.10])
+PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= 0.12.11])
 
 COMMON_CFLAGS='-I ${top_srcdir}/spice-common/ ${SPICE_PROTOCOL_CFLAGS}'
 AC_SUBST(COMMON_CFLAGS)
-- 
2.5.0

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


Re: [Spice-devel] [PATCH v3 0/5] Add OpenGL scanout drawing

2016-02-04 Thread Marc-André Lureau
oops, something went wrong with the rebase, I'll resend.

On Fri, Feb 5, 2016 at 12:29 AM, Marc-André Lureau
 wrote:
> The following series implements the x11 client-side support for
> local-only shared OpenGL scanout rendering.
>
> The implementation doesn't rely on gtkglarea since:
> - it's quite recent (3.16 while rhel7 is currently 3.14)
> - using gtkglarea isn't possible without either uncovenient API
>   changes (new widget) or ABI break (SpiceDisplay widget to inherit
>   from something more flexible than GtkDrawingArea)
> - gtkglarea uses various gdk backends to setup GL context, such as
>   glx, however dmabuf import requires egl.
>
> I have a gtk3/gtkglarea-based branch, which will bring wayland
> support. I would suggest to do first a release with gtk2/x11/egl
> support before deprecating gtk2 and bumping gtk requirements.
>
> v2->v3: after code review session with the team
> - remove gslice usage
> - drop gles in favour of desktop gl (probably more appropriate)
> - explain the rationale for boxed scanout property and const getter in
>   commit details
> - some indent fixes
>
> v1->v2:
> - add some error handling code, fix gl objects leaks
> - improve egl code to be compatible with future wayland series
> - misc spellings
>
> Marc-André Lureau (5):
>   build-sys: bump to spice-protocol 0.12.11
>   Add spice_channel_unix_read_fd()
>   build-sys: check for epoxy-egl support
>   glib: add local GL scanout support
>   gtk: add spice-widget GL scanout support
>
>  configure.ac |  27 +-
>  doc/reference/spice-gtk-sections.txt |   1 +
>  src/Makefile.am  |   9 +
>  src/channel-display.c| 170 ++-
>  src/channel-display.h|  19 ++
>  src/map-file |   4 +
>  src/spice-channel-priv.h |   3 +
>  src/spice-channel.c  |  68 +
>  src/spice-glib-sym-file  |   4 +
>  src/spice-marshal.txt|   1 +
>  src/spice-widget-egl.c   | 576 
> +++
>  src/spice-widget-priv.h  |  30 ++
>  src/spice-widget.c   | 151 +++--
>  13 files changed, 1039 insertions(+), 24 deletions(-)
>  create mode 100644 src/spice-widget-egl.c
>
> --
> 2.5.0
>



-- 
Marc-André Lureau
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH v3 5/5] gtk: add spice-widget GL scanout support

2016-02-04 Thread Marc-André Lureau
From: Marc-André Lureau 

Hook to spice-glib events to show the GL scanout.

The opengl context is created with egl, and is currently
x11-only (supporting wayland with bare-egl doesn't seem trivial).

Using GtkGLArea is left for a future series, since SpiceDisplay widget
is a GtkDrawingArea and can't be replaced without breaking
ABI. Furthermore, GtkGLArea won't work on non-egl contexts, so this
approach is necessary on gtk+ < 3.16 or X11 (because gdk/x11 uses glx).

Signed-off-by: Marc-André Lureau 
---
 src/Makefile.am |   9 +
 src/channel-display.c   |   5 +-
 src/map-file|   2 +-
 src/spice-widget-egl.c  | 576 
 src/spice-widget-priv.h |  30 +++
 src/spice-widget.c  | 151 +++--
 6 files changed, 750 insertions(+), 23 deletions(-)
 create mode 100644 src/spice-widget-egl.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 37b89fe..68884e6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -122,6 +122,7 @@ SPICE_GTK_LIBADD_COMMON =   \
libspice-client-glib-2.0.la \
$(GTK_LIBS) \
$(CAIRO_LIBS)   \
+   $(EPOXY_LIBS)   \
$(LIBM) \
$(NULL)
 
@@ -160,17 +161,25 @@ SPICE_GTK_SOURCES_COMMON +=   \
 endif
 
 if WITH_GTK
+if WITH_EPOXY
+SPICE_GTK_SOURCES_COMMON +=\
+   spice-widget-egl.c  \
+   $(NULL)
+endif
+
 if HAVE_GTK_2
 libspice_client_gtk_2_0_la_DEPEDENCIES = $(GTK_SYMBOLS_FILE)
 libspice_client_gtk_2_0_la_LDFLAGS = $(SPICE_GTK_LDFLAGS_COMMON)
 libspice_client_gtk_2_0_la_LIBADD = $(SPICE_GTK_LIBADD_COMMON)
 libspice_client_gtk_2_0_la_SOURCES = $(SPICE_GTK_SOURCES_COMMON)
+libspice_client_gtk_2_0_la_CFLAGS = $(EPOXY_CFLAGS)
 nodist_libspice_client_gtk_2_0_la_SOURCES = $(nodist_SPICE_GTK_SOURCES_COMMON)
 else
 libspice_client_gtk_3_0_la_DEPEDENCIES = $(GTK_SYMBOLS_FILE)
 libspice_client_gtk_3_0_la_LDFLAGS = $(SPICE_GTK_LDFLAGS_COMMON)
 libspice_client_gtk_3_0_la_LIBADD = $(SPICE_GTK_LIBADD_COMMON)
 libspice_client_gtk_3_0_la_SOURCES = $(SPICE_GTK_SOURCES_COMMON)
+libspice_client_gtk_3_0_la_CFLAGS = $(EPOXY_CFLAGS)
 nodist_libspice_client_gtk_3_0_la_SOURCES = $(nodist_SPICE_GTK_SOURCES_COMMON)
 endif
 
diff --git a/src/channel-display.c b/src/channel-display.c
index 6a9bce9..8f99e94 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -132,8 +132,9 @@ G_DEFINE_BOXED_TYPE(SpiceGlScanout, spice_gl_scanout,
 static SpiceGlScanout*
 spice_gl_scanout_copy(const SpiceGlScanout *scanout)
 {
-SpiceGlScanout *so = g_slice_dup(SpiceGlScanout, scanout);
+SpiceGlScanout *so = g_new(SpiceGlScanout, 1);
 
+*so = *scanout;
 so->fd = dup(so->fd);
 
 return so;
@@ -144,7 +145,7 @@ spice_gl_scanout_free(SpiceGlScanout *scanout)
 {
 close(scanout->fd);
 
-g_slice_free(SpiceGlScanout, scanout);
+g_free(scanout);
 }
 
 static void spice_display_channel_dispose(GObject *object)
diff --git a/src/map-file b/src/map-file
index ced6f3c..123ef96 100644
--- a/src/map-file
+++ b/src/map-file
@@ -28,7 +28,7 @@ spice_display_get_grab_keys;
 spice_display_get_pixbuf;
 spice_display_get_primary;
 spice_display_get_type;
-spice_display_gl_draw_done  ;
+spice_display_gl_draw_done;
 spice_display_key_event_get_type;
 spice_display_mouse_ungrab;
 spice_display_new;
diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
new file mode 100644
index 000..b7fd3d9
--- /dev/null
+++ b/src/spice-widget-egl.c
@@ -0,0 +1,576 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   Copyright (C) 2014-2015 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 .
+*/
+#include "config.h"
+
+#include 
+
+#define EGL_EGLEXT_PROTOTYPES
+#define GL_GLEXT_PROTOTYPES
+
+#include "spice-widget.h"
+#include "spice-widget-priv.h"
+#include "spice-gtk-session-priv.h"
+#include 
+
+#include 
+
+static const char *spice_egl_vertex_src =   \
+"   \
+  #version 130\n\
+\
+  in vec4 position; \
+  in vec2 texcoords;\
+  out vec2 tcoords; \
+  uniform mat4 

[Spice-devel] [PATCH v3 4/5] glib: add local GL scanout support

2016-02-04 Thread Marc-André Lureau
From: Marc-André Lureau 

Add spice-glib support for gl scanout messages.

A note about SpiceGlScanout: it is struct with scanout details,
registered as a boxed type, with associated gl-scanout property. That
way, it doesn't need a seperate signal for change notification and the
current scanout can be retrieve with gobject getter. Since boxed
property are always duplicated by g_object_get(), an additional
spice_display_get_gl_scanout() method returns the current scanout
without duplication (that's what spice-gtk display widget will use).

Signed-off-by: Marc-André Lureau 
---
 doc/reference/spice-gtk-sections.txt |   1 +
 src/channel-display.c| 169 ++-
 src/channel-display.h|  19 
 src/map-file |   4 +
 src/spice-glib-sym-file  |   4 +
 src/spice-marshal.txt|   1 +
 6 files changed, 195 insertions(+), 3 deletions(-)

diff --git a/doc/reference/spice-gtk-sections.txt 
b/doc/reference/spice-gtk-sections.txt
index f156a3f..a108386 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -158,6 +158,7 @@ SpiceAudioPrivate
 SpiceDisplayChannel
 SpiceDisplayChannelClass
 
+spice_display_get_gl_scanout
 spice_display_get_primary
 spice_display_change_preferred_compression
 
diff --git a/src/channel-display.c b/src/channel-display.c
index 6a474b1..6a9bce9 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -82,6 +82,7 @@ struct _SpiceDisplayChannelPrivate {
 #ifdef G_OS_WIN32
 HDC dc;
 #endif
+SpiceGlScanout scanout;
 };
 
 G_DEFINE_TYPE(SpiceDisplayChannel, spice_display_channel, SPICE_TYPE_CHANNEL)
@@ -92,7 +93,8 @@ enum {
 PROP_WIDTH,
 PROP_HEIGHT,
 PROP_MONITORS,
-PROP_MONITORS_MAX
+PROP_MONITORS_MAX,
+PROP_GL_SCANOUT,
 };
 
 enum {
@@ -100,6 +102,7 @@ enum {
 SPICE_DISPLAY_PRIMARY_DESTROY,
 SPICE_DISPLAY_INVALIDATE,
 SPICE_DISPLAY_MARK,
+SPICE_DISPLAY_GL_DRAW,
 
 SPICE_DISPLAY_LAST_SIGNAL,
 };
@@ -118,9 +121,32 @@ static void 
spice_display_channel_reset_capabilities(SpiceChannel *channel);
 static void destroy_canvas(display_surface *surface);
 static void _msg_in_unref_func(gpointer data, gpointer user_data);
 static void display_session_mm_time_reset_cb(SpiceSession *session, gpointer 
data);
+static SpiceGlScanout* spice_gl_scanout_copy(const SpiceGlScanout *scanout);
+
+G_DEFINE_BOXED_TYPE(SpiceGlScanout, spice_gl_scanout,
+(GBoxedCopyFunc)spice_gl_scanout_copy,
+(GBoxedFreeFunc)spice_gl_scanout_free)
 
 /* -- */
 
+static SpiceGlScanout*
+spice_gl_scanout_copy(const SpiceGlScanout *scanout)
+{
+SpiceGlScanout *so = g_slice_dup(SpiceGlScanout, scanout);
+
+so->fd = dup(so->fd);
+
+return so;
+}
+
+void
+spice_gl_scanout_free(SpiceGlScanout *scanout)
+{
+close(scanout->fd);
+
+g_slice_free(SpiceGlScanout, scanout);
+}
+
 static void spice_display_channel_dispose(GObject *object)
 {
 SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(object)->priv;
@@ -130,6 +156,11 @@ static void spice_display_channel_dispose(GObject *object)
 c->mark_false_event_id = 0;
 }
 
+if (c->scanout.fd >= 0) {
+close(c->scanout.fd);
+c->scanout.fd = -1;
+}
+
 if (G_OBJECT_CLASS(spice_display_channel_parent_class)->dispose)
 G_OBJECT_CLASS(spice_display_channel_parent_class)->dispose(object);
 }
@@ -171,13 +202,13 @@ static void spice_display_channel_constructed(GObject 
*object)
 
G_OBJECT_CLASS(spice_display_channel_parent_class)->constructed(object);
 }
 
-
 static void spice_display_get_property(GObject*object,
guint   prop_id,
GValue *value,
GParamSpec *pspec)
 {
-SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(object)->priv;
+SpiceDisplayChannel *channel = SPICE_DISPLAY_CHANNEL(object);
+SpiceDisplayChannelPrivate *c = channel->priv;
 
 switch (prop_id) {
 case PROP_WIDTH: {
@@ -196,6 +227,10 @@ static void spice_display_get_property(GObject*object,
 g_value_set_uint(value, c->monitors_max);
 break;
 }
+case PROP_GL_SCANOUT: {
+g_value_set_static_boxed(value, spice_display_get_gl_scanout(channel));
+break;
+}
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
 break;
@@ -292,6 +327,23 @@ static void 
spice_display_channel_class_init(SpiceDisplayChannelClass *klass)
G_PARAM_STATIC_STRINGS));
 
 /**
+ * SpiceDisplayChannel:gl-scanout:
+ * @display: the #SpiceDisplayChannel that emitted the signal
+ *
+ * The last #SpiceGlScanout received.
+ *
+ * Since: 0.31
+ */
+

[Spice-devel] [PATCH v3 3/5] build-sys: check for epoxy-egl support

2016-02-04 Thread Marc-André Lureau
From: Marc-André Lureau 

The following code requires epoxy with egl support. Check for pkg-config
and egl headers.

Signed-off-by: Marc-André Lureau 
---
 configure.ac | 25 +
 1 file changed, 25 insertions(+)

diff --git a/configure.ac b/configure.ac
index 0beec7c..d59d6d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -243,6 +243,30 @@ AS_IF([test "x$have_phodav" = "xyes"],
 
 AM_CONDITIONAL([WITH_PHODAV], [test "x$have_phodav" = "xyes"])
 
+AC_ARG_ENABLE([epoxy],
+  AS_HELP_STRING([--enable-epoxy=@<:@auto/yes/no@:>@],
+  [Enable egl/epoxy support @<:@default=auto@:>@]),
+  [],
+  [enable_epoxy="auto"])
+
+if test "x$enable_epoxy" = "xno"; then
+  have_epoxy="no"
+else
+  PKG_CHECK_MODULES(EPOXY, [epoxy], [have_epoxy=yes], [have_epoxy=no])
+  AC_SUBST(EPOXY_CFLAGS)
+  AC_SUBST(EPOXY_LIBS)
+  if test "x$have_epoxy" = "xyes"; then
+AC_CHECK_HEADER([epoxy/egl.h],,have_epoxy=no)
+  fi
+  if test "x$have_epoxy" = "xno" && test "x$enable_epoxy" = "xyes"; then
+AC_MSG_ERROR([epoxy support explicitly requested, but required package is 
not available])
+  fi
+fi
+AS_IF([test "x$have_epoxy" = "xyes"],
+  AC_DEFINE(USE_EPOXY, [1], [Define if supporting epoxy]))
+
+AM_CONDITIONAL([WITH_EPOXY], [test "x$have_epoxy" = "xyes"])
+
 AC_ARG_WITH([audio],
   AS_HELP_STRING([--with-audio=@<:@gstreamer/pulse/auto/no@:>@], [For legacy 
compatibility only]),
   [SPICE_WARNING([--with-audio is deprecated. Use --enable-pulse and/or 
--enable-gstaudio instead])
@@ -705,6 +729,7 @@ AC_MSG_NOTICE([
 DBus: ${have_dbus}
 WebDAV support:   ${have_phodav}
 LZ4 support:  ${enable_lz4}
+epoxy:${have_epoxy}
 
 Now type 'make' to build $PACKAGE
 
-- 
2.5.0

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


[Spice-devel] [PATCH v3 1/5] build-sys: bump to spice-protocol 0.12.11

2016-02-04 Thread Marc-André Lureau
Needed for GL messages

Signed-off-by: Marc-André Lureau 
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 38db8b5..0beec7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,7 +70,7 @@ AC_CHECK_LIBM
 AC_SUBST(LIBM)
 
 AC_CONFIG_SUBDIRS([spice-common])
-PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= 0.12.10])
+PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= 0.12.11])
 
 COMMON_CFLAGS='-I ${top_srcdir}/spice-common/ ${SPICE_PROTOCOL_CFLAGS}'
 AC_SUBST(COMMON_CFLAGS)
-- 
2.5.0

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


[Spice-devel] [PATCH v3 2/5] Add spice_channel_unix_read_fd()

2016-02-04 Thread Marc-André Lureau
From: Marc-André Lureau 

Utility function used in the messages with socket ancillary fd.

Signed-off-by: Marc-André Lureau 
---
 src/spice-channel-priv.h |  3 +++
 src/spice-channel.c  | 68 
 2 files changed, 71 insertions(+)

diff --git a/src/spice-channel-priv.h b/src/spice-channel-priv.h
index d60ea73..526b661 100644
--- a/src/spice-channel-priv.h
+++ b/src/spice-channel-priv.h
@@ -205,6 +205,9 @@ void spice_vmc_write_async(SpiceChannel *self,
gpointer user_data);
 gssize spice_vmc_write_finish(SpiceChannel *self,
   GAsyncResult *result, GError **error);
+#ifdef G_OS_UNIX
+gint spice_channel_unix_read_fd(SpiceChannel *channel);
+#endif
 
 G_END_DECLS
 
diff --git a/src/spice-channel.c b/src/spice-channel.c
index ff85715..db2e5c2 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -872,6 +872,74 @@ static void spice_channel_write_msg(SpiceChannel *channel, 
SpiceMsgOut *out)
 spice_msg_out_unref(out);
 }
 
+#ifdef G_OS_UNIX
+static ssize_t read_fd(int fd, int *msgfd)
+{
+struct msghdr msg = { NULL, };
+struct iovec iov[1];
+union {
+struct cmsghdr cmsg;
+char control[CMSG_SPACE(sizeof(int))];
+} msg_control;
+struct cmsghdr *cmsg;
+ssize_t ret;
+char c;
+
+iov[0].iov_base = 
+iov[0].iov_len = 1;
+
+msg.msg_iov = iov;
+msg.msg_iovlen = 1;
+msg.msg_control = _control;
+msg.msg_controllen = sizeof(msg_control);
+
+ret = recvmsg(fd, , 0);
+if (ret > 0) {
+for (cmsg = CMSG_FIRSTHDR();
+ cmsg;
+ cmsg = CMSG_NXTHDR(, cmsg)) {
+if (cmsg->cmsg_len != CMSG_LEN(sizeof(int)) ||
+cmsg->cmsg_level != SOL_SOCKET ||
+cmsg->cmsg_type != SCM_RIGHTS) {
+continue;
+}
+
+memcpy(msgfd, CMSG_DATA(cmsg), sizeof(int));
+if (*msgfd < 0) {
+continue;
+}
+}
+}
+return ret;
+}
+
+G_GNUC_INTERNAL
+gint spice_channel_unix_read_fd(SpiceChannel *channel)
+{
+SpiceChannelPrivate *c = channel->priv;
+gint fd = -1;
+
+g_return_val_if_fail(g_socket_get_family(c->sock) == G_SOCKET_FAMILY_UNIX, 
-1);
+
+while (1) {
+/* g_socket_receive_message() is not convenient here because it
+ * reads all control messages, and overly complicated to deal with */
+if (read_fd(g_socket_get_fd(c->sock), ) > 0) {
+break;
+}
+
+if (errno == EWOULDBLOCK) {
+g_coroutine_socket_wait(>coroutine, c->sock, G_IO_IN);
+} else {
+g_warning("failed to get fd: %s", g_strerror(errno));
+return -1;
+}
+}
+
+return fd;
+}
+#endif
+
 /*
  * Read at least 1 more byte of data straight off the wire
  * into the requested buffer.
-- 
2.5.0

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


[Spice-devel] [PATCH v3 0/5] Add OpenGL scanout drawing

2016-02-04 Thread Marc-André Lureau
The following series implements the x11 client-side support for
local-only shared OpenGL scanout rendering.

The implementation doesn't rely on gtkglarea since:
- it's quite recent (3.16 while rhel7 is currently 3.14)
- using gtkglarea isn't possible without either uncovenient API
  changes (new widget) or ABI break (SpiceDisplay widget to inherit
  from something more flexible than GtkDrawingArea)
- gtkglarea uses various gdk backends to setup GL context, such as
  glx, however dmabuf import requires egl.

I have a gtk3/gtkglarea-based branch, which will bring wayland
support. I would suggest to do first a release with gtk2/x11/egl
support before deprecating gtk2 and bumping gtk requirements.

v2->v3: after code review session with the team
- remove gslice usage
- drop gles in favour of desktop gl (probably more appropriate)
- explain the rationale for boxed scanout property and const getter in
  commit details
- some indent fixes

v1->v2:
- add some error handling code, fix gl objects leaks
- improve egl code to be compatible with future wayland series
- misc spellings

Marc-André Lureau (5):
  build-sys: bump to spice-protocol 0.12.11
  Add spice_channel_unix_read_fd()
  build-sys: check for epoxy-egl support
  glib: add local GL scanout support
  gtk: add spice-widget GL scanout support

 configure.ac |  27 +-
 doc/reference/spice-gtk-sections.txt |   1 +
 src/Makefile.am  |   9 +
 src/channel-display.c| 170 ++-
 src/channel-display.h|  19 ++
 src/map-file |   4 +
 src/spice-channel-priv.h |   3 +
 src/spice-channel.c  |  68 +
 src/spice-glib-sym-file  |   4 +
 src/spice-marshal.txt|   1 +
 src/spice-widget-egl.c   | 576 +++
 src/spice-widget-priv.h  |  30 ++
 src/spice-widget.c   | 151 +++--
 13 files changed, 1039 insertions(+), 24 deletions(-)
 create mode 100644 src/spice-widget-egl.c

-- 
2.5.0

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


Re: [Spice-devel] [PATCH v6 08/10] usbdk: Load hide rules for auto-redirected devices

2016-02-04 Thread Jonathon Jongsma
On Thu, 2015-10-29 at 17:26 +0200, Dmitry Fleytman wrote:
> Hide rules order UsbDk to avoid showing specific USB
> devices to Windows PnP manager.
> 
> Spice-gtk loads hide rules for devices that should be
> automatically redirected on connection to prevent Windows
> from showing "New Hardware Found" wizard window for USB
> devices that do not have driver on the local system.
> 
> Signed-off-by: Dmitry Fleytman 
> ---
>  src/usb-device-manager.c | 58
> 
>  1 file changed, 58 insertions(+)
> 
> diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
> index dd55276..d5fec8f 100644
> --- a/src/usb-device-manager.c
> +++ b/src/usb-device-manager.c
> @@ -29,6 +29,10 @@
>  #include 
>  #include 
>  
> +#ifdef G_OS_WIN32
> +#include "usbdk_api.h"
> +#endif
> +
>  #if defined(USE_GUDEV)
>  #include 
>  #elif defined(G_OS_WIN32)
> @@ -121,6 +125,8 @@ struct _SpiceUsbDeviceManagerPrivate {
>  libusb_hotplug_callback_handle hp_handle;
>  #endif
>  #ifdef G_OS_WIN32
> +usbdk_api_wrapper *usbdk_api;
> +HANDLE usbdk_hider_handle;
>  SpiceWinUsbDriver *installer;
>  #endif
>  gboolean   use_usbclerk;
> @@ -183,6 +189,9 @@ static void spice_usb_device_unref(SpiceUsbDevice
> *device);
>  #ifdef G_OS_WIN32
>  static guint8 spice_usb_device_get_state(SpiceUsbDevice *device);
>  static void  spice_usb_device_set_state(SpiceUsbDevice *device, guint8 s);
> +
> +static void _usbdk_autoredir_enable(SpiceUsbDeviceManager *manager);
> +static void _usbdk_autoredir_disable(SpiceUsbDeviceManager *manager);
>  #endif
>  
>  static gboolean spice_usb_manager_device_equal_libdev(SpiceUsbDeviceManager
> *manager,
> @@ -364,6 +373,12 @@ static void spice_usb_device_manager_finalize(GObject
> *gobject)
>  g_free(priv->auto_connect_filter);
>  g_free(priv->redirect_on_connect);
>  
> +#ifdef G_OS_WIN32
> +if (!priv->use_usbclerk) {
> +if(priv->auto_connect)
> +_usbdk_autoredir_disable(self);
> +}
> +#endif
>  /* Chain up to the parent class */
>  if (G_OBJECT_CLASS(spice_usb_device_manager_parent_class)->finalize)
>  G_OBJECT_CLASS(spice_usb_device_manager_parent_class)
> ->finalize(gobject);
> @@ -415,6 +430,15 @@ static void spice_usb_device_manager_set_property(GObject
>*gobject,
>  break;
>  case PROP_AUTO_CONNECT:
>  priv->auto_connect = g_value_get_boolean(value);

It does not appear that PROP_AUTO_CONNECT is a construct-only property, so this
property could theoretically be called multiple times. From looking at the
_usb_autoredir_(en|dis)able() functions below, it doesn't look like a good idea
to call them multiple times. In addition, it appears racy since
 _usbdk_autoredir_enable() depends on redirect_on_connect. If that property is
not set before this one, it will return without doing anything. To avoid the
race, these calls should probably go into a 'constructed' vfunc.

> +#ifdef G_OS_WIN32
> +if (!priv->use_usbclerk) {
> +if (priv->auto_connect) {
> +_usbdk_autoredir_enable(self);
> +} else {
> +_usbdk_autoredir_disable(self);
> +}
> +}
> +#endif
>  break;
>  case PROP_AUTO_CONNECT_FILTER: {
>  const gchar *filter = g_value_get_string(value);
> @@ -1856,6 +1880,40 @@ guint8 spice_usb_device_get_state(SpiceUsbDevice
> *device)
>  
>  return info->state;
>  }
> +static
> +void _usbdk_autoredir_enable(SpiceUsbDeviceManager *manager)
> +{
> +SpiceUsbDeviceManagerPrivate *priv = manager->priv;
> +g_return_if_fail(!priv->use_usbclerk);
> +
> +if (priv->redirect_on_connect == NULL) {

as I said above, if the 'redirect-on-connect' property is not set before 'auto
-connect', this function will return without doing anythign and print a debug
statement.

> +SPICE_DEBUG("No autoredirect rules, no hider setup needed");
> +return;
> +}
> +
> +priv->usbdk_hider_handle = usbdk_create_hider_handle(priv->usbdk_api);

Also, if this function is called multiple times, I think we'll leak the handle
here.

> +if (priv->usbdk_hider_handle == NULL) {
> +g_warning("Failed to instantiate UsbDk hider interface");
> +return;
> +}
> +
> +usbdk_api_set_hide_rules(priv->usbdk_api,
> + priv->usbdk_hider_handle,
> + priv->redirect_on_connect);
> +}
> +
> +static
> +void _usbdk_autoredir_disable(SpiceUsbDeviceManager *manager)
> +{
> +SpiceUsbDeviceManagerPrivate *priv = manager->priv;
> +g_return_if_fail(!priv->use_usbclerk);
> +
> +if (priv->usbdk_hider_handle != NULL) {
> +usbdk_clear_hide_rules(priv->usbdk_api, priv->usbdk_hider_handle);
> +usbdk_close_hider_handle(priv->usbdk_api, priv->usbdk_hider_handle);
> +priv->usbdk_hider_handle = NULL;
> +}
> +}
>  #endif
>  
>  static 

Re: [Spice-devel] [PATCH] record: save real time during recording

2016-02-04 Thread Pavel Grunt
On Thu, 2016-02-04 at 16:10 +, Frediano Ziglio wrote:
> Instead of using CPU time use a timer depending on real times.
> Currently that time in the record log is not used.
> However if we want to reproduce problems with stream would be useful
> to have real times instead.
Yes, it makes sense

Thanks,
Pavel

Acked-by: Pavel Grunt 

> 
> 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 df24a5b..e70c9df 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -242,7 +242,7 @@ static int red_process_display(RedWorker *worker,
> int *ring_is_empty)
>  
>  if (worker->record_fd)
>  red_record_qxl_command(worker->record_fd, 
> >mem_slots, ext_cmd,
> -   stat_now(CLOCK_THREAD_CPUTIME_ID)
> );
> +   stat_now(CLOCK_MONOTONIC));
>  
>  stat_inc_counter(worker->command_counter, 1);
>  worker->display_poll_tries = 0;
> @@ -1221,7 +1221,7 @@ static void worker_dispatcher_record(void
> *opaque, uint32_t message_type, void *
>  {
>  RedWorker *worker = opaque;
>  
> -red_record_event(worker->record_fd, 1, message_type,
> stat_now(CLOCK_THREAD_CPUTIME_ID));
> +red_record_event(worker->record_fd, 1, message_type,
> stat_now(CLOCK_MONOTONIC));
>  }
>  
>  static void register_callbacks(Dispatcher *dispatcher)
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [vd-agent-win32 1/2] Detect and use the new WDDM driver

2016-02-04 Thread Javier Celaya
When setting a new desktop resolution, detect whether the XDDM or the
WDDM driver is loaded, and use the correct API.

This patch is based on the one by Vadim Rozenfeld, with some
improvements:
- Valid for both the XDDM and the WDDM drivers.
- Avoids flickering when the target resolution is the current one.
- Does not define unused constants.
---
 common/vdcommon.h  | 66 ++
 vdagent/desktop_layout.cpp | 90 +++---
 2 files changed, 144 insertions(+), 12 deletions(-)

diff --git a/common/vdcommon.h b/common/vdcommon.h
index 93bb673..f40e68e 100644
--- a/common/vdcommon.h
+++ b/common/vdcommon.h
@@ -36,6 +36,72 @@ typedef CRITICAL_SECTION mutex_t;
 #define VD_AGENT_REGISTRY_KEY "SOFTWARE\\Red Hat\\Spice\\vdagent\\"
 #define VD_AGENT_STOP_EVENT   TEXT("Global\\vdagent_stop_event")
 
+#ifndef NT_SUCCESS
+#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
+#endif
+
+// WDDM data types and constants
+#define D3DKMT_HANDLE ULONG
+
+typedef UINT D3DDDI_VIDEO_PRESENT_SOURCE_ID;
+
+struct D3DKMT_OPENADAPTERFROMHDC {
+HDC hDc;// in:  DC that maps to a 
single display
+D3DKMT_HANDLE   hAdapter;   // out: adapter handle
+LUIDAdapterLuid;// out: adapter LUID
+D3DDDI_VIDEO_PRESENT_SOURCE_ID  VidPnSourceId;  // out: VidPN source ID 
for that particular display
+};
+
+enum D3DKMT_ESCAPETYPE {
+D3DKMT_ESCAPE_DRIVERPRIVATE =  0,
+};
+
+struct D3DDDI_ESCAPEFLAGS {
+// We do not care about these flags
+UINT Value;
+};
+
+struct D3DKMT_ESCAPE {
+D3DKMT_HANDLE   hAdapter;   // in: adapter handle
+D3DKMT_HANDLE   hDevice;// in: device handle [Optional]
+D3DKMT_ESCAPETYPE   Type;   // in: escape type.
+D3DDDI_ESCAPEFLAGS  Flags;  // in: flags
+VOID*   pPrivateDriverData; // in/out: escape data
+UINTPrivateDriverDataSize;  // in: size of escape data
+D3DKMT_HANDLE   hContext;   // in: context handle 
[Optional]
+};
+
+struct D3DKMT_CLOSEADAPTER {
+D3DKMT_HANDLE hAdapter;
+};
+
+typedef NTSTATUS (APIENTRY *PFND3DKMT_CLOSEADAPTER)(_In_ CONST 
D3DKMT_CLOSEADAPTER*);
+typedef NTSTATUS (APIENTRY *PFND3DKMT_ESCAPE)(_In_ CONST D3DKMT_ESCAPE*);
+typedef NTSTATUS (APIENTRY *PFND3DKMT_OPENADAPTERFROMHDC)(_Inout_ 
D3DKMT_OPENADAPTERFROMHDC*);
+
+class D3DKMTLibrary {
+public:
+~D3DKMTLibrary();
+static D3DKMTLibrary& singleton() {
+static D3DKMTLibrary instance;
+return instance;
+}
+bool found() {
+return _hGDI && _pD3DKMTCloseAdapter && _pD3DKMTEscape && 
_pD3DKMTOpenAdapterFromHdc;
+}
+D3DKMT_HANDLE open_adapter_from_hdc(HDC hdc);
+NTSTATUS escape_driver_private(D3DKMT_HANDLE adapter, VOID* priv_data, 
UINT size);
+NTSTATUS close_adapter(D3DKMT_HANDLE adapter);
+
+private:
+D3DKMTLibrary();
+
+HINSTANCE _hGDI;
+PFND3DKMT_CLOSEADAPTER _pD3DKMTCloseAdapter;
+PFND3DKMT_ESCAPE _pD3DKMTEscape;
+PFND3DKMT_OPENADAPTERFROMHDC _pD3DKMTOpenAdapterFromHdc;
+};
+
 #if defined __GNUC__
 #define ALIGN_GCC __attribute__ ((packed))
 #define ALIGN_VC
diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index a7666ca..b5e8cfa 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -265,6 +265,53 @@ bool DesktopLayout::get_qxl_device_id(WCHAR* device_key, 
DWORD* device_id)
 return key_found;
 }
 
+D3DKMTLibrary::D3DKMTLibrary()
+: _pD3DKMTCloseAdapter(NULL)
+, _pD3DKMTEscape(NULL)
+, _pD3DKMTOpenAdapterFromHdc(NULL)
+{
+_hGDI = LoadLibrary(L"gdi32.dll");
+if (_hGDI) {
+_pD3DKMTCloseAdapter = (PFND3DKMT_CLOSEADAPTER)GetProcAddress(_hGDI, 
"D3DKMTCloseAdapter");
+_pD3DKMTEscape = (PFND3DKMT_ESCAPE)GetProcAddress(_hGDI, 
"D3DKMTEscape");
+_pD3DKMTOpenAdapterFromHdc = 
(PFND3DKMT_OPENADAPTERFROMHDC)GetProcAddress(_hGDI, "D3DKMTOpenAdapterFromHdc");
+}
+}
+
+D3DKMTLibrary::~D3DKMTLibrary()
+{
+if (_hGDI)
+FreeLibrary(_hGDI);
+}
+
+D3DKMT_HANDLE D3DKMTLibrary::open_adapter_from_hdc(HDC hdc)
+{
+D3DKMT_OPENADAPTERFROMHDC func_params = {0};
+func_params.hDc = hdc;
+if (NT_SUCCESS(_pD3DKMTOpenAdapterFromHdc(_params)))
+return func_params.hAdapter;
+else
+return 0;
+}
+
+NTSTATUS D3DKMTLibrary::escape_driver_private(D3DKMT_HANDLE adapter, VOID* 
priv_data, UINT size)
+{
+D3DKMT_ESCAPE func_params = {0};
+func_params.hAdapter = adapter;
+func_params.Flags.Value = 0;
+func_params.Type = D3DKMT_ESCAPE_DRIVERPRIVATE;
+func_params.pPrivateDriverData = priv_data;
+func_params.PrivateDriverDataSize = size;
+return _pD3DKMTEscape(_params);
+}
+
+NTSTATUS D3DKMTLibrary::close_adapter(D3DKMT_HANDLE adapter)
+{
+D3DKMT_CLOSEADAPTER func_params = {0};
+func_params.hAdapter = adapter;
+

[Spice-devel] [vd-agent-win32 2/2] Use CCD API to update the WDDM display modes.

2016-02-04 Thread Javier Celaya
When a new custom display mode is added, the current WDDM driver notifies
a disconnection and reconnection of the virtual monitor to force Windows
to update the display modes. This produces an ugly effect, keeping the
screen black for up to some seconds and usually not repainting it
afterwards.

This patch uses the CCD API to update the display modes, and produces
just a quick flash followed by a whole screen repaint. For best results,
it should be used with a driver that does not update the display modes
by itself, but it is still compatible with the current implementation.
---
 common/vdcommon.h  | 40 +++
 vdagent/desktop_layout.cpp | 68 +-
 2 files changed, 107 insertions(+), 1 deletion(-)

diff --git a/common/vdcommon.h b/common/vdcommon.h
index f40e68e..29437c3 100644
--- a/common/vdcommon.h
+++ b/common/vdcommon.h
@@ -102,6 +102,46 @@ private:
 PFND3DKMT_OPENADAPTERFROMHDC _pD3DKMTOpenAdapterFromHdc;
 };
 
+// CCD API
+#define SDC_APPLY 0x0080
+#define SDC_USE_SUPPLIED_DISPLAY_CONFIG 0x0020
+#define SDC_FORCE_MODE_ENUMERATION 0x1000
+#define QDC_ALL_PATHS 1
+struct DISPLAYCONFIG_PATH_INFO;
+struct DISPLAYCONFIG_MODE_INFO;
+struct DISPLAYCONFIG_TOPOLOGY_ID;
+typedef LONG (*PFNGETDISPLAYCONFIGBUFFERSIZES)(UINT32, UINT32*, UINT32*);
+typedef LONG (*PFNQUERYDISPLAYCONFIG)(UINT32, UINT32*, 
DISPLAYCONFIG_PATH_INFO*, UINT32*,
+  DISPLAYCONFIG_MODE_INFO*, 
DISPLAYCONFIG_TOPOLOGY_ID*);
+typedef LONG (*PFNSETDISPLAYCONFIG)(UINT32, DISPLAYCONFIG_PATH_INFO*, UINT32,
+DISPLAYCONFIG_MODE_INFO*, UINT32);
+class CCDLibrary {
+public:
+~CCDLibrary();
+static CCDLibrary& singleton() {
+static CCDLibrary instance;
+return instance;
+}
+bool found() {
+return _hUser32 && _pGetDisplayConfigBufferSizes &&
+   _pQuieryDisplayConfig && _pSetDisplayConfig;
+}
+LONG get_display_config_buffer_sizes(UINT32* num_paths, UINT32* num_modes);
+LONG query_display_config(UINT32* num_paths, DISPLAYCONFIG_PATH_INFO* 
paths,
+  UINT32* num_modes, DISPLAYCONFIG_MODE_INFO* 
modes);
+LONG set_display_config(UINT32 num_paths, DISPLAYCONFIG_PATH_INFO* paths,
+UINT32 num_modes, DISPLAYCONFIG_MODE_INFO* modes,
+UINT32 flags);
+
+private:
+CCDLibrary();
+
+HINSTANCE _hUser32;
+PFNGETDISPLAYCONFIGBUFFERSIZES _pGetDisplayConfigBufferSizes;
+PFNQUERYDISPLAYCONFIG _pQuieryDisplayConfig;
+PFNSETDISPLAYCONFIG _pSetDisplayConfig;
+};
+
 #if defined __GNUC__
 #define ALIGN_GCC __attribute__ ((packed))
 #define ALIGN_VC
diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index b5e8cfa..92493f3 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -312,6 +312,70 @@ NTSTATUS D3DKMTLibrary::close_adapter(D3DKMT_HANDLE 
adapter)
 return _pD3DKMTCloseAdapter(_params);
 }
 
+CCDLibrary::CCDLibrary()
+: _pGetDisplayConfigBufferSizes(NULL)
+, _pQuieryDisplayConfig(NULL)
+, _pSetDisplayConfig(NULL)
+{
+_hUser32 = LoadLibrary(L"User32.dll");
+if (_hUser32) {
+_pGetDisplayConfigBufferSizes = 
(PFNGETDISPLAYCONFIGBUFFERSIZES)GetProcAddress(_hUser32, 
"GetDisplayConfigBufferSizes");
+_pQuieryDisplayConfig = 
(PFNQUERYDISPLAYCONFIG)GetProcAddress(_hUser32, "QueryDisplayConfig");
+_pSetDisplayConfig = (PFNSETDISPLAYCONFIG)GetProcAddress(_hUser32, 
"SetDisplayConfig");
+}
+}
+
+
+CCDLibrary::~CCDLibrary()
+{
+if (_hUser32)
+FreeLibrary(_hUser32);
+}
+
+LONG CCDLibrary::get_display_config_buffer_sizes(UINT32* num_paths, UINT32* 
num_modes)
+{
+return _pGetDisplayConfigBufferSizes(QDC_ALL_PATHS, num_paths, num_modes);
+}
+
+LONG CCDLibrary::query_display_config(UINT32* num_paths, 
DISPLAYCONFIG_PATH_INFO* paths,
+  UINT32* num_modes, 
DISPLAYCONFIG_MODE_INFO* modes)
+{
+return _pQuieryDisplayConfig(QDC_ALL_PATHS, num_paths, paths, num_modes, 
modes, NULL);
+}
+
+LONG CCDLibrary::set_display_config(UINT32 num_paths, DISPLAYCONFIG_PATH_INFO* 
paths,
+UINT32 num_modes, DISPLAYCONFIG_MODE_INFO* 
modes,
+UINT32 flags)
+{
+return _pSetDisplayConfig(num_paths, paths, num_modes, modes, flags);
+}
+
+static void update_display_modes()
+{
+// The trick here is to call SetDisplayConfig with the current config and
+// the SDC_FORCE_MODE_ENUMERATION flag
+CCDLibrary& ccd = CCDLibrary::singleton();
+if (!ccd.found()) return;
+UINT32 num_paths = 0, num_modes = 0;
+DISPLAYCONFIG_PATH_INFO * paths;
+DISPLAYCONFIG_MODE_INFO * modes;
+LONG status = ccd.get_display_config_buffer_sizes(_paths, _modes);
+if (NT_SUCCESS(status)) {
+// Being conservative, struct sizes are under 100 bytes
+paths 

Re: [Spice-devel] [vd-agent-win32 0/2] Add support for WDDM driver

2016-02-04 Thread Fabio Fantoni
Il 04/02/2016 13:31, Javier Celaya ha scritto:
> This patch set adds support for dynamic resolution changes with the WDDM
> driver on Windows >= 8. It is based on the one sent by Vadim Rozenfeld
> with some improvements:
>
> - It detects both the XDDM driver and the WDDM driver, and uses the
>   correct API.
> - It detects if the client is trying to set the same resolution again,
>   and does nothing. This is the result of the client detecting a primary
>   surface destruction/construction when the resolution changes, and
>   asking for a resolution change again. This bug does not happen with
>   the XDDM driver, so it may be avoidable in some other way.
> - It uses an alternative method to update the list of display modes,
>   that results in a nicer effect when changing the resolution. This
>   method is compatible with the current driver implementation (v0.12),
>   but for best results we have modified the driver to drop the previous
>   method and to improve support of hardware pointers. The source can be
>   found in https://github.com/flexvdi/qxl-dod, and precompiled and signed
>   binaries can be downloaded from http://depot.flexvdi.com/guest-tools/.

Big thanks for help improving windows>=8 support (unfortunately still
overlooked).
I want do a fast test to see is your changes solve the bugs (and/or
occasional hangs) I have found trying spice-guest-tools 0.100 and
qxlwddm-0.12.zip on windows 10 guests. For tests your improvements I can
simply install spice-guest-tools.exe inside
flexvdi-guest-tools-2.2.3.exe and qxlwddm-0.13-flexvdi.zip?

Thanks for any reply and sorry for my bad english.

>
> Javier Celaya (2):
>   Detect and use the new WDDM driver
>   Use CCD API to update the WDDM display modes.
>
>  common/vdcommon.h  | 106 ++
>  vdagent/desktop_layout.cpp | 156 
> +
>  2 files changed, 250 insertions(+), 12 deletions(-)
>




smime.p7s
Description: Firma crittografica S/MIME
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] Add lz4 support in qemu parameters

2016-02-04 Thread Fabio Fantoni
Hi, lz4 support in qemu parameters is still missed.
I'm actually using the patch posted long time ago by Javier Celaya with
only the small version check fix (spice>=0.12.6 instead of >=0.12.7):
https://github.com/Fantu/qemu/commit/e66e58053cea9f0aff71c9d9b8b822e40f5ba266
Tested and working.
Original was here: https://patchwork.freedesktop.org/patch/41072/
Now that spice 0.12.6 with lz4 support has been released can be this
patch (plus the version fix) upstreamed for have lz4 support
"out-of-the-box" or improvements is needed before accepting it?

Thanks for any reply and sorry for my bad english.



smime.p7s
Description: Firma crittografica S/MIME
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [vd-agent-win32 0/2] Add support for WDDM driver

2016-02-04 Thread Javier Celaya
This patch set adds support for dynamic resolution changes with the WDDM
driver on Windows >= 8. It is based on the one sent by Vadim Rozenfeld
with some improvements:

- It detects both the XDDM driver and the WDDM driver, and uses the
  correct API.
- It detects if the client is trying to set the same resolution again,
  and does nothing. This is the result of the client detecting a primary
  surface destruction/construction when the resolution changes, and
  asking for a resolution change again. This bug does not happen with
  the XDDM driver, so it may be avoidable in some other way.
- It uses an alternative method to update the list of display modes,
  that results in a nicer effect when changing the resolution. This
  method is compatible with the current driver implementation (v0.12),
  but for best results we have modified the driver to drop the previous
  method and to improve support of hardware pointers. The source can be
  found in https://github.com/flexvdi/qxl-dod, and precompiled and signed
  binaries can be downloaded from http://depot.flexvdi.com/guest-tools/.

Javier Celaya (2):
  Detect and use the new WDDM driver
  Use CCD API to update the WDDM display modes.

 common/vdcommon.h  | 106 ++
 vdagent/desktop_layout.cpp | 156 +
 2 files changed, 250 insertions(+), 12 deletions(-)

-- 
2.4.3

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


[Spice-devel] [phodav PATCH 0/4] phodav automounting pre-patch

2016-02-04 Thread Lukas Venhoda
Small bugs, that I found when working on windows shared folder auto mounting

Theese patches were already ACKed by elmarco, but since the last one
(the big one) wasn't ACKed, the patches weren't pushed.

There's work to be done on automounting itself, but theese patches would
just sit in the mailing list, until I complete the automounting itself.

Lukas Venhoda (4):
  spice-webdavd: Safer MDNS Unregister
  spice-webdavd: Hide client folder when sharing disabled
  spice-webdavd: Alert when CreateFile fails
  spice-webdavd: Option to run without service on Windows

 spice/spice-webdavd.c | 45 ++---
 1 file changed, 38 insertions(+), 7 deletions(-)

--
2.5.0

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


Re: [Spice-devel] [PATCH v3 8/9] Handle GL_DRAW messages

2016-02-04 Thread Frediano Ziglio
> 
> Create an async, and marshall the GL_DRAW message. Count number of
> clients, and wait until gl_draw_async_count is 0 to complete the async.
> The count is going to be updated in the following patch when the client
> is done with the draw.
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  server/dcc-send.c| 14 ++
>  server/dcc.c | 23 +++
>  server/dcc.h |  9 +
>  server/display-channel.c | 22 ++
>  server/display-channel.h |  3 +++
>  server/red-dispatcher.c  | 14 ++
>  server/red-dispatcher.h  |  1 +
>  server/red-worker.c  | 14 ++
>  server/reds.h|  1 +
>  9 files changed, 101 insertions(+)
> 
> diff --git a/server/dcc-send.c b/server/dcc-send.c
> index a9cc19c..3af5760 100644
> --- a/server/dcc-send.c
> +++ b/server/dcc-send.c
> @@ -2321,6 +2321,17 @@ end:
>  pthread_mutex_unlock(>st->scanout_mutex);
>  }
>  
> +static void marshall_gl_draw(RedChannelClient *rcc,
> + SpiceMarshaller *m,
> + PipeItem *item)
> +{
> +GlDrawItem *p = SPICE_CONTAINEROF(item, GlDrawItem, base);
> +
> +red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_GL_DRAW, NULL);
> +spice_marshall_msg_display_gl_draw(m, >draw);
> +}
> +
> +
>  static void begin_send_message(RedChannelClient *rcc)
>  {
>  DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
> @@ -2435,6 +2446,9 @@ void dcc_send_item(DisplayChannelClient *dcc, PipeItem
> *pipe_item)
>  case PIPE_ITEM_TYPE_GL_SCANOUT:
>  marshall_gl_scanout(rcc, m, pipe_item);
>  break;
> +case PIPE_ITEM_TYPE_GL_DRAW:
> +marshall_gl_draw(rcc, m, pipe_item);
> +break;
>  default:
>  spice_warn_if_reached();
>  }
> diff --git a/server/dcc.c b/server/dcc.c
> index 58ae55c..6972616 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -586,6 +586,27 @@ PipeItem *dcc_gl_scanout_item_new(RedChannelClient *rcc,
> void *data, int num)
>  return >base;
>  }
>  
> +PipeItem *dcc_gl_draw_item_new(RedChannelClient *rcc, void *data, int num)
> +{
> +DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
> +const SpiceMsgDisplayGlDraw *draw = data;
> +GlDrawItem *item = spice_new(GlDrawItem, 1);
> +spice_return_val_if_fail(item != NULL, NULL);
> +
> +if (!red_channel_client_test_remote_cap(rcc,
> SPICE_DISPLAY_CAP_GL_SCANOUT)) {
> +spice_printerr("FIXME: client does not support GL scanout");
> +red_channel_client_disconnect(rcc);
> +return NULL;
> +}
> +
> +dcc->gl_draw_ongoing = TRUE;
> +item->draw = *draw;
> +red_channel_pipe_item_init(rcc->channel, >base,
> +   PIPE_ITEM_TYPE_GL_DRAW);
> +
> +return >base;
> +}
> +
>  void dcc_destroy_surface(DisplayChannelClient *dcc, uint32_t surface_id)
>  {
>  DisplayChannel *display;
> @@ -1558,6 +1579,7 @@ static void
> release_item_after_push(DisplayChannelClient *dcc, PipeItem *item)
>  image_item_unref((ImageItem *)item);
>  break;
>  case PIPE_ITEM_TYPE_GL_SCANOUT:
> +case PIPE_ITEM_TYPE_GL_DRAW:
>  case PIPE_ITEM_TYPE_VERB:
>  free(item);
>  break;
> @@ -1633,6 +1655,7 @@ static void
> release_item_before_push(DisplayChannelClient *dcc, PipeItem *item)
>  case PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE:
>  case PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT:
>  case PIPE_ITEM_TYPE_GL_SCANOUT:
> +case PIPE_ITEM_TYPE_GL_DRAW:
>  free(item);
>  break;
>  default:
> diff --git a/server/dcc.h b/server/dcc.h
> index 4ef6073..842b7d4 100644
> --- a/server/dcc.h
> +++ b/server/dcc.h
> @@ -111,6 +111,7 @@ struct DisplayChannelClient {
>  int use_mjpeg_encoder_rate_control;
>  uint32_t streams_max_latency;
>  uint64_t streams_max_bit_rate;
> +bool gl_draw_ongoing;
>  };
>  
>  #define DCC_TO_WORKER(dcc)  \
> @@ -128,6 +129,12 @@ typedef struct GlScanoutUnixItem {
>  PipeItem base;
>  } GlScanoutUnixItem;
>  
> +typedef struct GlDrawItem {
> +PipeItem base;
> +SpiceMsgDisplayGlDraw draw;
> +int sent;

The sent field is never used in the code

> +} GlDrawItem;
> +
>  typedef struct ImageItem {
>  PipeItem link;
>  int refs;
> @@ -213,6 +220,8 @@ intdcc_drawable_is_in_pipe
> (DisplayCha
>
> Drawable
>
> *drawable);
>  PipeItem * dcc_gl_scanout_item_new
>  (RedChannelClient *rcc,
>void
>*data,
>int
> 

[Spice-devel] [phodav PATCH 2/4] spice-webdavd: Hide client folder when sharing disabled

2016-02-04 Thread Lukas Venhoda
After disabling sharing, remove client folder from file explorer.
Show client folder again after sharing is re-enabled.
---
Changes
 - Split patch into 2
---
 spice/spice-webdavd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/spice/spice-webdavd.c b/spice/spice-webdavd.c
index 68f3cf0..c8fb795 100644
--- a/spice/spice-webdavd.c
+++ b/spice/spice-webdavd.c
@@ -469,6 +469,9 @@ end:
   g_clear_error ();
 }

+#ifdef WITH_AVAHI
+  mdns_unregister_service ();
+#endif
   quit (-3);
 }

--
2.5.0

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


Re: [Spice-devel] [PATCH v9 00/24] Add GStreamer support for video streaming

2016-02-04 Thread Francois Gouget
On Thu, 28 Jan 2016, Pavel Grunt wrote:
[...]
> I can provide a recording without the warning:
> http://people.freedesktop.org/~pgrunt/rhel6_gstreamer_record.spice.xz
> 
> It seems that gstreamer has problem when the stream dimensions changes.
> I notice that before the server hangs the target-bitrate is set to:
> 0 for gstreamer:vp8 or mjpeg http://fpaste.org/315639/14539702/ and
> 1 for gstreamer:h264 http://fpaste.org/315644/53971267/

I have reproduced the problem with this file. In fact it was masked by a 
change in one of my extras patches which is why I was not seeing the 
issue. I have pushed an updated patchset to github.

The new patchset also tweaks the pipeline to fix prevent GStreamer 1.0's 
h264 encoder from freezing on startup and to improve performance of VP8 
encoding. Hopefully that will work better.

Let me know how it goes.

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


Re: [Spice-devel] [PATCH v9 00/24] Add GStreamer support for video streaming

2016-02-04 Thread Baurzhan Konurbayev

Hi, guys!

I couldn't find the updated patchset.
Francois said he has pushed to github, I tried to find it in 
https://github.com/fgouget/

There were no related commits.
Can you, please, suggest the correct link?

Thanks.


On 02/05/2016 10:27 AM, Francois Gouget wrote:

On Thu, 28 Jan 2016, Pavel Grunt wrote:
[...]

I can provide a recording without the warning:
http://people.freedesktop.org/~pgrunt/rhel6_gstreamer_record.spice.xz

It seems that gstreamer has problem when the stream dimensions changes.
I notice that before the server hangs the target-bitrate is set to:
0 for gstreamer:vp8 or mjpeg http://fpaste.org/315639/14539702/ and
1 for gstreamer:h264 http://fpaste.org/315644/53971267/

I have reproduced the problem with this file. In fact it was masked by a
change in one of my extras patches which is why I was not seeing the
issue. I have pushed an updated patchset to github.

The new patchset also tweaks the pipeline to fix prevent GStreamer 1.0's
h264 encoder from freezing on startup and to improve performance of VP8
encoding. Hopefully that will work better.

Let me know how it goes.



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


--

С уважением, Бауржан Конурбаев

Технический директор

ANT Global Cloud

Мобильный: +7 701 725 44 00

b.konurba...@ant-gcloud.kz 



Regards, Baurzhan Konurbayev

Chief technology officer

ANT Global Cloud

Mobile: +7 701 725 44 00

b.konurba...@ant-gcloud.kz 

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


Re: [Spice-devel] [PATCH v3 5/9] Add new spice-gl stubs API

2016-02-04 Thread Frediano Ziglio
> 
> - spice_gl_scanout() to take the current scanout
> 
> - spice_gl_draw_async() to draw the scanout, is like other Spice async
>   functions, it takes a cookie and will return in the
>   QXLInterface.async_complete()
> 
> Two new fields are also added to QXLState, in order to save the current
> scanout, and the pending async.
> 
> A scanout can't be updated if there are pending draw atm. Discarding
> outdated draws is left as a future improvement to allow updating the
> scanout without waiting for draw async to be done.
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  server/red-dispatcher.c  | 35 +++
>  server/reds.c|  1 +
>  server/reds.h|  2 ++
>  server/spice-qxl.h   | 11 +++
>  server/spice-server.syms |  6 ++
>  5 files changed, 55 insertions(+)
> 
> diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
> index b4bbe85..f776f66 100644
> --- a/server/red-dispatcher.c
> +++ b/server/red-dispatcher.c
> @@ -959,6 +959,41 @@ void spice_qxl_driver_unload(QXLInstance *instance)
>  red_dispatcher_driver_unload(instance->st->dispatcher);
>  }
>  
> +SPICE_GNUC_VISIBLE
> +void spice_gl_scanout(QXLInstance *qxl,
> +  int fd,
> +  uint32_t width, uint32_t height,
> +  uint32_t stride, uint32_t format,
> +  int y_0_top)
> +{
> +spice_return_if_fail(qxl != NULL);
> +spice_return_if_fail(qxl->st->gl_draw_async == NULL);

Here you need to close fd on error or you will get a file
descriptor leak.

Frediano

> +
> +if (qxl->st->scanout.drm_dma_buf_fd != -1) {
> +close(qxl->st->scanout.drm_dma_buf_fd);
> +}
> +
> +qxl->st->scanout = (SpiceMsgDisplayGlScanoutUnix) {
> +.flags = y_0_top ? SPICE_GL_SCANOUT_FLAGS_Y0TOP : 0,
> +.drm_dma_buf_fd = fd,
> +.width = width,
> +.height = height,
> +.stride = stride,
> +.drm_fourcc_format = format
> +};
> +}
> +
> +SPICE_GNUC_VISIBLE
> +void spice_gl_draw_async(QXLInstance *qxl,
> + uint32_t x, uint32_t y,
> + uint32_t w, uint32_t h,
> + uint64_t cookie)
> +{
> +spice_return_if_fail(qxl != NULL);
> +spice_return_if_fail(qxl->st->scanout.drm_dma_buf_fd != -1);
> +spice_return_if_fail(qxl->st->gl_draw_async == NULL);

Here you should signal the cookie (or return an error to be handled by the
caller or rendering will stuck

Frediano


> +}
> +
>  void red_dispatcher_async_complete(struct RedDispatcher *dispatcher,
> AsyncCommand *async_command)
>  {
> diff --git a/server/reds.c b/server/reds.c
> index f0087a8..156e653 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -3233,6 +3233,7 @@ SPICE_GNUC_VISIBLE int
> spice_server_add_interface(SpiceServer *s,
>  
>  qxl = SPICE_CONTAINEROF(sin, QXLInstance, base);
>  qxl->st = spice_new0(QXLState, 1);
> +qxl->st->scanout.drm_dma_buf_fd = -1;
>  qxl->st->qif = SPICE_CONTAINEROF(interface, QXLInterface, base);
>  red_dispatcher_init(qxl);
>  
> diff --git a/server/reds.h b/server/reds.h
> index e398607..c1ab878 100644
> --- a/server/reds.h
> +++ b/server/reds.h
> @@ -36,6 +36,8 @@ extern RedsState *reds;
>  struct QXLState {
>  QXLInterface  *qif;
>  struct RedDispatcher  *dispatcher;
> +SpiceMsgDisplayGlScanoutUnix scanout;
> +struct AsyncCommand *gl_draw_async;
>  };
>  
>  struct TunnelWorker;
> diff --git a/server/spice-qxl.h b/server/spice-qxl.h
> index e1f14e7..466b95c 100644
> --- a/server/spice-qxl.h
> +++ b/server/spice-qxl.h
> @@ -193,4 +193,15 @@ struct QXLInstance {
>  QXLState   *st;
>  };
>  
> +void spice_gl_scanout(QXLInstance *instance,
> +  int fd,
> +  uint32_t width, uint32_t height,
> +  uint32_t stride, uint32_t format,
> +  int y_0_top);
> +
> +void spice_gl_draw_async(QXLInstance *instance,
> + uint32_t x, uint32_t y,
> + uint32_t w, uint32_t h,
> + uint64_t cookie);
> +
>  #endif /* SPICE_QXL_H_ */
> diff --git a/server/spice-server.syms b/server/spice-server.syms
> index 4137546..db7d973 100644
> --- a/server/spice-server.syms
> +++ b/server/spice-server.syms
> @@ -167,3 +167,9 @@ SPICE_SERVER_0.12.7 {
>  global:
>  spice_server_set_keepalive_timeout;
>  } SPICE_SERVER_0.12.6;
> +
> +SPICE_SERVER_0.13.1 {
> +global:
> +spice_gl_scanout;
> +spice_gl_draw_async;
> +} SPICE_SERVER_0.12.7;
> --
> 2.5.0
> 
> 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH 17/18] Add RedsState arg to spicevmc_device_connect|disconnect()

2016-02-04 Thread Frediano Ziglio
From: Jonathon Jongsma 

---
 server/char-device.h | 6 --
 server/reds.c| 8 
 server/spicevmc.c| 5 +++--
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/server/char-device.h b/server/char-device.h
index a6315b0..3f81d13 100644
--- a/server/char-device.h
+++ b/server/char-device.h
@@ -212,8 +212,10 @@ void 
spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
 
 /* api for specific char devices */
 
-SpiceCharDeviceState *spicevmc_device_connect(SpiceCharDeviceInstance *sin,
+SpiceCharDeviceState *spicevmc_device_connect(RedsState *reds,
+  SpiceCharDeviceInstance *sin,
   uint8_t channel_type);
-void spicevmc_device_disconnect(SpiceCharDeviceInstance *char_device);
+void spicevmc_device_disconnect(RedsState *reds,
+SpiceCharDeviceInstance *char_device);
 
 #endif // CHAR_DEVICE_H_
diff --git a/server/reds.c b/server/reds.c
index 496dfa2..1c777f5 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3103,13 +3103,13 @@ static int 
spice_server_char_device_add_interface(SpiceServer *s,
 }
 #endif
 else if (strcmp(char_device->subtype, SUBTYPE_USBREDIR) == 0) {
-dev_state = spicevmc_device_connect(char_device, 
SPICE_CHANNEL_USBREDIR);
+dev_state = spicevmc_device_connect(s, char_device, 
SPICE_CHANNEL_USBREDIR);
 }
 else if (strcmp(char_device->subtype, SUBTYPE_PORT) == 0) {
 if (strcmp(char_device->portname, "org.spice-space.webdav.0") == 0) {
-dev_state = spicevmc_device_connect(char_device, 
SPICE_CHANNEL_WEBDAV);
+dev_state = spicevmc_device_connect(s, char_device, 
SPICE_CHANNEL_WEBDAV);
 } else {
-dev_state = spicevmc_device_connect(char_device, 
SPICE_CHANNEL_PORT);
+dev_state = spicevmc_device_connect(s, char_device, 
SPICE_CHANNEL_PORT);
 }
 }
 
@@ -3147,7 +3147,7 @@ static void 
spice_server_char_device_remove_interface(RedsState *reds, SpiceBase
 #endif
 else if (strcmp(char_device->subtype, SUBTYPE_USBREDIR) == 0 ||
  strcmp(char_device->subtype, SUBTYPE_PORT) == 0) {
-spicevmc_device_disconnect(char_device);
+spicevmc_device_disconnect(reds, char_device);
 } else {
 spice_warning("failed to remove char device %s", char_device->subtype);
 }
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 4460eab..4fc95e3 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -504,7 +504,8 @@ static void spicevmc_connect(RedChannel *channel, RedClient 
*client,
 }
 }
 
-SpiceCharDeviceState *spicevmc_device_connect(SpiceCharDeviceInstance *sin,
+SpiceCharDeviceState *spicevmc_device_connect(RedsState *reds,
+  SpiceCharDeviceInstance *sin,
   uint8_t channel_type)
 {
 static uint8_t id[256] = { 0, };
@@ -554,7 +555,7 @@ SpiceCharDeviceState 
*spicevmc_device_connect(SpiceCharDeviceInstance *sin,
 }
 
 /* Must be called from RedClient handling thread. */
-void spicevmc_device_disconnect(SpiceCharDeviceInstance *sin)
+void spicevmc_device_disconnect(RedsState *reds, SpiceCharDeviceInstance *sin)
 {
 SpiceVmcState *state;
 
-- 
2.5.0

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


[Spice-devel] [PATCH 08/18] Add RedsState arg to reds_handle_channel_event()

2016-02-04 Thread Frediano Ziglio
From: Jonathon Jongsma 

---
 server/main-dispatcher.c | 2 +-
 server/reds.c| 2 +-
 server/reds.h| 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/server/main-dispatcher.c b/server/main-dispatcher.c
index 132a693..777a44f 100644
--- a/server/main-dispatcher.c
+++ b/server/main-dispatcher.c
@@ -86,7 +86,7 @@ static void main_dispatcher_self_handle_channel_event(
 int event,
 SpiceChannelEventInfo *info)
 {
-reds_handle_channel_event(event, info);
+reds_handle_channel_event(reds, event, info);
 }
 
 static void main_dispatcher_handle_channel_event(void *opaque,
diff --git a/server/reds.c b/server/reds.c
index 5d2130d..d3b693d 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -186,7 +186,7 @@ static ChannelSecurityOptions 
*reds_find_channel_security(RedsState *reds, int i
 return now;
 }
 
-void reds_handle_channel_event(int event, SpiceChannelEventInfo *info)
+void reds_handle_channel_event(RedsState *reds, int event, 
SpiceChannelEventInfo *info)
 {
 reds->core->channel_event(event, info);
 
diff --git a/server/reds.h b/server/reds.h
index 3a05019..6a8654e 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -48,7 +48,7 @@ struct SpiceMigrateState {
 };
 
 /* main thread only */
-void reds_handle_channel_event(int event, SpiceChannelEventInfo *info);
+void reds_handle_channel_event(RedsState *reds, int event, 
SpiceChannelEventInfo *info);
 
 void reds_disable_mm_time(RedsState *reds);
 void reds_enable_mm_time(RedsState *reds);
-- 
2.5.0

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


[Spice-devel] [PATCH 01/18] Change spice_server_set_ticket() to use local 'reds'

2016-02-04 Thread Frediano Ziglio
From: Jonathon Jongsma 

Rather than using global 'reds' variable
---
 server/reds.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index edbdaad..60be869 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3581,13 +3581,11 @@ SPICE_GNUC_VISIBLE void 
spice_server_set_uuid(SpiceServer *s, const uint8_t uuid
 s->spice_uuid_is_set = TRUE;
 }
 
-SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *s,
+SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *reds,
const char *passwd, int 
lifetime,
int fail_if_connected,
int disconnect_if_connected)
 {
-spice_assert(reds == s);
-
 if (reds_main_channel_connected(reds)) {
 if (fail_if_connected) {
 return -1;
-- 
2.5.0

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


[Spice-devel] [PATCH 13/18] RedsState: use local variables in more places

2016-02-04 Thread Frediano Ziglio
From: Jonathon Jongsma 

Various functions were still using the global 'reds' variable rather
than the local argument of type RedsState
---
 server/reds.c | 68 +--
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index fe35d84..012c0f3 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -859,7 +859,7 @@ static int reds_get_n_clients(RedsState *reds)
 SPICE_GNUC_VISIBLE int spice_server_get_num_clients(SpiceServer *s)
 {
 spice_assert(reds == s);
-return reds_get_n_clients(reds);
+return reds_get_n_clients(s);
 }
 
 static int secondary_channels[] = {
@@ -1340,6 +1340,7 @@ int reds_handle_migrate_data(RedsState *reds, 
MainChannelClient *mcc,
 
 static void reds_channel_init_auth_caps(RedLinkInfo *link, RedChannel *channel)
 {
+RedsState *reds = link->reds;
 if (reds->sasl_enabled && !link->skip_auth) {
 red_channel_set_common_cap(channel, SPICE_COMMON_CAP_AUTH_SASL);
 } else {
@@ -3116,11 +3117,11 @@ static int 
spice_server_char_device_add_interface(SpiceServer *s,
 spice_assert(char_device->st);
 /* setting the char_device state to "started" for backward compatibily 
with
  * qemu releases that don't call spice api for start/stop (not 
implemented yet) */
-if (reds->vm_running) {
+if (s->vm_running) {
 spice_char_device_start(char_device->st);
 }
 spice_char_device_set_server(char_device->st, reds);
-reds_char_device_add_state(reds, char_device->st);
+reds_char_device_add_state(s, char_device->st);
 } else {
 spice_warning("failed to create device state for %s", 
char_device->subtype);
 return -1;
@@ -3740,7 +3741,7 @@ SPICE_GNUC_VISIBLE int 
spice_server_set_channel_security(SpiceServer *s, const c
 SPICE_GNUC_VISIBLE int spice_server_get_sock_info(SpiceServer *s, struct 
sockaddr *sa, socklen_t *salen)
 {
 spice_assert(reds == s);
-if (main_channel_getsockname(reds->main_channel, sa, salen) < 0) {
+if (main_channel_getsockname(s->main_channel, sa, salen) < 0) {
 return -1;
 }
 return 0;
@@ -3749,7 +3750,7 @@ SPICE_GNUC_VISIBLE int 
spice_server_get_sock_info(SpiceServer *s, struct sockadd
 SPICE_GNUC_VISIBLE int spice_server_get_peer_info(SpiceServer *s, struct 
sockaddr *sa, socklen_t *salen)
 {
 spice_assert(reds == s);
-if (main_channel_getpeername(reds->main_channel, sa, salen) < 0) {
+if (main_channel_getpeername(s->main_channel, sa, salen) < 0) {
 return -1;
 }
 return 0;
@@ -3758,7 +3759,7 @@ SPICE_GNUC_VISIBLE int 
spice_server_get_peer_info(SpiceServer *s, struct sockadd
 SPICE_GNUC_VISIBLE int spice_server_is_server_mouse(SpiceServer *s)
 {
 spice_assert(reds == s);
-return reds->mouse_mode == SPICE_MOUSE_MODE_SERVER;
+return s->mouse_mode == SPICE_MOUSE_MODE_SERVER;
 }
 
 SPICE_GNUC_VISIBLE int spice_server_add_renderer(SpiceServer *s, const char 
*name)
@@ -3802,7 +3803,6 @@ SPICE_GNUC_VISIBLE int 
spice_server_set_playback_compression(SpiceServer *s, int
 
 SPICE_GNUC_VISIBLE int spice_server_set_agent_mouse(SpiceServer *s, int enable)
 {
-spice_assert(reds == s);
 reds->agent_mouse = enable;
 reds_update_mouse_mode(reds);
 return 0;
@@ -3812,8 +3812,8 @@ SPICE_GNUC_VISIBLE int 
spice_server_set_agent_copypaste(SpiceServer *s, int enab
 {
 spice_assert(reds == s);
 s->agent_copypaste = enable;
-reds->agent_state.write_filter.copy_paste_enabled = s->agent_copypaste;
-reds->agent_state.read_filter.copy_paste_enabled = s->agent_copypaste;
+s->agent_state.write_filter.copy_paste_enabled = s->agent_copypaste;
+s->agent_state.read_filter.copy_paste_enabled = s->agent_copypaste;
 return 0;
 }
 
@@ -3821,8 +3821,8 @@ SPICE_GNUC_VISIBLE int 
spice_server_set_agent_file_xfer(SpiceServer *s, int enab
 {
 spice_assert(reds == s);
 s->agent_file_xfer = enable;
-reds->agent_state.write_filter.file_xfer_enabled = s->agent_file_xfer;
-reds->agent_state.read_filter.file_xfer_enabled = s->agent_file_xfer;
+s->agent_state.write_filter.file_xfer_enabled = s->agent_file_xfer;
+s->agent_state.read_filter.file_xfer_enabled = s->agent_file_xfer;
 return 0;
 }
 
@@ -3863,9 +3863,9 @@ SPICE_GNUC_VISIBLE int 
spice_server_migrate_connect(SpiceServer *s, const char*
 spice_assert(s->migration_interface);
 spice_assert(reds == s);
 
-if (reds->expect_migrate) {
+if (s->expect_migrate) {
 spice_info("consecutive calls without migration. Canceling previous 
call");
-main_channel_migrate_src_complete(reds->main_channel, FALSE);
+main_channel_migrate_src_complete(s->main_channel, FALSE);
 }
 
 sif = SPICE_CONTAINEROF(s->migration_interface->base.sif, 
SpiceMigrateInterface, base);
@@ -3875,7 +3875,7 @@ SPICE_GNUC_VISIBLE int 
spice_server_migrate_connect(SpiceServer *s, const char*
   

[Spice-devel] [PATCH 18/18] Add RedsState arg to activate_modifiers_watch()

2016-02-04 Thread Frediano Ziglio
From: Jonathon Jongsma 

---
 server/inputs-channel.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 38b23df..f47a586 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -192,7 +192,7 @@ static void 
inputs_channel_release_msg_rcv_buf(RedChannelClient *rcc,
  ((state & SPICE_MOUSE_BUTTON_MASK_MIDDLE) ? VD_AGENT_MBUTTON_MASK : 0) |  
  \
  ((state & SPICE_MOUSE_BUTTON_MASK_RIGHT) ? VD_AGENT_RBUTTON_MASK : 0))
 
-static void activate_modifiers_watch(void)
+static void activate_modifiers_watch(RedsState *reds)
 {
 reds_get_core_interface(reds)->timer_start(key_modifiers_timer, 
KEY_MODIFIERS_TTL);
 }
@@ -312,7 +312,7 @@ static int inputs_channel_handle_parsed(RedChannelClient 
*rcc, uint32_t size, ui
 if (key_down->code == CAPS_LOCK_SCAN_CODE ||
 key_down->code == NUM_LOCK_SCAN_CODE ||
 key_down->code == SCROLL_LOCK_SCAN_CODE) {
-activate_modifiers_watch();
+activate_modifiers_watch(reds);
 }
 }
 case SPICE_MSGC_INPUTS_KEY_UP: {
@@ -450,7 +450,7 @@ static int inputs_channel_handle_parsed(RedChannelClient 
*rcc, uint32_t size, ui
 kbd_push_scan(keyboard, CAPS_LOCK_SCAN_CODE);
 kbd_push_scan(keyboard, CAPS_LOCK_SCAN_CODE | 0x80);
 }
-activate_modifiers_watch();
+activate_modifiers_watch(reds);
 break;
 }
 case SPICE_MSGC_DISCONNECTING:
-- 
2.5.0

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


[Spice-devel] [PATCH 07/18] Add RedsState member to RedLinkInfo

2016-02-04 Thread Frediano Ziglio
From: Jonathon Jongsma 

This allows us to use local 'reds' variables in all of the various async
callbacks rather than using the global 'reds' variable.
---
 server/reds.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index 7b8848a..5d2130d 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -148,6 +148,7 @@ static long *lock_count;
 RedsState *reds = NULL;
 
 typedef struct RedLinkInfo {
+RedsState *reds;
 RedsStream *stream;
 SpiceLinkHeader link_header;
 SpiceLinkMess *link_mess;
@@ -1893,6 +1894,7 @@ static void reds_handle_link(RedsState *reds, RedLinkInfo 
*link)
 static void reds_handle_ticket(void *opaque)
 {
 RedLinkInfo *link = (RedLinkInfo *)opaque;
+RedsState *reds = link->reds;
 char *password;
 time_t ltime;
 int password_size;
@@ -1977,6 +1979,7 @@ static void reds_handle_auth_sasl_steplen(void *opaque);
 static void reds_handle_auth_sasl_step(void *opaque)
 {
 RedLinkInfo *link = (RedLinkInfo *)opaque;
+RedsState *reds = link->reds;
 RedsSaslError status;
 
 status = reds_sasl_handle_auth_step(link->stream, 
reds_handle_auth_sasl_steplen, link);
@@ -2017,6 +2020,7 @@ static void reds_handle_auth_sasl_steplen(void *opaque)
 static void reds_handle_auth_sasl_start(void *opaque)
 {
 RedLinkInfo *link = (RedLinkInfo *)opaque;
+RedsState *reds = link->reds;
 RedsSaslError status;
 
 status = reds_sasl_handle_auth_start(link->stream, 
reds_handle_auth_sasl_steplen, link);
@@ -2081,6 +2085,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
 static void reds_handle_auth_mechanism(void *opaque)
 {
 RedLinkInfo *link = (RedLinkInfo *)opaque;
+RedsState *reds = link->reds;
 
 spice_info("Auth method: %d", link->auth_mechanism.auth_mechanism);
 
@@ -2106,6 +2111,7 @@ static void reds_handle_auth_mechanism(void *opaque)
 
 static int reds_security_check(RedLinkInfo *link)
 {
+RedsState *reds = link->reds;
 ChannelSecurityOptions *security_option = reds_find_channel_security(reds, 
link->link_mess->channel_type);
 uint32_t security = security_option ? security_option->options : 
reds->default_channel_security;
 return (reds_stream_is_ssl(link->stream) && (security & 
SPICE_CHANNEL_SECURITY_SSL)) ||
@@ -2115,6 +2121,7 @@ static int reds_security_check(RedLinkInfo *link)
 static void reds_handle_read_link_done(void *opaque)
 {
 RedLinkInfo *link = (RedLinkInfo *)opaque;
+RedsState *reds = link->reds;
 SpiceLinkMess *link_mess = link->link_mess;
 uint32_t num_caps;
 uint32_t *caps;
@@ -2194,6 +2201,7 @@ static void reds_handle_link_error(void *opaque, int err)
 static void reds_handle_read_header_done(void *opaque)
 {
 RedLinkInfo *link = (RedLinkInfo *)opaque;
+RedsState *reds = link->reds;
 SpiceLinkHeader *header = >link_header;
 
 header->major_version = GUINT32_FROM_LE(header->major_version);
@@ -2247,6 +2255,7 @@ static void reds_handle_new_link(RedLinkInfo *link)
 static void reds_handle_ssl_accept(int fd, int event, void *data)
 {
 RedLinkInfo *link = (RedLinkInfo *)data;
+RedsState *reds = link->reds;
 int return_code = reds_stream_ssl_accept(link->stream);
 
 switch (return_code) {
@@ -2303,6 +2312,7 @@ static RedLinkInfo *reds_init_client_connection(RedsState 
*reds, int socket)
 }
 
 link = spice_new0(RedLinkInfo, 1);
+link->reds = reds;
 link->stream = reds_stream_new(socket);
 
 /* gather info + send event */
@@ -2372,6 +2382,7 @@ static void reds_accept_ssl_connection(int fd, int event, 
void *data)
 
 static void reds_accept(int fd, int event, void *data)
 {
+RedsState *reds = data;
 int socket;
 
 if ((socket = accept(reds->listen_socket, NULL, 0)) == -1) {
@@ -2535,7 +2546,7 @@ static int reds_init_net(RedsState *reds)
 }
 reds->listen_watch = reds->core->watch_add(reds->core, 
reds->listen_socket,
SPICE_WATCH_EVENT_READ,
-   reds_accept, NULL);
+   reds_accept, reds);
 if (reds->listen_watch == NULL) {
 spice_warning("set fd handle failed");
 return -1;
@@ -2561,7 +2572,7 @@ static int reds_init_net(RedsState *reds)
 reds->listen_socket = reds->spice_listen_socket_fd;
 reds->listen_watch = reds->core->watch_add(reds->core, 
reds->listen_socket,
SPICE_WATCH_EVENT_READ,
-   reds_accept, NULL);
+   reds_accept, reds);
 if (reds->listen_watch == NULL) {
 spice_warning("set fd handle failed");
 return -1;
-- 
2.5.0

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org

[Spice-devel] [PATCH 10/18] Remove use of global 'reds' from VDIReadBuf functions

2016-02-04 Thread Frediano Ziglio
From: Jonathon Jongsma 

Add a new 'state' property to VDIReadBuf so that we can refer back to
the VDIPortState struct from the readbuf functions.
---
 server/reds-private.h |  7 +--
 server/reds.c | 35 +--
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/server/reds-private.h b/server/reds-private.h
index e5444d6..80abdb3 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -40,7 +40,10 @@ typedef struct MonitorMode {
 uint32_t y_res;
 } MonitorMode;
 
+typedef struct VDIPortState VDIPortState;
+
 typedef struct VDIReadBuf {
+VDIPortState *state;
 RingItem link;
 uint32_t refs;
 
@@ -54,7 +57,7 @@ enum {
 VDI_PORT_READ_STATE_READ_DATA,
 };
 
-typedef struct VDIPortState {
+struct VDIPortState {
 SpiceCharDeviceState *base;
 uint32_t plug_generation;
 int client_agent_started;
@@ -77,7 +80,7 @@ typedef struct VDIPortState {
 
 SpiceMigrateDataMain *mig_data; /* storing it when migration data arrives
before agent is attached */
-} VDIPortState;
+};
 
 /* messages that are addressed to the agent and are created in the server */
 typedef struct __attribute__ ((__packed__)) VDInternalBuf {
diff --git a/server/reds.c b/server/reds.c
index 33cc4a7..0a39340 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -173,9 +173,9 @@ static void reds_char_device_add_state(RedsState *reds, 
SpiceCharDeviceState *st
 static void reds_char_device_remove_state(RedsState *reds, 
SpiceCharDeviceState *st);
 static void reds_send_mm_time(RedsState *reds);
 
-static VDIReadBuf *reds_get_vdi_port_read_buf(RedsState *reds);
+static VDIReadBuf *vdi_port_state_get_read_buf(VDIPortState *state);
 static VDIReadBuf *vdi_port_read_buf_ref(VDIReadBuf *buf);
-static void vdi_port_read_buf_unref(RedsState *reds, VDIReadBuf *buf);
+static void vdi_port_read_buf_unref(VDIReadBuf *buf);
 
 static ChannelSecurityOptions *reds_find_channel_security(RedsState *reds, int 
id)
 {
@@ -395,7 +395,7 @@ static void reds_reset_vdp(RedsState *reds)
 state->receive_len = sizeof(state->vdi_chunk_header);
 state->message_receive_len = 0;
 if (state->current_read_buf) {
-vdi_port_read_buf_unref(reds, state->current_read_buf);
+vdi_port_read_buf_unref(state->current_read_buf);
 state->current_read_buf = NULL;
 }
 /* Reset read filter to start with clean state when the agent reconnects */
@@ -614,7 +614,7 @@ static void vdi_port_read_buf_release(uint8_t *data, void 
*opaque)
 {
 VDIReadBuf *buf = (VDIReadBuf *)opaque;
 
-vdi_port_read_buf_unref(reds, buf);
+vdi_port_read_buf_unref(buf);
 }
 
 /* returns TRUE if the buffer can be forwarded */
@@ -646,9 +646,8 @@ static int vdi_port_read_buf_process(RedsState *reds, int 
port, VDIReadBuf *buf)
 }
 }
 
-static VDIReadBuf *reds_get_vdi_port_read_buf(RedsState *reds)
+static VDIReadBuf *vdi_port_state_get_read_buf(VDIPortState *state)
 {
-VDIPortState *state = >agent_state;
 RingItem *item;
 VDIReadBuf *buf;
 
@@ -671,17 +670,17 @@ static VDIReadBuf* vdi_port_read_buf_ref(VDIReadBuf *buf)
 
 /* FIXME: refactor so that unreffing the VDIReadBuf doesn't require accessing
  * RedsState? */
-static void vdi_port_read_buf_unref(RedsState *reds, VDIReadBuf *buf)
+static void vdi_port_read_buf_unref(VDIReadBuf *buf)
 {
 if (!--buf->refs) {
-ring_add(>agent_state.read_bufs, >link);
+ring_add(>state->read_bufs, >link);
 
 /* read_one_msg_from_vdi_port may have never completed because the 
read_bufs
 ring was empty. So we call it again so it can complete its work if
 necessary. Note that since we can be called from 
spice_char_device_wakeup
 this can cause recursion, but we have protection for that */
-if (reds->agent_state.base) {
-spice_char_device_wakeup(reds->agent_state.base);
+if (buf->state->base) {
+spice_char_device_wakeup(buf->state->base);
 }
 }
 }
@@ -716,7 +715,7 @@ static SpiceCharDeviceMsgToClient 
*vdi_port_read_one_msg_from_device(SpiceCharDe
 state->message_receive_len = state->vdi_chunk_header.size;
 state->read_state = VDI_PORT_READ_STATE_GET_BUFF;
 case VDI_PORT_READ_STATE_GET_BUFF: {
-if (!(state->current_read_buf = reds_get_vdi_port_read_buf(reds))) 
{
+if (!(state->current_read_buf = 
vdi_port_state_get_read_buf(>agent_state))) {
 return NULL;
 }
 state->receive_pos = state->current_read_buf->data;
@@ -748,7 +747,7 @@ static SpiceCharDeviceMsgToClient 
*vdi_port_read_one_msg_from_device(SpiceCharDe
 if (vdi_port_read_buf_process(reds, state->vdi_chunk_header.port, 
dispatch_buf)) {
 return dispatch_buf;
 } else {
-vdi_port_read_buf_unref(reds, dispatch_buf);
+vdi_port_read_buf_unref(dispatch_buf);

[Spice-devel] [PATCH 14/18] spice_server_kbd_leds: don't use global 'reds'

2016-02-04 Thread Frediano Ziglio
From: Jonathon Jongsma 

Store a reference to the RedsState server in the keyboard state struct
---
 server/inputs-channel.c | 14 +++---
 server/inputs-channel.h |  1 +
 server/reds.c   |  1 +
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 5e884f4..38b23df 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -61,11 +61,19 @@ struct SpiceKbdState {
 /* track key press state */
 bool key[0x7f];
 bool key_ext[0x7f];
+RedsState *reds;
 };
 
-static SpiceKbdState* spice_kbd_state_new(void)
+static SpiceKbdState* spice_kbd_state_new(RedsState *reds)
+{
+SpiceKbdState *st = spice_new0(SpiceKbdState, 1);
+st->reds = reds;
+return st;
+}
+
+RedsState* spice_kbd_state_get_server(SpiceKbdState *dev)
 {
-return spice_new0(SpiceKbdState, 1);
+return dev->reds;
 }
 
 struct SpiceMouseState {
@@ -666,7 +674,7 @@ int inputs_channel_set_keyboard(InputsChannel *inputs, 
SpiceKbdInstance *keyboar
 return -1;
 }
 inputs->keyboard = keyboard;
-inputs->keyboard->st = spice_kbd_state_new();
+inputs->keyboard->st = spice_kbd_state_new(reds);
 return 0;
 }
 
diff --git a/server/inputs-channel.h b/server/inputs-channel.h
index 31574b5..4070a23 100644
--- a/server/inputs-channel.h
+++ b/server/inputs-channel.h
@@ -40,5 +40,6 @@ int inputs_channel_set_tablet(InputsChannel *inputs, 
SpiceTabletInstance *tablet
 int inputs_channel_has_tablet(InputsChannel *inputs);
 void inputs_channel_detach_tablet(InputsChannel *inputs, SpiceTabletInstance 
*tablet);
 RedsState* spice_tablet_state_get_server(SpiceTabletState *dev);
+RedsState* spice_kbd_state_get_server(SpiceKbdState *dev);
 
 #endif
diff --git a/server/reds.c b/server/reds.c
index 012c0f3..91711a1 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3773,6 +3773,7 @@ SPICE_GNUC_VISIBLE int 
spice_server_add_renderer(SpiceServer *s, const char *nam
 
 SPICE_GNUC_VISIBLE int spice_server_kbd_leds(SpiceKbdInstance *sin, int leds)
 {
+RedsState *reds = spice_kbd_state_get_server(sin->st);
 inputs_channel_on_keyboard_leds_change(reds->inputs_channel, leds);
 return 0;
 }
-- 
2.5.0

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


[Spice-devel] [PATCH 06/18] Add RedsState arg to reds_init_client_[ssl_]connection()

2016-02-04 Thread Frediano Ziglio
From: Jonathon Jongsma 

---
 server/reds.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index 6467c7e..7b8848a 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2265,7 +2265,7 @@ static void reds_handle_ssl_accept(int fd, int event, 
void *data)
 }
 }
 
-static RedLinkInfo *reds_init_client_connection(int socket)
+static RedLinkInfo *reds_init_client_connection(RedsState *reds, int socket)
 {
 RedLinkInfo *link;
 int delay_val = 1;
@@ -2318,12 +2318,12 @@ error:
 }
 
 
-static RedLinkInfo *reds_init_client_ssl_connection(int socket)
+static RedLinkInfo *reds_init_client_ssl_connection(RedsState *reds, int 
socket)
 {
 RedLinkInfo *link;
 int ssl_status;
 
-link = reds_init_client_connection(socket);
+link = reds_init_client_connection(reds, socket);
 if (link == NULL)
 goto error;
 
@@ -2354,6 +2354,7 @@ error:
 
 static void reds_accept_ssl_connection(int fd, int event, void *data)
 {
+RedsState *reds = data;
 RedLinkInfo *link;
 int socket;
 
@@ -2362,7 +2363,7 @@ static void reds_accept_ssl_connection(int fd, int event, 
void *data)
 return;
 }
 
-if (!(link = reds_init_client_ssl_connection(socket))) {
+if (!(link = reds_init_client_ssl_connection(reds, socket))) {
 close(socket);
 return;
 }
@@ -2388,7 +2389,7 @@ SPICE_GNUC_VISIBLE int 
spice_server_add_client(SpiceServer *s, int socket, int s
 RedLinkInfo *link;
 
 spice_assert(reds == s);
-if (!(link = reds_init_client_connection(socket))) {
+if (!(link = reds_init_client_connection(s, socket))) {
 spice_warning("accept failed");
 return -1;
 }
@@ -2405,7 +2406,7 @@ SPICE_GNUC_VISIBLE int 
spice_server_add_ssl_client(SpiceServer *s, int socket, i
 RedLinkInfo *link;
 
 spice_assert(reds == s);
-if (!(link = reds_init_client_ssl_connection(socket))) {
+if (!(link = reds_init_client_ssl_connection(s, socket))) {
 return -1;
 }
 
-- 
2.5.0

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


[Spice-devel] [PATCH 09/18] Add RedsState arg to all stat functions

2016-02-04 Thread Frediano Ziglio
From: Jonathon Jongsma 

---
 server/dcc-send.c|  6 +++---
 server/display-channel.c | 12 ++--
 server/main-channel.c|  2 +-
 server/red-channel.c |  4 ++--
 server/red-worker.c  | 12 ++--
 server/reds.c| 22 +++---
 server/reds.h|  3 ---
 server/stat.h| 22 --
 8 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/server/dcc-send.c b/server/dcc-send.c
index 3cb50ba..7b46d22 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -207,13 +207,13 @@ static void 
red_display_add_image_to_pixmap_cache(RedChannelClient *rcc,
 io_image->descriptor.flags |= SPICE_IMAGE_FLAGS_CACHE_ME;
 
dcc->send_data.pixmap_cache_items[dcc->send_data.num_pixmap_cache_items++] =

image->descriptor.id;
-stat_inc_counter(display_channel->add_to_cache_counter, 1);
+reds_stat_inc_counter(reds, 
display_channel->add_to_cache_counter, 1);
 }
 }
 }
 
 if (!(io_image->descriptor.flags & SPICE_IMAGE_FLAGS_CACHE_ME)) {
-stat_inc_counter(display_channel->non_cache_counter, 1);
+reds_stat_inc_counter(reds, display_channel->non_cache_counter, 1);
 }
 }
 
@@ -376,7 +376,7 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, 
SpiceMarshaller *m,
  _palette_out, _palette_out);
 spice_assert(bitmap_palette_out == NULL);
 spice_assert(lzplt_palette_out == NULL);
-stat_inc_counter(display->cache_hits_counter, 1);
+reds_stat_inc_counter(reds, display->cache_hits_counter, 1);
 pthread_mutex_unlock(>pixmap_cache->lock);
 return FILL_BITS_TYPE_CACHE;
 } else {
diff --git a/server/display-channel.c b/server/display-channel.c
index 2282847..91bb2c5 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2049,12 +2049,12 @@ DisplayChannel* display_channel_new(RedWorker *worker, 
int migrate, int stream_v
 stat_init(>__exclude_stat, "__exclude", stat_clock);
 #ifdef RED_STATISTICS
 RedChannel *channel = RED_CHANNEL(display);
-display->cache_hits_counter = stat_add_counter(channel->stat,
-   "cache_hits", TRUE);
-display->add_to_cache_counter = stat_add_counter(channel->stat,
- "add_to_cache", 
TRUE);
-display->non_cache_counter = stat_add_counter(channel->stat,
-  "non_cache", TRUE);
+display->cache_hits_counter = reds_stat_add_counter(reds, channel->stat,
+"cache_hits", TRUE);
+display->add_to_cache_counter = reds_stat_add_counter(reds, channel->stat,
+  "add_to_cache", 
TRUE);
+display->non_cache_counter = reds_stat_add_counter(reds, channel->stat,
+   "non_cache", TRUE);
 #endif
 stat_compress_init(>lz_stat, "lz", stat_clock);
 stat_compress_init(>glz_stat, "glz", stat_clock);
diff --git a/server/main-channel.c b/server/main-channel.c
index c2a7b8b..a70c605 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -985,7 +985,7 @@ static int main_channel_handle_parsed(RedChannelClient 
*rcc, uint32_t size, uint
 red_channel_client_handle_message(rcc, size, type, message);
 }
 #ifdef RED_STATISTICS
-reds_update_stat_value(roundtrip);
+reds_update_stat_value(reds, roundtrip);
 #endif
 break;
 }
diff --git a/server/red-channel.c b/server/red-channel.c
index fdd85b9..1ca85b1 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -396,7 +396,7 @@ static void red_channel_client_on_output(void *opaque, int 
n)
 if (rcc->connectivity_monitor.timer) {
 rcc->connectivity_monitor.out_bytes += n;
 }
-stat_inc_counter(rcc->channel->out_bytes_counter, n);
+reds_stat_inc_counter(reds, rcc->channel->out_bytes_counter, n);
 }
 
 static void red_channel_client_on_input(void *opaque, int n)
@@ -1162,7 +1162,7 @@ void red_channel_set_stat_node(RedChannel *channel, 
StatNodeRef stat)
 
 #ifdef RED_STATISTICS
 channel->stat = stat;
-channel->out_bytes_counter = stat_add_counter(stat, "out_bytes", TRUE);
+channel->out_bytes_counter = reds_stat_add_counter(reds, stat, 
"out_bytes", TRUE);
 #endif
 }
 
diff --git a/server/red-worker.c b/server/red-worker.c
index df24a5b..878e498 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -244,7 +244,7 @@ static int red_process_display(RedWorker *worker, int 
*ring_is_empty)
 red_record_qxl_command(worker->record_fd, >mem_slots, 
ext_cmd,
 

[Spice-devel] [PATCH 04/18] Rename vdi_port_read_buf_get() to match convention

2016-02-04 Thread Frediano Ziglio
From: Jonathon Jongsma 

Since this is technically a RedsState method, name it as such.
---
 server/reds.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index 4ad8b0f..bff64d6 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -174,7 +174,7 @@ static void reds_char_device_add_state(RedsState *reds, 
SpiceCharDeviceState *st
 static void reds_char_device_remove_state(RedsState *reds, 
SpiceCharDeviceState *st);
 static void reds_send_mm_time(RedsState *reds);
 
-static VDIReadBuf *vdi_port_read_buf_get(RedsState *reds);
+static VDIReadBuf *reds_get_vdi_port_read_buf(RedsState *reds);
 static VDIReadBuf *vdi_port_read_buf_ref(VDIReadBuf *buf);
 static void vdi_port_read_buf_unref(RedsState *reds, VDIReadBuf *buf);
 
@@ -647,7 +647,7 @@ static int vdi_port_read_buf_process(RedsState *reds, int 
port, VDIReadBuf *buf)
 }
 }
 
-static VDIReadBuf *vdi_port_read_buf_get(RedsState *reds)
+static VDIReadBuf *reds_get_vdi_port_read_buf(RedsState *reds)
 {
 VDIPortState *state = >agent_state;
 RingItem *item;
@@ -717,7 +717,7 @@ static SpiceCharDeviceMsgToClient 
*vdi_port_read_one_msg_from_device(SpiceCharDe
 state->message_receive_len = state->vdi_chunk_header.size;
 state->read_state = VDI_PORT_READ_STATE_GET_BUFF;
 case VDI_PORT_READ_STATE_GET_BUFF: {
-if (!(state->current_read_buf = vdi_port_read_buf_get(reds))) {
+if (!(state->current_read_buf = reds_get_vdi_port_read_buf(reds))) 
{
 return NULL;
 }
 state->receive_pos = state->current_read_buf->data;
@@ -1242,7 +1242,7 @@ static int reds_agent_state_restore(RedsState *reds, 
SpiceMigrateDataMain *mig_d
 uint32_t cur_buf_size;
 
 agent_state->read_state = VDI_PORT_READ_STATE_READ_DATA;
-agent_state->current_read_buf = vdi_port_read_buf_get(reds);
+agent_state->current_read_buf = reds_get_vdi_port_read_buf(reds);
 spice_assert(agent_state->current_read_buf);
 partial_msg_header = (uint8_t *)mig_data + 
mig_data->agent2client.msg_header_ptr -
 sizeof(SpiceMiniDataHeader);
-- 
2.5.0

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


[Spice-devel] [PATCH] reds: constification

2016-02-04 Thread Frediano Ziglio
Make version_string a constant.
Also there is no need to have a pointer but declare the buffer as static

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

diff --git a/server/reds.c b/server/reds.c
index edbdaad..4225847 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3299,7 +3299,7 @@ static void reds_init_vd_agent_resources(RedsState *reds)
 }
 }
 
-const char *version_string = VERSION;
+static const char version_string[] = VERSION;
 
 static int do_spice_init(RedsState *reds, SpiceCoreInterface *core_interface)
 {
-- 
2.5.0

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


Re: [Spice-devel] [PATCH v2] Move streaming_video to RedsState struct

2016-02-04 Thread Frediano Ziglio
> 
> Also requires adding reds_get_streaming_video() accessor so that other
> files can check this value.
> ---
> 
>  - Changed back to assert
> 
>  server/red-dispatcher.c | 7 ---
>  server/red-worker.c | 2 +-
>  server/reds-private.h   | 1 +
>  server/reds.c   | 9 +++--
>  server/reds.h   | 2 +-
>  5 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
> index fa2a42c..374d5a9 100644
> --- a/server/red-dispatcher.c
> +++ b/server/red-dispatcher.c
> @@ -704,8 +704,9 @@ static void qxl_worker_loadvm_commands(QXLWorker
> *qxl_worker,
>  
>  static inline int calc_compression_level(void)
>  {
> -spice_assert(streaming_video != SPICE_STREAM_VIDEO_INVALID);
> -if ((streaming_video != SPICE_STREAM_VIDEO_OFF) ||
> +spice_assert(reds_get_streaming_video(reds) !=
> SPICE_STREAM_VIDEO_INVALID);
> +
> +if ((reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_OFF) ||
>  (spice_server_get_image_compression(reds) !=
>  SPICE_IMAGE_COMPRESSION_QUIC)) {
>  return 0;
>  } else {
> @@ -736,7 +737,7 @@ void red_dispatcher_on_sv_change(void)
>  RedDispatcher *now = dispatchers;
>  while (now) {
>  now->qxl->st->qif->set_compression_level(now->qxl,
>  compression_level);
> -payload.streaming_video = streaming_video;
> +payload.streaming_video = reds_get_streaming_video(reds);
>  dispatcher_send_message(>dispatcher,
>  RED_WORKER_MESSAGE_SET_STREAMING_VIDEO,
>  );
> diff --git a/server/red-worker.c b/server/red-worker.c
> index f6c4f45..0549047 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -1541,7 +1541,7 @@ RedWorker* red_worker_new(QXLInstance *qxl,
> RedDispatcher *red_dispatcher)
>  
>  worker->cursor_channel = cursor_channel_new(worker);
>  // TODO: handle seemless migration. Temp, setting migrate to FALSE
> -worker->display_channel = display_channel_new(worker, FALSE,
> streaming_video,
> +worker->display_channel = display_channel_new(worker, FALSE,
> reds_get_streaming_video(reds),
>init_info.n_surfaces);
>  
>  return worker;
> diff --git a/server/reds-private.h b/server/reds-private.h
> index 504cb27..6f9bbaf 100644
> --- a/server/reds-private.h
> +++ b/server/reds-private.h
> @@ -216,6 +216,7 @@ struct RedsState {
>  uint8_t spice_uuid[16];
>  
>  gboolean ticketing_enabled;
> +uint32_t streaming_video;
>  SpiceImageCompression image_compression;
>  spice_wan_compression_t jpeg_state;
>  };
> diff --git a/server/reds.c b/server/reds.c
> index 91550ed..f50690c 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -146,7 +146,6 @@ static SpiceCoreInterfaceInternal core_interface_adapter
> = {
>  
>  static pthread_mutex_t *lock_cs;
>  static long *lock_count;
> -uint32_t streaming_video = SPICE_STREAM_VIDEO_FILTER;
>  spice_wan_compression_t zlib_glz_state = SPICE_WAN_COMPRESSION_AUTO;
>  int agent_mouse = TRUE;
>  int agent_copypaste = TRUE;
> @@ -3426,6 +3425,7 @@ SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
>  reds->spice_uuid_is_set = FALSE;
>  memset(reds->spice_uuid, 0, sizeof(reds->spice_uuid));
>  reds->ticketing_enabled = TRUE; /* ticketing enabled by default */
> +reds->streaming_video = SPICE_STREAM_VIDEO_FILTER;
>  reds->image_compression = SPICE_IMAGE_COMPRESSION_AUTO_GLZ;
>  reds->jpeg_state = SPICE_WAN_COMPRESSION_AUTO;
>  return reds;
> @@ -3782,11 +3782,16 @@ SPICE_GNUC_VISIBLE int
> spice_server_set_streaming_video(SpiceServer *s, int valu
>  value != SPICE_STREAM_VIDEO_ALL &&
>  value != SPICE_STREAM_VIDEO_FILTER)
>  return -1;
> -streaming_video = value;
> +s->streaming_video = value;
>  red_dispatcher_on_sv_change();
>  return 0;
>  }
>  
> +uint32_t reds_get_streaming_video(RedsState *reds)
> +{
> +return reds->streaming_video;
> +}
> +
>  SPICE_GNUC_VISIBLE int spice_server_set_playback_compression(SpiceServer *s,
>  int enable)
>  {
>  spice_assert(reds == s);
> diff --git a/server/reds.h b/server/reds.h
> index 97b08b5..e62f0ba 100644
> --- a/server/reds.h
> +++ b/server/reds.h
> @@ -73,7 +73,6 @@ enum {
>  };
>  
>  extern struct SpiceCoreInterfaceInternal *core;
> -extern uint32_t streaming_video;
>  extern spice_wan_compression_t zlib_glz_state;
>  
>  // Temporary measures to make splitting reds.c to inputs-channel.c easier
> @@ -111,6 +110,7 @@ void reds_on_main_channel_migrate(RedsState *reds,
> MainChannelClient *mcc);
>  void reds_on_char_device_state_destroy(RedsState *reds, SpiceCharDeviceState
>  *dev);
>  
>  void reds_set_client_mm_time_latency(RedsState *reds, RedClient *client,
>  uint32_t latency);
> +uint32_t reds_get_streaming_video(RedsState *reds);
>  spice_wan_compression_t reds_get_jpeg_state(const RedsState *reds);
>  
>  #endif


Re: [Spice-devel] [PATCH v2] Move agent_mouse to RedsState struct

2016-02-04 Thread Frediano Ziglio
> 
> Required adding a RedsState arg to reds_get_agent_mouse()
> ---
>  server/inputs-channel.c |  8 
>  server/reds-private.h   |  2 ++
>  server/reds.c   | 10 +-
>  server/reds.h   |  2 +-
>  4 files changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/server/inputs-channel.c b/server/inputs-channel.c
> index 8f5ab37..319d26c 100644
> --- a/server/inputs-channel.c
> +++ b/server/inputs-channel.c
> @@ -355,8 +355,8 @@ static int inputs_channel_handle_parsed(RedChannelClient
> *rcc, uint32_t size, ui
>  if (reds_get_mouse_mode(reds) != SPICE_MOUSE_MODE_CLIENT) {
>  break;
>  }
> -spice_assert((reds_get_agent_mouse() && reds_has_vdagent(reds)) ||
> tablet);
> -if (!reds_get_agent_mouse() || !reds_has_vdagent(reds)) {
> +spice_assert((reds_get_agent_mouse(reds) && reds_has_vdagent(reds))
> || tablet);
> +if (!reds_get_agent_mouse(reds) || !reds_has_vdagent(reds)) {
>  SpiceTabletInterface *sif;
>  sif = SPICE_CONTAINEROF(tablet->base.sif, SpiceTabletInterface,
>  base);
>  sif->position(tablet, pos->x, pos->y,
>  RED_MOUSE_STATE_TO_LOCAL(pos->buttons_state));
> @@ -379,7 +379,7 @@ static int inputs_channel_handle_parsed(RedChannelClient
> *rcc, uint32_t size, ui
>  dz = 1;
>  }
>  if (reds_get_mouse_mode(reds) == SPICE_MOUSE_MODE_CLIENT) {
> -if (reds_get_agent_mouse() && reds_has_vdagent(reds)) {
> +if (reds_get_agent_mouse(reds) && reds_has_vdagent(reds)) {
>  inputs_channel->mouse_state.buttons =
>  
> RED_MOUSE_BUTTON_STATE_TO_AGENT(mouse_press->buttons_state)
>  |
>  (dz == -1 ? VD_AGENT_UBUTTON_MASK : 0) |
> @@ -401,7 +401,7 @@ static int inputs_channel_handle_parsed(RedChannelClient
> *rcc, uint32_t size, ui
>  case SPICE_MSGC_INPUTS_MOUSE_RELEASE: {
>  SpiceMsgcMouseRelease *mouse_release = message;
>  if (reds_get_mouse_mode(reds) == SPICE_MOUSE_MODE_CLIENT) {
> -if (reds_get_agent_mouse() && reds_has_vdagent(reds)) {
> +if (reds_get_agent_mouse(reds) && reds_has_vdagent(reds)) {
>  inputs_channel->mouse_state.buttons =
>  
> RED_MOUSE_BUTTON_STATE_TO_AGENT(mouse_release->buttons_state);
>  reds_handle_agent_mouse_event(reds,
>  _channel->mouse_state);
> diff --git a/server/reds-private.h b/server/reds-private.h
> index 389bc5b..d29febf 100644
> --- a/server/reds-private.h
> +++ b/server/reds-private.h
> @@ -220,6 +220,8 @@ struct RedsState {
>  SpiceImageCompression image_compression;
>  spice_wan_compression_t jpeg_state;
>  spice_wan_compression_t zlib_glz_state;
> +
> +gboolean agent_mouse;
>  };
>  
>  #endif
> diff --git a/server/reds.c b/server/reds.c
> index 87a5d6d..4f9f087 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -146,7 +146,6 @@ static SpiceCoreInterfaceInternal core_interface_adapter
> = {
>  
>  static pthread_mutex_t *lock_cs;
>  static long *lock_count;
> -int agent_mouse = TRUE;
>  int agent_copypaste = TRUE;
>  int agent_file_xfer = TRUE;
>  static bool exit_on_disconnect = FALSE;
> @@ -580,9 +579,9 @@ static void reds_set_mouse_mode(RedsState *reds, uint32_t
> mode)
>  main_channel_push_mouse_mode(reds->main_channel, reds->mouse_mode,
>  reds->is_client_mouse_allowed);
>  }
>  
> -int reds_get_agent_mouse(void)
> +gboolean reds_get_agent_mouse(RedsState *reds)
>  {
> -return agent_mouse;
> +return reds->agent_mouse;
>  }
>  
>  static void reds_update_mouse_mode(RedsState *reds)
> @@ -590,7 +589,7 @@ static void reds_update_mouse_mode(RedsState *reds)
>  int allowed = 0;
>  int qxl_count = red_dispatcher_qxl_count();
>  
> -if ((agent_mouse && reds->vdagent) ||
> +if ((reds->agent_mouse && reds->vdagent) ||
>  (inputs_channel_has_tablet(reds->inputs_channel) && qxl_count == 1))
>  {
>  allowed = reds->dispatcher_allows_client_mouse;
>  }
> @@ -3428,6 +3427,7 @@ SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
>  reds->image_compression = SPICE_IMAGE_COMPRESSION_AUTO_GLZ;
>  reds->jpeg_state = SPICE_WAN_COMPRESSION_AUTO;
>  reds->zlib_glz_state = SPICE_WAN_COMPRESSION_AUTO;
> +reds->agent_mouse = TRUE;
>  return reds;
>  }
>  
> @@ -3802,7 +3802,7 @@ SPICE_GNUC_VISIBLE int
> spice_server_set_playback_compression(SpiceServer *s, int
>  SPICE_GNUC_VISIBLE int spice_server_set_agent_mouse(SpiceServer *s, int
>  enable)
>  {
>  spice_assert(reds == s);
> -agent_mouse = enable;
> +s->agent_mouse = enable;
>  reds_update_mouse_mode(reds);
>  return 0;
>  }
> diff --git a/server/reds.h b/server/reds.h
> index ae9aef4..09df5d3 100644
> --- a/server/reds.h
> +++ b/server/reds.h
> @@ -59,7 +59,7 @@ void reds_set_client_mouse_allowed(RedsState *reds,
>  void 

Re: [Spice-devel] [PATCH v2] Move streaming_video to RedsState struct

2016-02-04 Thread Pavel Grunt
On Wed, 2016-02-03 at 15:10 -0600, Jonathon Jongsma wrote:
> Also requires adding reds_get_streaming_video() accessor so that
> other
> files can check this value.
Acked-by: Pavel Grunt 

Thanks,
Pavel

> ---
> 
>  - Changed back to assert
> 
>  server/red-dispatcher.c | 7 ---
>  server/red-worker.c | 2 +-
>  server/reds-private.h   | 1 +
>  server/reds.c   | 9 +++--
>  server/reds.h   | 2 +-
>  5 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
> index fa2a42c..374d5a9 100644
> --- a/server/red-dispatcher.c
> +++ b/server/red-dispatcher.c
> @@ -704,8 +704,9 @@ static void qxl_worker_loadvm_commands(QXLWorker
> *qxl_worker,
>  
>  static inline int calc_compression_level(void)
>  {
> -spice_assert(streaming_video != SPICE_STREAM_VIDEO_INVALID);
> -if ((streaming_video != SPICE_STREAM_VIDEO_OFF) ||
> +spice_assert(reds_get_streaming_video(reds) !=
> SPICE_STREAM_VIDEO_INVALID);
> +
> +if ((reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_OFF)
> ||
>  (spice_server_get_image_compression(reds) !=
> SPICE_IMAGE_COMPRESSION_QUIC)) {
>  return 0;
>  } else {
> @@ -736,7 +737,7 @@ void red_dispatcher_on_sv_change(void)
>  RedDispatcher *now = dispatchers;
>  while (now) {
>  now->qxl->st->qif->set_compression_level(now->qxl,
> compression_level);
> -payload.streaming_video = streaming_video;
> +payload.streaming_video = reds_get_streaming_video(reds);
>  dispatcher_send_message(>dispatcher,
>  RED_WORKER_MESSAGE_SET_STREAMING_VID
> EO,
>  );
> diff --git a/server/red-worker.c b/server/red-worker.c
> index f6c4f45..0549047 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -1541,7 +1541,7 @@ RedWorker* red_worker_new(QXLInstance *qxl,
> RedDispatcher *red_dispatcher)
>  
>  worker->cursor_channel = cursor_channel_new(worker);
>  // TODO: handle seemless migration. Temp, setting migrate to
> FALSE
> -worker->display_channel = display_channel_new(worker, FALSE,
> streaming_video,
> +worker->display_channel = display_channel_new(worker, FALSE,
> reds_get_streaming_video(reds),
>    init_info.n_surfac
> es);
>  
>  return worker;
> diff --git a/server/reds-private.h b/server/reds-private.h
> index 504cb27..6f9bbaf 100644
> --- a/server/reds-private.h
> +++ b/server/reds-private.h
> @@ -216,6 +216,7 @@ struct RedsState {
>  uint8_t spice_uuid[16];
>  
>  gboolean ticketing_enabled;
> +uint32_t streaming_video;
>  SpiceImageCompression image_compression;
>  spice_wan_compression_t jpeg_state;
>  };
> diff --git a/server/reds.c b/server/reds.c
> index 91550ed..f50690c 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -146,7 +146,6 @@ static SpiceCoreInterfaceInternal
> core_interface_adapter = {
>  
>  static pthread_mutex_t *lock_cs;
>  static long *lock_count;
> -uint32_t streaming_video = SPICE_STREAM_VIDEO_FILTER;
>  spice_wan_compression_t zlib_glz_state = SPICE_WAN_COMPRESSION_AUTO;
>  int agent_mouse = TRUE;
>  int agent_copypaste = TRUE;
> @@ -3426,6 +3425,7 @@ SPICE_GNUC_VISIBLE SpiceServer
> *spice_server_new(void)
>  reds->spice_uuid_is_set = FALSE;
>  memset(reds->spice_uuid, 0, sizeof(reds->spice_uuid));
>  reds->ticketing_enabled = TRUE; /* ticketing enabled by default
> */
> +reds->streaming_video = SPICE_STREAM_VIDEO_FILTER;
>  reds->image_compression = SPICE_IMAGE_COMPRESSION_AUTO_GLZ;
>  reds->jpeg_state = SPICE_WAN_COMPRESSION_AUTO;
>  return reds;
> @@ -3782,11 +3782,16 @@ SPICE_GNUC_VISIBLE int
> spice_server_set_streaming_video(SpiceServer *s, int valu
>  value != SPICE_STREAM_VIDEO_ALL &&
>  value != SPICE_STREAM_VIDEO_FILTER)
>  return -1;
> -streaming_video = value;
> +s->streaming_video = value;
>  red_dispatcher_on_sv_change();
>  return 0;
>  }
>  
> +uint32_t reds_get_streaming_video(RedsState *reds)
> +{
> +return reds->streaming_video;
> +}
> +
>  SPICE_GNUC_VISIBLE int
> spice_server_set_playback_compression(SpiceServer *s, int enable)
>  {
>  spice_assert(reds == s);
> diff --git a/server/reds.h b/server/reds.h
> index 97b08b5..e62f0ba 100644
> --- a/server/reds.h
> +++ b/server/reds.h
> @@ -73,7 +73,6 @@ enum {
>  };
>  
>  extern struct SpiceCoreInterfaceInternal *core;
> -extern uint32_t streaming_video;
>  extern spice_wan_compression_t zlib_glz_state;
>  
>  // Temporary measures to make splitting reds.c to inputs-channel.c
> easier
> @@ -111,6 +110,7 @@ void reds_on_main_channel_migrate(RedsState
> *reds, MainChannelClient *mcc);
>  void reds_on_char_device_state_destroy(RedsState *reds,
> SpiceCharDeviceState *dev);
>  
>  void reds_set_client_mm_time_latency(RedsState *reds, RedClient
> *client, uint32_t latency);
> +uint32_t 

Re: [Spice-devel] [PATCH v2] Move agent_mouse to RedsState struct

2016-02-04 Thread Pavel Grunt
On Wed, 2016-02-03 at 15:07 -0600, Jonathon Jongsma wrote:
> Required adding a RedsState arg to reds_get_agent_mouse()
Acked-by: Pavel Grunt 
> ---
>  server/inputs-channel.c |  8 
>  server/reds-private.h   |  2 ++
>  server/reds.c   | 10 +-
>  server/reds.h   |  2 +-
>  4 files changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/server/inputs-channel.c b/server/inputs-channel.c
> index 8f5ab37..319d26c 100644
> --- a/server/inputs-channel.c
> +++ b/server/inputs-channel.c
> @@ -355,8 +355,8 @@ static int
> inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
>  if (reds_get_mouse_mode(reds) != SPICE_MOUSE_MODE_CLIENT) {
>  break;
>  }
> -spice_assert((reds_get_agent_mouse() &&
> reds_has_vdagent(reds)) || tablet);
> -if (!reds_get_agent_mouse() || !reds_has_vdagent(reds)) {
> +spice_assert((reds_get_agent_mouse(reds) &&
> reds_has_vdagent(reds)) || tablet);
> +if (!reds_get_agent_mouse(reds) || !reds_has_vdagent(reds))
> {
>  SpiceTabletInterface *sif;
>  sif = SPICE_CONTAINEROF(tablet->base.sif,
> SpiceTabletInterface, base);
>  sif->position(tablet, pos->x, pos->y,
> RED_MOUSE_STATE_TO_LOCAL(pos->buttons_state));
> @@ -379,7 +379,7 @@ static int
> inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
>  dz = 1;
>  }
>  if (reds_get_mouse_mode(reds) == SPICE_MOUSE_MODE_CLIENT) {
> -if (reds_get_agent_mouse() && reds_has_vdagent(reds)) {
> +if (reds_get_agent_mouse(reds) &&
> reds_has_vdagent(reds)) {
>  inputs_channel->mouse_state.buttons =
>  RED_MOUSE_BUTTON_STATE_TO_AGENT(mouse_press-
> >buttons_state) |
>  (dz == -1 ? VD_AGENT_UBUTTON_MASK : 0) |
> @@ -401,7 +401,7 @@ static int
> inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
>  case SPICE_MSGC_INPUTS_MOUSE_RELEASE: {
>  SpiceMsgcMouseRelease *mouse_release = message;
>  if (reds_get_mouse_mode(reds) == SPICE_MOUSE_MODE_CLIENT) {
> -if (reds_get_agent_mouse() && reds_has_vdagent(reds)) {
> +if (reds_get_agent_mouse(reds) &&
> reds_has_vdagent(reds)) {
>  inputs_channel->mouse_state.buttons =
>  RED_MOUSE_BUTTON_STATE_TO_AGENT(mouse_release-
> >buttons_state);
>  reds_handle_agent_mouse_event(reds, _channel-
> >mouse_state);
> diff --git a/server/reds-private.h b/server/reds-private.h
> index 389bc5b..d29febf 100644
> --- a/server/reds-private.h
> +++ b/server/reds-private.h
> @@ -220,6 +220,8 @@ struct RedsState {
>  SpiceImageCompression image_compression;
>  spice_wan_compression_t jpeg_state;
>  spice_wan_compression_t zlib_glz_state;
> +
> +gboolean agent_mouse;
>  };
>  
>  #endif
> diff --git a/server/reds.c b/server/reds.c
> index 87a5d6d..4f9f087 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -146,7 +146,6 @@ static SpiceCoreInterfaceInternal
> core_interface_adapter = {
>  
>  static pthread_mutex_t *lock_cs;
>  static long *lock_count;
> -int agent_mouse = TRUE;
>  int agent_copypaste = TRUE;
>  int agent_file_xfer = TRUE;
>  static bool exit_on_disconnect = FALSE;
> @@ -580,9 +579,9 @@ static void reds_set_mouse_mode(RedsState *reds,
> uint32_t mode)
>  main_channel_push_mouse_mode(reds->main_channel, reds-
> >mouse_mode, reds->is_client_mouse_allowed);
>  }
>  
> -int reds_get_agent_mouse(void)
> +gboolean reds_get_agent_mouse(RedsState *reds)
>  {
> -return agent_mouse;
> +return reds->agent_mouse;
>  }
>  
>  static void reds_update_mouse_mode(RedsState *reds)
> @@ -590,7 +589,7 @@ static void reds_update_mouse_mode(RedsState
> *reds)
>  int allowed = 0;
>  int qxl_count = red_dispatcher_qxl_count();
>  
> -if ((agent_mouse && reds->vdagent) ||
> +if ((reds->agent_mouse && reds->vdagent) ||
>  (inputs_channel_has_tablet(reds->inputs_channel) &&
> qxl_count == 1)) {
>  allowed = reds->dispatcher_allows_client_mouse;
>  }
> @@ -3428,6 +3427,7 @@ SPICE_GNUC_VISIBLE SpiceServer
> *spice_server_new(void)
>  reds->image_compression = SPICE_IMAGE_COMPRESSION_AUTO_GLZ;
>  reds->jpeg_state = SPICE_WAN_COMPRESSION_AUTO;
>  reds->zlib_glz_state = SPICE_WAN_COMPRESSION_AUTO;
> +reds->agent_mouse = TRUE;
>  return reds;
>  }
>  
> @@ -3802,7 +3802,7 @@ SPICE_GNUC_VISIBLE int
> spice_server_set_playback_compression(SpiceServer *s, int
>  SPICE_GNUC_VISIBLE int spice_server_set_agent_mouse(SpiceServer *s,
> int enable)
>  {
>  spice_assert(reds == s);
> -agent_mouse = enable;
> +s->agent_mouse = enable;
>  reds_update_mouse_mode(reds);
>  return 0;
>  }
> diff --git a/server/reds.h b/server/reds.h
> index ae9aef4..09df5d3 100644
> --- a/server/reds.h
> +++ b/server/reds.h
> @@ -59,7 +59,7 @@ void 

Re: [Spice-devel] [PATCH 12/18] Move ssl_parameters to RedsState struct

2016-02-04 Thread Frediano Ziglio
> 
> From: Jonathon Jongsma 
> 
> Removing more global variables
> ---
>  server/reds-private.h | 11 +
>  server/reds.c | 65
>  ++-
>  2 files changed, 39 insertions(+), 37 deletions(-)
> 
> diff --git a/server/reds-private.h b/server/reds-private.h
> index 5042773..2a6f438 100644
> --- a/server/reds-private.h
> +++ b/server/reds-private.h
> @@ -137,6 +137,15 @@ typedef struct RedsClientMonitorsConfig {
>  
>  typedef struct ChannelSecurityOptions ChannelSecurityOptions;
>  
> +typedef struct RedSSLParameters {
> +char keyfile_password[256];
> +char certs_file[256];
> +char private_key_file[256];
> +char ca_certificate_file[256];
> +char dh_key_file[256];
> +char ciphersuite[256];
> +} RedSSLParameters;
> +
>  struct RedsState {
>  int listen_socket;
>  int secure_listen_socket;
> @@ -225,6 +234,8 @@ struct RedsState {
>  gboolean agent_copypaste;
>  gboolean agent_file_xfer;
>  gboolean exit_on_disconnect;
> +
> +RedSSLParameters ssl_parameters;
>  };
>  
>  #endif
> diff --git a/server/reds.c b/server/reds.c
> index b25a1be..14857c2 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -159,15 +159,6 @@ typedef struct RedLinkInfo {
>  int skip_auth;
>  } RedLinkInfo;
>  
> -typedef struct RedSSLParameters {
> -char keyfile_password[256];
> -char certs_file[256];
> -char private_key_file[256];
> -char ca_certificate_file[256];
> -char dh_key_file[256];
> -char ciphersuite[256];
> -} RedSSLParameters;
> -
>  struct ChannelSecurityOptions {
>  uint32_t channel_id;
>  uint32_t options;
> @@ -187,8 +178,6 @@ static VDIReadBuf *vdi_port_read_buf_get(RedsState
> *reds);
>  static VDIReadBuf *vdi_port_read_buf_ref(VDIReadBuf *buf);
>  static void vdi_port_read_buf_unref(RedsState *reds, VDIReadBuf *buf);
>  
> -static RedSSLParameters ssl_parameters;
> -
>  static ChannelSecurityOptions *reds_find_channel_security(RedsState *reds,
>  int id)
>  {
>  ChannelSecurityOptions *now = reds->channels_security;
> @@ -2611,7 +2600,8 @@ static int load_dh_params(SSL_CTX *ctx, char *file)
>  /*The password code is not thread safe*/
>  static int ssl_password_cb(char *buf, int size, int flags, void *userdata)
>  {
> -char *pass = ssl_parameters.keyfile_password;
> +RedsState *reds = userdata;
> +char *pass = reds->ssl_parameters.keyfile_password;
>  if (size < strlen(pass) + 1) {
>  return (0);
>  }
> @@ -2686,31 +2676,32 @@ static int reds_init_ssl(RedsState *reds)
>  SSL_CTX_set_options(reds->ctx, ssl_options);
>  
>  /* Load our keys and certificates*/
> -return_code = SSL_CTX_use_certificate_chain_file(reds->ctx,
> ssl_parameters.certs_file);
> +return_code = SSL_CTX_use_certificate_chain_file(reds->ctx,
> reds->ssl_parameters.certs_file);
>  if (return_code == 1) {
> -spice_info("Loaded certificates from %s",
> ssl_parameters.certs_file);
> +spice_info("Loaded certificates from %s",
> reds->ssl_parameters.certs_file);
>  } else {
> -spice_warning("Could not load certificates from %s",
> ssl_parameters.certs_file);
> +spice_warning("Could not load certificates from %s",
> reds->ssl_parameters.certs_file);
>  return -1;
>  }
>  
>  SSL_CTX_set_default_passwd_cb(reds->ctx, ssl_password_cb);
> +SSL_CTX_set_default_passwd_cb_userdata(reds->ctx, reds);
>  
> -return_code = SSL_CTX_use_PrivateKey_file(reds->ctx,
> ssl_parameters.private_key_file,
> +return_code = SSL_CTX_use_PrivateKey_file(reds->ctx,
> reds->ssl_parameters.private_key_file,
>SSL_FILETYPE_PEM);
>  if (return_code == 1) {
> -spice_info("Using private key from %s",
> ssl_parameters.private_key_file);
> +spice_info("Using private key from %s",
> reds->ssl_parameters.private_key_file);
>  } else {
>  spice_warning("Could not use private key file");
>  return -1;
>  }
>  
>  /* Load the CAs we trust*/
> -return_code = SSL_CTX_load_verify_locations(reds->ctx,
> ssl_parameters.ca_certificate_file, 0);
> +return_code = SSL_CTX_load_verify_locations(reds->ctx,
> reds->ssl_parameters.ca_certificate_file, 0);
>  if (return_code == 1) {
> -spice_info("Loaded CA certificates from %s",
> ssl_parameters.ca_certificate_file);
> +spice_info("Loaded CA certificates from %s",
> reds->ssl_parameters.ca_certificate_file);
>  } else {
> -spice_warning("Could not use CA file %s",
> ssl_parameters.ca_certificate_file);
> +spice_warning("Could not use CA file %s",
> reds->ssl_parameters.ca_certificate_file);
>  return -1;
>  }
>  
> @@ -2718,15 +2709,15 @@ static int reds_init_ssl(RedsState *reds)
>  SSL_CTX_set_verify_depth(reds->ctx, 1);
>  #endif
>  
> -if (strlen(ssl_parameters.dh_key_file) > 0) {
> -if 

Re: [Spice-devel] [PATCH 1/5] common: constify some declarations

2016-02-04 Thread Uri Lublin

On 01/27/2016 06:09 PM, Frediano Ziglio wrote:

Signed-off-by: Frediano Ziglio 
---
  common/log.c| 2 +-
  common/marshaller.c | 7 +--
  common/marshaller.h | 2 +-
  3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/common/log.c b/common/log.c
index 607aa82..a9bbebc 100644
--- a/common/log.c
+++ b/common/log.c
@@ -43,7 +43,7 @@ static int abort_level = -1;

  static GLogLevelFlags spice_log_level_to_glib(SpiceLogLevel level)
  {
-static GLogLevelFlags glib_levels[] = {
+static const GLogLevelFlags glib_levels[] = {
  [ SPICE_LOG_LEVEL_ERROR ] = G_LOG_LEVEL_ERROR,
  [ SPICE_LOG_LEVEL_CRITICAL ] = G_LOG_LEVEL_CRITICAL,
  [ SPICE_LOG_LEVEL_WARNING ] = G_LOG_LEVEL_WARNING,
diff --git a/common/marshaller.c b/common/marshaller.c
index c967371..c1d208e 100644
--- a/common/marshaller.c
+++ b/common/marshaller.c
@@ -347,9 +347,12 @@ uint8_t *spice_marshaller_add(SpiceMarshaller *m, const 
uint8_t *data, size_t si
  return ptr;
  }

-uint8_t *spice_marshaller_add_ref(SpiceMarshaller *m, uint8_t *data, size_t 
size)
+uint8_t *spice_marshaller_add_ref(SpiceMarshaller *m, const uint8_t *data, 
size_t size)
  {
-return spice_marshaller_add_ref_full(m, data, size, NULL, NULL);
+/* the cast to no-const here is safe as data is used for writing only if
+ * free_data pointer is not NULL
+ */
+return spice_marshaller_add_ref_full(m, (uint8_t *) data, size, NULL, 
NULL);
  }


Hi Frediano,

Isn't there a potential problem with data being returned as non-const ?
I see currently no caller looks at the data returned.

Regards,
Uri.



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


[Spice-devel] [PATCH] channel: fix typo in comment

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

diff --git a/server/red-channel.c b/server/red-channel.c
index fdd85b9..4bc2faa 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -1506,7 +1506,7 @@ static void 
red_channel_client_handle_pong(RedChannelClient *rcc, SpiceMsgPing *
 return;
 }
 
-/* set TCO_NODELAY=0, in case we reverted it for the test*/
+/* set TCP_NODELAY=0, in case we reverted it for the test*/
 if (!rcc->latency_monitor.tcp_nodelay) {
 int delay_val = 0;
 
-- 
2.5.0

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


Re: [Spice-devel] [PATCH v3 8/9] Handle GL_DRAW messages

2016-02-04 Thread Frediano Ziglio
> 
> Create an async, and marshall the GL_DRAW message. Count number of
> clients, and wait until gl_draw_async_count is 0 to complete the async.
> The count is going to be updated in the following patch when the client
> is done with the draw.
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  server/dcc-send.c| 14 ++
>  server/dcc.c | 23 +++
>  server/dcc.h |  9 +
>  server/display-channel.c | 22 ++
>  server/display-channel.h |  3 +++
>  server/red-dispatcher.c  | 14 ++
>  server/red-dispatcher.h  |  1 +
>  server/red-worker.c  | 14 ++
>  server/reds.h|  1 +
>  9 files changed, 101 insertions(+)
> 
> diff --git a/server/dcc-send.c b/server/dcc-send.c
> index a9cc19c..3af5760 100644
> --- a/server/dcc-send.c
> +++ b/server/dcc-send.c
> @@ -2321,6 +2321,17 @@ end:
>  pthread_mutex_unlock(>st->scanout_mutex);
>  }
>  
> +static void marshall_gl_draw(RedChannelClient *rcc,
> + SpiceMarshaller *m,
> + PipeItem *item)
> +{
> +GlDrawItem *p = SPICE_CONTAINEROF(item, GlDrawItem, base);
> +
> +red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_GL_DRAW, NULL);
> +spice_marshall_msg_display_gl_draw(m, >draw);
> +}
> +
> +
>  static void begin_send_message(RedChannelClient *rcc)
>  {
>  DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
> @@ -2435,6 +2446,9 @@ void dcc_send_item(DisplayChannelClient *dcc, PipeItem
> *pipe_item)
>  case PIPE_ITEM_TYPE_GL_SCANOUT:
>  marshall_gl_scanout(rcc, m, pipe_item);
>  break;
> +case PIPE_ITEM_TYPE_GL_DRAW:
> +marshall_gl_draw(rcc, m, pipe_item);
> +break;
>  default:
>  spice_warn_if_reached();
>  }
> diff --git a/server/dcc.c b/server/dcc.c
> index 58ae55c..6972616 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -586,6 +586,27 @@ PipeItem *dcc_gl_scanout_item_new(RedChannelClient *rcc,
> void *data, int num)
>  return >base;
>  }
>  
> +PipeItem *dcc_gl_draw_item_new(RedChannelClient *rcc, void *data, int num)
> +{
> +DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
> +const SpiceMsgDisplayGlDraw *draw = data;
> +GlDrawItem *item = spice_new(GlDrawItem, 1);
> +spice_return_val_if_fail(item != NULL, NULL);
> +
> +if (!red_channel_client_test_remote_cap(rcc,
> SPICE_DISPLAY_CAP_GL_SCANOUT)) {
> +spice_printerr("FIXME: client does not support GL scanout");
> +red_channel_client_disconnect(rcc);
> +return NULL;
> +}
> +
> +dcc->gl_draw_ongoing = TRUE;
> +item->draw = *draw;
> +red_channel_pipe_item_init(rcc->channel, >base,
> +   PIPE_ITEM_TYPE_GL_DRAW);
> +
> +return >base;
> +}
> +
>  void dcc_destroy_surface(DisplayChannelClient *dcc, uint32_t surface_id)
>  {
>  DisplayChannel *display;
> @@ -1558,6 +1579,7 @@ static void
> release_item_after_push(DisplayChannelClient *dcc, PipeItem *item)
>  image_item_unref((ImageItem *)item);
>  break;
>  case PIPE_ITEM_TYPE_GL_SCANOUT:
> +case PIPE_ITEM_TYPE_GL_DRAW:
>  case PIPE_ITEM_TYPE_VERB:
>  free(item);
>  break;
> @@ -1633,6 +1655,7 @@ static void
> release_item_before_push(DisplayChannelClient *dcc, PipeItem *item)
>  case PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE:
>  case PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT:
>  case PIPE_ITEM_TYPE_GL_SCANOUT:
> +case PIPE_ITEM_TYPE_GL_DRAW:
>  free(item);
>  break;
>  default:
> diff --git a/server/dcc.h b/server/dcc.h
> index 4ef6073..842b7d4 100644
> --- a/server/dcc.h
> +++ b/server/dcc.h
> @@ -111,6 +111,7 @@ struct DisplayChannelClient {
>  int use_mjpeg_encoder_rate_control;
>  uint32_t streams_max_latency;
>  uint64_t streams_max_bit_rate;
> +bool gl_draw_ongoing;
>  };
>  
>  #define DCC_TO_WORKER(dcc)  \
> @@ -128,6 +129,12 @@ typedef struct GlScanoutUnixItem {
>  PipeItem base;
>  } GlScanoutUnixItem;
>  
> +typedef struct GlDrawItem {
> +PipeItem base;
> +SpiceMsgDisplayGlDraw draw;
> +int sent;
> +} GlDrawItem;
> +
>  typedef struct ImageItem {
>  PipeItem link;
>  int refs;
> @@ -213,6 +220,8 @@ intdcc_drawable_is_in_pipe
> (DisplayCha
>
> Drawable
>
> *drawable);
>  PipeItem * dcc_gl_scanout_item_new
>  (RedChannelClient *rcc,
>void
>*data,
>int
>num);
> +PipeItem * 

Re: [Spice-devel] [vd-agent-win32 0/2] Add support for WDDM driver

2016-02-04 Thread Javier Celaya

Hi

El 04/02/16 a las 15:12, Fabio Fantoni escribió:

Il 04/02/2016 13:31, Javier Celaya ha scritto:

This patch set adds support for dynamic resolution changes with the WDDM
driver on Windows >= 8. It is based on the one sent by Vadim Rozenfeld
with some improvements:

- It detects both the XDDM driver and the WDDM driver, and uses the
   correct API.
- It detects if the client is trying to set the same resolution again,
   and does nothing. This is the result of the client detecting a primary
   surface destruction/construction when the resolution changes, and
   asking for a resolution change again. This bug does not happen with
   the XDDM driver, so it may be avoidable in some other way.
- It uses an alternative method to update the list of display modes,
   that results in a nicer effect when changing the resolution. This
   method is compatible with the current driver implementation (v0.12),
   but for best results we have modified the driver to drop the previous
   method and to improve support of hardware pointers. The source can be
   found in https://github.com/flexvdi/qxl-dod, and precompiled and signed
   binaries can be downloaded from http://depot.flexvdi.com/guest-tools/.

Big thanks for help improving windows>=8 support (unfortunately still
overlooked).
I want do a fast test to see is your changes solve the bugs (and/or
occasional hangs) I have found trying spice-guest-tools 0.100 and
qxlwddm-0.12.zip on windows 10 guests. For tests your improvements I can
simply install spice-guest-tools.exe inside
flexvdi-guest-tools-2.2.3.exe and qxlwddm-0.13-flexvdi.zip?
You can just install spice-guest-tools.exe, as it includes both the 
patched vdagent.exe and the new driver.


Thanks for any reply and sorry for my bad english.


Javier Celaya (2):
   Detect and use the new WDDM driver
   Use CCD API to update the WDDM display modes.

  common/vdcommon.h  | 106 ++
  vdagent/desktop_layout.cpp | 156 +
  2 files changed, 250 insertions(+), 12 deletions(-)





--





Javier Celaya

Software Engineer



j avier.cel...@flexvdi.com

+34 876 60 00 73

@j_celaya

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


[Spice-devel] [PATCH] record: save real time during recording

2016-02-04 Thread Frediano Ziglio
Instead of using CPU time use a timer depending on real times.
Currently that time in the record log is not used.
However if we want to reproduce problems with stream would be useful
to have real times instead.

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 df24a5b..e70c9df 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -242,7 +242,7 @@ static int red_process_display(RedWorker *worker, int 
*ring_is_empty)
 
 if (worker->record_fd)
 red_record_qxl_command(worker->record_fd, >mem_slots, 
ext_cmd,
-   stat_now(CLOCK_THREAD_CPUTIME_ID));
+   stat_now(CLOCK_MONOTONIC));
 
 stat_inc_counter(worker->command_counter, 1);
 worker->display_poll_tries = 0;
@@ -1221,7 +1221,7 @@ static void worker_dispatcher_record(void *opaque, 
uint32_t message_type, void *
 {
 RedWorker *worker = opaque;
 
-red_record_event(worker->record_fd, 1, message_type, 
stat_now(CLOCK_THREAD_CPUTIME_ID));
+red_record_event(worker->record_fd, 1, message_type, 
stat_now(CLOCK_MONOTONIC));
 }
 
 static void register_callbacks(Dispatcher *dispatcher)
-- 
2.5.0

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


Re: [Spice-devel] [PATCH] reds: constification

2016-02-04 Thread Daniel P. Berrange
On Thu, Feb 04, 2016 at 04:03:10PM +, Frediano Ziglio wrote:
> Make version_string a constant.
> Also there is no need to have a pointer but declare the buffer as static
> 
> Signed-off-by: Frediano Ziglio 
> ---
>  server/reds.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/server/reds.c b/server/reds.c
> index edbdaad..4225847 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -3299,7 +3299,7 @@ static void reds_init_vd_agent_resources(RedsState 
> *reds)
>  }
>  }
>  
> -const char *version_string = VERSION;
> +static const char version_string[] = VERSION;

The 'version_string' is only used once:

$ git grep version_string
reds.c:const char *version_string = VERSION;
reds.c:spice_info("starting %s", version_string);

So why not just kill the pointless variable and directly
use 'VERSION' in the call to spice_info()

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] channel: fix typo in comment

2016-02-04 Thread Victor Toso
On Thu, Feb 04, 2016 at 04:01:31PM +, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio 
Acked-by: Victor Toso 

> ---
>  server/red-channel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/server/red-channel.c b/server/red-channel.c
> index fdd85b9..4bc2faa 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -1506,7 +1506,7 @@ static void 
> red_channel_client_handle_pong(RedChannelClient *rcc, SpiceMsgPing *
>  return;
>  }
>  
> -/* set TCO_NODELAY=0, in case we reverted it for the test*/
> +/* set TCP_NODELAY=0, in case we reverted it for the test*/
>  if (!rcc->latency_monitor.tcp_nodelay) {
>  int delay_val = 0;
>  
> -- 
> 2.5.0
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH v6 05/10] win-usbredir: Introduce UsbDk wrapper

2016-02-04 Thread Jonathon Jongsma
On Thu, 2015-10-29 at 17:26 +0200, Dmitry Fleytman wrote:
> From: Kirill Moizik 
> 
> Introduce UsbDk API definitions and binding code.

I would appreciate a bit more justification in the commit log about why we're
using this approach of dynamically loading and wrapping usbdk rather than
linking to a library.


> 
> Signed-off-by: Kirill Moizik 
> ---
>  src/Makefile.am |   2 +
>  src/usbdk_api.c | 187
> 
>  src/usbdk_api.h |  34 +++
>  3 files changed, 223 insertions(+)
>  create mode 100644 src/usbdk_api.c
>  create mode 100644 src/usbdk_api.h
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 0c40c48..6f4eb81 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -371,6 +371,8 @@ WIN_USB_FILES= \
>   win-usb-clerk.h \
>   win-usb-driver-install.h\
>   win-usb-driver-install.c\
> + usbdk_api.h \
> + usbdk_api.c \
>   $(NULL)
>  
>  if OS_WIN32
> diff --git a/src/usbdk_api.c b/src/usbdk_api.c
> new file mode 100644
> index 000..c4cb3b1
> --- /dev/null
> +++ b/src/usbdk_api.c
> @@ -0,0 +1,187 @@
> +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
> +/*
> +   Copyright (C) 2014-2015 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  >.
> +
> +  Authors:
> +Dmitry Fleytman 
> +Kirill Moizik 
> +*/
> +#include 
> +
> +#include 
> +#include 
> +#include "usbdk_api.h"
> +#include "channel-usbredir-priv.h"
> +
> +#define USB_DK_HIDE_RULE_MATCH_ALL ((ULONG64)(-1))
> +typedef struct tag_USB_DK_HIDE_RULE
> +{
> +ULONG64 Hide;
> +ULONG64 Class;
> +ULONG64 VID;
> +ULONG64 PID;
> +ULONG64 BCD;
> +} USB_DK_HIDE_RULE, *PUSB_DK_HIDE_RULE;
> +
> +typedef HANDLE(__cdecl *USBDK_CREATEHIDERHANDLE)(void);
> +typedef BOOL(__cdecl * USBDK_ADDHIDERULE)(HANDLE hider_handle,
> PUSB_DK_HIDE_RULE rule);
> +typedef BOOL(__cdecl *USBDK_CLEARHIDERULES)(HANDLE hider_handle);
> +typedef void(__cdecl *USBDK_CLOSEHIDERHANDLE)(HANDLE hider_handle);
> +
> +struct tag_usbdk_api_wrapper
> +{
> +HMODULE module;
> +USBDK_CREATEHIDERHANDLE CreateHandle;
> +USBDK_ADDHIDERULE   AddRule;
> +USBDK_CLEARHIDERULESClearRules;
> +USBDK_CLOSEHIDERHANDLE  CloseHiderHandle;
> +};
> +
> +BOOL usbdk_is_driver_installed(void)
> +{
> +gboolean usbdk_installed = FALSE;
> +SC_HANDLE managerHandle = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
> +
> +if (managerHandle) {
> +SC_HANDLE serviceHandle = OpenService(managerHandle, TEXT("UsbDk"),
> GENERIC_READ);
> +
> +if (serviceHandle) {
> +SPICE_DEBUG("UsbDk driver is installed.");
> +usbdk_installed = TRUE;
> +CloseServiceHandle(serviceHandle);
> +}
> +CloseServiceHandle(managerHandle);
> +}
> +return usbdk_installed;
> +}
> +
> +void usbdk_api_unload(usbdk_api_wrapper *usbdk_api)
> +{
> +if (usbdk_api->module != NULL) {

Here you dereference usbdk_api

> +SPICE_DEBUG("Unloading UsbDk API DLL");
> +FreeLibrary(usbdk_api->module);
> +}
> +
> +if (usbdk_api != NULL) {

yet here you check if usbdk_api is non-NULL. If it was NULL, we would have
already segfaulted above.

> +g_free(usbdk_api);
> +}
> +}
> +
> +BOOL usbdk_api_load(usbdk_api_wrapper **usbdk_api)
> +{
> +*usbdk_api = g_new0(usbdk_api_wrapper, 1);
> +
> +SPICE_DEBUG("Loading UsbDk API DLL");
> +(*usbdk_api)->module = LoadLibraryA("UsbDkHelper");
> +if ((*usbdk_api)->module == NULL) {
> +g_warning("Failed to load UsbDkHelper.dll, error %lu",
> GetLastError());
> +goto error_unload;
> +}
> +
> +(*usbdk_api)->CreateHandle = (USBDK_CREATEHIDERHANDLE)
> +GetProcAddress((*usbdk_api)->module, "UsbDk_CreateHiderHandle");
> +if ((*usbdk_api)->CreateHandle == NULL) {
> +g_warning("Failed to find CreateHandle entry point");
> +goto error_unload;
> +}
> +
> +(*usbdk_api)->AddRule = (USBDK_ADDHIDERULE)
> +GetProcAddress((*usbdk_api)->module, "UsbDk_AddHideRule");
> +if 

Re: [Spice-devel] [PATCH v6 03/10] Add SpiceUsbDeviceManager parameter to device comparison functions

2016-02-04 Thread Jonathon Jongsma
It doesn't seem that these new parameters are used until patch #7, unless I
missed something. So I'd re-order the patch series so that this comes right
before it's used (or even merge them together?).

Acked-by: Jonathon Jongsma 


On Thu, 2015-10-29 at 17:26 +0200, Dmitry Fleytman wrote:
> From: Christophe Fergeau 
> 
> This additional parameter is currently unused, but this is in
> preparation for the next commits.
> ---
>  src/usb-device-manager.c | 40 ++--
>  1 file changed, 22 insertions(+), 18 deletions(-)
> 
> diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
> index d261dce..4930613 100644
> --- a/src/usb-device-manager.c
> +++ b/src/usb-device-manager.c
> @@ -184,8 +184,9 @@ static guint8 spice_usb_device_get_state(SpiceUsbDevice
> *device);
>  static void  spice_usb_device_set_state(SpiceUsbDevice *device, guint8 s);
>  #endif
>  
> -static gboolean spice_usb_device_equal_libdev(SpiceUsbDevice *device,
> -  libusb_device *libdev);
> +static gboolean spice_usb_manager_device_equal_libdev(SpiceUsbDeviceManager
> *manager,
> +  SpiceUsbDevice *device,
> +  libusb_device *libdev);
>  static libusb_device *
>  spice_usb_device_manager_device_to_libdev(SpiceUsbDeviceManager *self,
>SpiceUsbDevice *device);
> @@ -641,7 +642,8 @@ static void
> spice_usb_device_manager_class_init(SpiceUsbDeviceManagerClass *klas
>  
>  #ifdef USE_GUDEV
>  static gboolean spice_usb_device_manager_get_udev_bus_n_address(
> -GUdevDevice *udev, int *bus, int *address)
> +SpiceUsbDeviceManager *manager, GUdevDevice *udev,
> +int *bus, int *address)
>  {
>  const gchar *bus_str, *address_str;
>  
> @@ -794,7 +796,7 @@ static void
> spice_usb_device_manager_auto_connect_cb(GObject  *gobject,
>  
>  #ifndef G_OS_WIN32 /* match functions for Linux -- match by bus.addr */
>  static gboolean
> -spice_usb_device_manager_device_match(SpiceUsbDevice *device,
> +spice_usb_device_manager_device_match(SpiceUsbDeviceManager *self,
> SpiceUsbDevice *device,
>const int bus, const int address)
>  {
>  return (spice_usb_device_get_busnum(device) == bus &&
> @@ -803,7 +805,7 @@ spice_usb_device_manager_device_match(SpiceUsbDevice
> *device,
>  
>  #ifdef USE_GUDEV
>  static gboolean
> -spice_usb_device_manager_libdev_match(libusb_device *libdev,
> +spice_usb_device_manager_libdev_match(SpiceUsbDeviceManager *self,
> libusb_device *libdev,
>const int bus, const int address)
>  {
>  return (libusb_get_bus_number(libdev) == bus &&
> @@ -813,7 +815,7 @@ spice_usb_device_manager_libdev_match(libusb_device
> *libdev,
>  
>  #else /* Win32 -- match functions for Windows -- match by vid:pid */
>  static gboolean
> -spice_usb_device_manager_device_match(SpiceUsbDevice *device,
> +spice_usb_device_manager_device_match(SpiceUsbDeviceManager *self,
> SpiceUsbDevice *device,
>const int vid, const int pid)
>  {
>  return (spice_usb_device_get_vid(device) == vid &&
> @@ -821,7 +823,7 @@ spice_usb_device_manager_device_match(SpiceUsbDevice
> *device,
>  }
>  
>  static gboolean
> -spice_usb_device_manager_libdev_match(libusb_device *libdev,
> +spice_usb_device_manager_libdev_match(SpiceUsbDeviceManager *self,
> libusb_device *libdev,
>const int vid, const int pid)
>  {
>  int vid2, pid2;
> @@ -843,7 +845,7 @@ spice_usb_device_manager_find_device(SpiceUsbDeviceManager
> *self,
>  
>  for (i = 0; i < priv->devices->len; i++) {
>  curr = g_ptr_array_index(priv->devices, i);
> -if (spice_usb_device_manager_device_match(curr, bus, address)) {
> +if (spice_usb_device_manager_device_match(self, curr, bus, address))
> {
>  device = curr;
>  break;
>  }
> @@ -946,7 +948,7 @@ static void
> spice_usb_device_manager_add_udev(SpiceUsbDeviceManager  *self,
>  if (!devtype || strcmp(devtype, "usb_device"))
>  return;
>  
> -if (!spice_usb_device_manager_get_udev_bus_n_address(udev, ,
> )) {
> +if (!spice_usb_device_manager_get_udev_bus_n_address(self, udev, ,
> )) {
>  g_warning("USB device without bus number or device address");
>  return;
>  }
> @@ -967,7 +969,7 @@ static void
> spice_usb_device_manager_add_udev(SpiceUsbDeviceManager  *self,
>  libusb_get_device_list(priv->context, _list);
>  
>  for (i = 0; dev_list && dev_list[i]; i++) {
> -if (spice_usb_device_manager_libdev_match(dev_list[i], bus, address))
> {
> +if (spice_usb_device_manager_libdev_match(self, dev_list[i], bus,
> address)) {
>  libdev = dev_list[i];
>  break;
>  }
> @@