Re: [Spice-devel] unexpected protocol interaction when playing vedio.

2014-11-05 Thread jiangdahui


thanks for reminding from your configuration,as I find that without  image 
compression='auto_glz'/, the client could receive STREAM_DATA,and I find the 
reason in code too,I think I should first be familar using it,sorry for 
disturbing.







At 2014-11-04 00:53:39, Christophe Fergeau cferg...@redhat.com wrote:
On Mon, Nov 03, 2014 at 05:53:03PM +0100, Christophe Fergeau wrote:
 Hey,
 On Mon, Nov 03, 2014 at 10:11:20AM +0800, jiangdahui wrote:
  yes,I have set the  streaming mode to be all,but still can not see 
  STREAM_DATA,
  I will keep investigating for this,could you send the configuration of 
  your VM to me,
 
 See attached file, and let me know if this helps :)

Better with the file actually attached...

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


[Spice-devel] [PATCH spice-gtk 1/2] Support for keyboard description message

2014-11-05 Thread Pavel Grunt
This commit introduces function for sending the message to the agent.

RFE: https://bugs.freedesktop.org/show_bug.cgi?id=85332
---
depends on: 
http://lists.freedesktop.org/archives/spice-devel/2014-November/017821.html
---
 gtk/channel-main.c | 32 
 gtk/channel-main.h |  2 ++
 gtk/map-file   |  1 +
 3 files changed, 35 insertions(+)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 1ad090f..66587d6 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -187,6 +187,7 @@ static const char *agent_msg_types[] = {
 [ VD_AGENT_CLIPBOARD_GRAB  ] = clipboard grab,
 [ VD_AGENT_CLIPBOARD_REQUEST   ] = clipboard request,
 [ VD_AGENT_CLIPBOARD_RELEASE   ] = clipboard release,
+[ VD_AGENT_KEYBOARD_DESCRIPTION] = keyboard description,
 };
 
 static const char *agent_caps[] = {
@@ -1282,6 +1283,18 @@ static void agent_clipboard_release(SpiceMainChannel 
*channel, guint selection)
 agent_msg_queue(channel, VD_AGENT_CLIPBOARD_RELEASE, msgsize, msg);
 }
 
+/* any context: the message is not flushed immediately,
+   you can wakeup() the channel coroutine or send_msg_queue() */
+static void agent_keyboard_description(SpiceMainChannel *channel,
+   const gchar *data, size_t size)
+{
+SpiceMainChannelPrivate *c = channel-priv;
+
+g_return_if_fail(c-agent_connected);
+
+agent_msg_queue(channel, VD_AGENT_KEYBOARD_DESCRIPTION, size, data);
+}
+
 /* main context*/
 static gboolean timer_set_display(gpointer data)
 {
@@ -2630,6 +2643,25 @@ void spice_main_set_display_enabled(SpiceMainChannel 
*channel, int id, gboolean
 update_display_timer(channel, 1);
 }
 
+/**
+ * spice_main_keyboard_description:
+ * @channel: a #SpiceMainChannel
+ * @data: keyboard description
+ * @size: data length in bytes
+ *
+ * Send the keyboard description to the guest.
+ *
+ **/
+void spice_main_keyboard_description(SpiceMainChannel *channel,
+ const gchar *data, size_t size)
+{
+g_return_if_fail(channel != NULL);
+g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
+
+agent_keyboard_description(channel, data, size);
+spice_channel_wakeup(SPICE_CHANNEL(channel), FALSE);
+}
+
 static void file_xfer_completed(SpiceFileXferTask *task, GError *error)
 {
 /* In case of multiple errors we only report the first error */
diff --git a/gtk/channel-main.h b/gtk/channel-main.h
index 3e4fc42..cd122a7 100644
--- a/gtk/channel-main.h
+++ b/gtk/channel-main.h
@@ -93,6 +93,8 @@ gboolean spice_main_file_copy_finish(SpiceMainChannel 
*channel,
  GAsyncResult *result,
  GError **error);
 
+void spice_main_keyboard_description(SpiceMainChannel *channel,
+ const gchar *data, size_t size);
 #ifndef SPICE_DISABLE_DEPRECATED
 SPICE_DEPRECATED_FOR(spice_main_clipboard_selection_grab)
 void spice_main_clipboard_grab(SpiceMainChannel *channel, guint32 *types, int 
ntypes);
diff --git a/gtk/map-file b/gtk/map-file
index 9f8d04e..2bbc62e 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -67,6 +67,7 @@ spice_main_clipboard_selection_release;
 spice_main_clipboard_selection_request;
 spice_main_file_copy_async;
 spice_main_file_copy_finish;
+spice_main_keyboard_description;
 spice_main_send_monitor_config;
 spice_main_set_display;
 spice_main_set_display_enabled;
-- 
1.9.3

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


[Spice-devel] [PATCH spice-gtk 2/2] Send keyboard description

2014-11-05 Thread Pavel Grunt
The keyboard description of the client will be sent to the guest
when the connection is established.

RFE: https://bugs.freedesktop.org/show_bug.cgi?id=85332
---
 gtk/spice-gtk-session-priv.h |  1 +
 gtk/spice-gtk-session.c  | 72 
 2 files changed, 73 insertions(+)

diff --git a/gtk/spice-gtk-session-priv.h b/gtk/spice-gtk-session-priv.h
index 91304b2..571f91f 100644
--- a/gtk/spice-gtk-session-priv.h
+++ b/gtk/spice-gtk-session-priv.h
@@ -28,6 +28,7 @@ gboolean spice_gtk_session_get_read_only(SpiceGtkSession 
*self);
 void spice_gtk_session_sync_keyboard_modifiers(SpiceGtkSession *self);
 void spice_gtk_session_set_pointer_grabbed(SpiceGtkSession *self, gboolean 
grabbed);
 gboolean spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self);
+void spice_gtk_session_sync_keyboard_layout(SpiceGtkSession *self);
 
 G_END_DECLS
 
diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 52ad597..180f2ed 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -178,6 +178,13 @@ static void 
spice_gtk_session_sync_keyboard_modifiers_for_channel(SpiceGtkSessio
 }
 }
 
+static void keymap_layout_changed(GdkKeymap *keymap, gpointer data)
+{
+SpiceGtkSession *self = data;
+
+spice_gtk_session_sync_keyboard_layout(self);
+}
+
 static void keymap_modifiers_changed(GdkKeymap *keymap, gpointer data)
 {
 SpiceGtkSession *self = data;
@@ -207,6 +214,8 @@ static void spice_gtk_session_init(SpiceGtkSession *self)
  G_CALLBACK(clipboard_owner_change), self);
 spice_g_signal_connect_object(keymap, state-changed,
   G_CALLBACK(keymap_modifiers_changed), self, 
0);
+spice_g_signal_connect_object(keymap, keys-changed,
+  G_CALLBACK(keymap_layout_changed), self, 0);
 }
 
 static GObject *
@@ -1001,6 +1010,15 @@ static void channel_new(SpiceSession *session, 
SpiceChannel *channel,
  G_CALLBACK(clipboard_request), self);
 g_signal_connect(channel, main-clipboard-selection-release,
  G_CALLBACK(clipboard_release), self);
+gboolean agent_connected;
+g_object_get(channel, agent-connected, agent_connected, NULL);
+if (agent_connected) {
+spice_gtk_session_sync_keyboard_layout(self);
+} else {
+g_signal_connect_swapped(channel, notify::agent-connected,
+ 
G_CALLBACK(spice_gtk_session_sync_keyboard_layout),
+ self);
+}
 }
 if (SPICE_IS_INPUTS_CHANNEL(channel)) {
 spice_g_signal_connect_object(channel, inputs-modifiers,
@@ -1195,3 +1213,57 @@ gboolean 
spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self)
 
 return self-priv-pointer_grabbed;
 }
+
+static gchar *get_keyboard_description(void)
+{
+gchar *keyboard_description = NULL;
+#ifdef HAVE_X11_XKBLIB_H
+Display *dpy;
+XkbDescPtr xkb;
+int major = XkbMajorVersion, minor = XkbMinorVersion;
+
+dpy = XkbOpenDisplay(NULL, NULL, NULL, major, minor, NULL);
+if (dpy != NULL) {
+xkb = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
+if (xkb != NULL) {
+keyboard_description = g_strdelimit(
+g_strdup_printf(%s, XGetAtomName(dpy, xkb-names-symbols)), 
_,'+');
+XkbFreeKeyboard(xkb, XkbAllComponentsMask, True);
+}
+XCloseDisplay(dpy);
+}
+#elif defined(G_OS_WIN32)
+gchar  *locale, *region;
+locale = g_win32_getlocale();
+region = g_ascii_strdown(g_strrstr(locale, _)+1, -1);
+g_free(locale);
+keyboard_description = g_strdup_printf(pc+%s, region);
+g_free(region);
+#endif
+return keyboard_description;
+}
+
+G_GNUC_INTERNAL
+void spice_gtk_session_sync_keyboard_layout(SpiceGtkSession *self)
+{
+GList *l, *channels;
+gchar *keyboard_description = get_keyboard_description();
+
+if (keyboard_description != NULL) {
+channels = spice_session_get_channels(self-priv-session);
+for (l = channels; l != NULL; l = l-next) {
+if (SPICE_IS_MAIN_CHANNEL(l-data)) {
+SpiceMainChannel *main_channel = SPICE_MAIN_CHANNEL(l-data);
+gboolean agent_connected;
+g_object_get(main_channel, agent-connected, 
agent_connected, NULL);
+if (!agent_connected)
+continue;
+spice_main_keyboard_description(main_channel,
+keyboard_description,
+
strlen(keyboard_description)+1);
+}
+}
+g_list_free(channels);
+g_free(keyboard_description);
+}
+}
-- 
1.9.3

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


Re: [Spice-devel] [PATCH spice-gtk 1/2] Support for keyboard description message

2014-11-05 Thread Marc-André Lureau
Hi

- Original Message -
 This commit introduces function for sending the message to the agent.
 
 RFE: https://bugs.freedesktop.org/show_bug.cgi?id=85332
 ---
 depends on:
 http://lists.freedesktop.org/archives/spice-devel/2014-November/017821.html
 ---
  gtk/channel-main.c | 32 
  gtk/channel-main.h |  2 ++
  gtk/map-file   |  1 +
  3 files changed, 35 insertions(+)
 
 diff --git a/gtk/channel-main.c b/gtk/channel-main.c
 index 1ad090f..66587d6 100644
 --- a/gtk/channel-main.c
 +++ b/gtk/channel-main.c
 @@ -187,6 +187,7 @@ static const char *agent_msg_types[] = {
  [ VD_AGENT_CLIPBOARD_GRAB  ] = clipboard grab,
  [ VD_AGENT_CLIPBOARD_REQUEST   ] = clipboard request,
  [ VD_AGENT_CLIPBOARD_RELEASE   ] = clipboard release,
 +[ VD_AGENT_KEYBOARD_DESCRIPTION] = keyboard description,
  };
  
  static const char *agent_caps[] = {
 @@ -1282,6 +1283,18 @@ static void agent_clipboard_release(SpiceMainChannel
 *channel, guint selection)
  agent_msg_queue(channel, VD_AGENT_CLIPBOARD_RELEASE, msgsize, msg);
  }
  
 +/* any context: the message is not flushed immediately,
 +   you can wakeup() the channel coroutine or send_msg_queue() */
 +static void agent_keyboard_description(SpiceMainChannel *channel,
 +   const gchar *data, size_t size)
 +{
 +SpiceMainChannelPrivate *c = channel-priv;
 +
 +g_return_if_fail(c-agent_connected);
 +
 +agent_msg_queue(channel, VD_AGENT_KEYBOARD_DESCRIPTION, size, data);
 +}
 +
  /* main context*/
  static gboolean timer_set_display(gpointer data)
  {
 @@ -2630,6 +2643,25 @@ void spice_main_set_display_enabled(SpiceMainChannel
 *channel, int id, gboolean
  update_display_timer(channel, 1);
  }
  
 +/**
 + * spice_main_keyboard_description:

I would use spice_main_send_keyboard_description()

 + * @channel: a #SpiceMainChannel
 + * @data: keyboard description
 + * @size: data length in bytes

Is it a nul terminated string? ascii only? In which case, no need for size 
parameter.

 + *
 + * Send the keyboard description to the guest.
 + *
 + **/
 +void spice_main_keyboard_description(SpiceMainChannel *channel,
 + const gchar *data, size_t size)
 +{
 +g_return_if_fail(channel != NULL);
 +g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
 +
 +agent_keyboard_description(channel, data, size);
 +spice_channel_wakeup(SPICE_CHANNEL(channel), FALSE);
 +}
 +
  static void file_xfer_completed(SpiceFileXferTask *task, GError *error)
  {
  /* In case of multiple errors we only report the first error */
 diff --git a/gtk/channel-main.h b/gtk/channel-main.h
 index 3e4fc42..cd122a7 100644
 --- a/gtk/channel-main.h
 +++ b/gtk/channel-main.h
 @@ -93,6 +93,8 @@ gboolean spice_main_file_copy_finish(SpiceMainChannel
 *channel,
   GAsyncResult *result,
   GError **error);
  
 +void spice_main_keyboard_description(SpiceMainChannel *channel,
 + const gchar *data, size_t size);
  #ifndef SPICE_DISABLE_DEPRECATED
  SPICE_DEPRECATED_FOR(spice_main_clipboard_selection_grab)
  void spice_main_clipboard_grab(SpiceMainChannel *channel, guint32 *types,
  int ntypes);
 diff --git a/gtk/map-file b/gtk/map-file
 index 9f8d04e..2bbc62e 100644
 --- a/gtk/map-file
 +++ b/gtk/map-file
 @@ -67,6 +67,7 @@ spice_main_clipboard_selection_release;
  spice_main_clipboard_selection_request;
  spice_main_file_copy_async;
  spice_main_file_copy_finish;
 +spice_main_keyboard_description;
  spice_main_send_monitor_config;
  spice_main_set_display;
  spice_main_set_display_enabled;
 --
 1.9.3
 
 ___
 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 spice-gtk 2/2] Send keyboard description

2014-11-05 Thread Marc-André Lureau


- Original Message -
 The keyboard description of the client will be sent to the guest
 when the connection is established.
 
 RFE: https://bugs.freedesktop.org/show_bug.cgi?id=85332
 ---
  gtk/spice-gtk-session-priv.h |  1 +
  gtk/spice-gtk-session.c  | 72
  
  2 files changed, 73 insertions(+)
 
 diff --git a/gtk/spice-gtk-session-priv.h b/gtk/spice-gtk-session-priv.h
 index 91304b2..571f91f 100644
 --- a/gtk/spice-gtk-session-priv.h
 +++ b/gtk/spice-gtk-session-priv.h
 @@ -28,6 +28,7 @@ gboolean spice_gtk_session_get_read_only(SpiceGtkSession
 *self);
  void spice_gtk_session_sync_keyboard_modifiers(SpiceGtkSession *self);
  void spice_gtk_session_set_pointer_grabbed(SpiceGtkSession *self, gboolean
  grabbed);
  gboolean spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self);
 +void spice_gtk_session_sync_keyboard_layout(SpiceGtkSession *self);
  
  G_END_DECLS
  
 diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
 index 52ad597..180f2ed 100644
 --- a/gtk/spice-gtk-session.c
 +++ b/gtk/spice-gtk-session.c
 @@ -178,6 +178,13 @@ static void
 spice_gtk_session_sync_keyboard_modifiers_for_channel(SpiceGtkSessio
  }
  }
  
 +static void keymap_layout_changed(GdkKeymap *keymap, gpointer data)
 +{
 +SpiceGtkSession *self = data;
 +
 +spice_gtk_session_sync_keyboard_layout(self);
 +}
 +
  static void keymap_modifiers_changed(GdkKeymap *keymap, gpointer data)
  {
  SpiceGtkSession *self = data;
 @@ -207,6 +214,8 @@ static void spice_gtk_session_init(SpiceGtkSession *self)
   G_CALLBACK(clipboard_owner_change), self);
  spice_g_signal_connect_object(keymap, state-changed,
G_CALLBACK(keymap_modifiers_changed),
self, 0);
 +spice_g_signal_connect_object(keymap, keys-changed,
 +  G_CALLBACK(keymap_layout_changed), self,
 0);
  }
  
  static GObject *
 @@ -1001,6 +1010,15 @@ static void channel_new(SpiceSession *session,
 SpiceChannel *channel,
   G_CALLBACK(clipboard_request), self);
  g_signal_connect(channel, main-clipboard-selection-release,
   G_CALLBACK(clipboard_release), self);
 +gboolean agent_connected;
 +g_object_get(channel, agent-connected, agent_connected, NULL);
 +if (agent_connected) {
 +spice_gtk_session_sync_keyboard_layout(self);
 +} else {
 +g_signal_connect_swapped(channel, notify::agent-connected,
 +
 G_CALLBACK(spice_gtk_session_sync_keyboard_layout),
 + self);
 +}
  }
  if (SPICE_IS_INPUTS_CHANNEL(channel)) {
  spice_g_signal_connect_object(channel, inputs-modifiers,
 @@ -1195,3 +1213,57 @@ gboolean
 spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self)
  
  return self-priv-pointer_grabbed;
  }
 +
 +static gchar *get_keyboard_description(void)
 +{
 +gchar *keyboard_description = NULL;
 +#ifdef HAVE_X11_XKBLIB_H
 +Display *dpy;
 +XkbDescPtr xkb;
 +int major = XkbMajorVersion, minor = XkbMinorVersion;
 +
 +dpy = XkbOpenDisplay(NULL, NULL, NULL, major, minor, NULL);
 +if (dpy != NULL) {

Please use g_return_val_if_fail() here, as this should not happen.

 +xkb = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
 +if (xkb != NULL) {

Same here

 +keyboard_description = g_strdelimit(
 +g_strdup_printf(%s, XGetAtomName(dpy,
 xkb-names-symbols)), _,'+');
 +XkbFreeKeyboard(xkb, XkbAllComponentsMask, True);
 +}
 +XCloseDisplay(dpy);
 +}
 +#elif defined(G_OS_WIN32)
 +gchar  *locale, *region;
 +locale = g_win32_getlocale();
 +region = g_ascii_strdown(g_strrstr(locale, _)+1, -1);
 +g_free(locale);
 +keyboard_description = g_strdup_printf(pc+%s, region);
 +g_free(region);
 +#endif
 +return keyboard_description;
 +}
 +
 +G_GNUC_INTERNAL
 +void spice_gtk_session_sync_keyboard_layout(SpiceGtkSession *self)
 +{
 +GList *l, *channels;
 +gchar *keyboard_description = get_keyboard_description();
 +
 +if (keyboard_description != NULL) {

To avoid deep blocks, it's easy to return early, this time with simple return 
(NULL is ok)

 +channels = spice_session_get_channels(self-priv-session);
 +for (l = channels; l != NULL; l = l-next) {

No need to look up all channels, there is a single main channel, and you can 
take it from priv-main

 +if (SPICE_IS_MAIN_CHANNEL(l-data)) {
 +SpiceMainChannel *main_channel =
 SPICE_MAIN_CHANNEL(l-data);
 +gboolean agent_connected;
 +g_object_get(main_channel, agent-connected,
 agent_connected, NULL);
 +if (!agent_connected)
 +continue;
 +spice_main_keyboard_description(main_channel,
 +   

Re: [Spice-devel] [PATCH spice-gtk 1/2] Support for keyboard description message

2014-11-05 Thread Pavel Grunt
Hi,
thanks for the review.
 
 Is it a nul terminated string? ascii only? In which case, no need for
 size parameter.
 

Yes, it is. I will send v2.

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


[Spice-devel] Patch to support LZ4 compression algorithm

2014-11-05 Thread Javier Celaya
Hello

My name is Javier Celaya and I work for Flexible Solutions [1]. We develop a 
virtualization product that includes a VDI module with Spice. As part of this 
module, we have included support for the LZ4 compression algorithm [2], and we 
would like to contribute it to the main project.

The LZ4 algorithm focuses on speed sacrificing compression ratio. In our tests, 
we obtained a compression ratio of x1.75~x2, while QUIC obtained ~x4. However, 
LZ4 was around 4~5 times faster than QUIC or GLZ. The objective was to 
implement a Spice client for devices with limited CPU performance, like 
smartphones or ARM set-top-boxes.

We have tried to keep things simple. Our approach consists in replacing the LZ 
algorithm with LZ4 when Spice is built with the --enable-lz4 switch. Adding it 
as a new option would also require changes in the software that uses the 
server, like QEMU. Then, each image is compressed independently. Since the LZ4 
dictionary size is quite small (64KB), there is no improvement in compressing 
all the images as a stream.

I send you three patches, for spice-common, spice and spice-gtk. The 
compression code is in spice, the decompression is in spice-common, and
spice-gtk only contains the macros needed to find liblz4 during configure.

We are open to comments and critics.
Best regards

[1] http://flexvm.es/
[2] https://code.google.com/p/lz4/diff --git a/common/canvas_base.c b/common/canvas_base.c
index 2753fae..a1bfc27 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -26,6 +26,10 @@
 #include stdio.h
 #include math.h
 
+#ifdef USE_LZ4
+#include arpa/inet.h
+#include lz4.h
+#endif
 #include spice/macros.h
 #include log.h
 #include quic.h
@@ -543,6 +547,64 @@ static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image, in
 return surface;
 }
 
+#ifdef USE_LZ4
+static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image, int invers)
+{
+pixman_image_t *surface = NULL;
+int dec_size, enc_size;
+int stride;
+int stride_abs;
+uint8_t *dest, *data, *data_end;
+int width, height, direction;
+LZ4_streamDecode_t *stream;
+
+spice_chunks_linearize(image-u.lz4.data);
+data = image-u.lz4.data-chunk[0].data;
+data_end = data + image-u.lz4.data-chunk[0].len;
+width = image-descriptor.width;
+height = image-descriptor.height;
+direction = *(data++);
+
+surface = surface_create(
+#ifdef WIN32
+ canvas-dc,
+#endif
+ PIXMAN_a8r8g8b8,
+ width, height, direction == 0);
+if (surface == NULL) {
+spice_warning(create surface failed);
+return NULL;
+}
+
+stream = LZ4_createStreamDecode();
+dest = (uint8_t *)pixman_image_get_data(surface);
+stride = pixman_image_get_stride(surface);
+stride_abs = abs(stride);
+if (direction == 1) {
+dest -= (stride_abs * (height - 1));
+}
+
+do {
+// Read next compressed block
+enc_size = ntohl(*((uint32_t *)data));
+data += 4;
+dec_size = LZ4_decompress_safe_continue(stream, (const char *) data,
+(char *) dest, enc_size, height * stride_abs);
+if (dec_size = 0) {
+spice_warning(Error decoding LZ4 block\n);
+pixman_image_unref(surface);
+surface = NULL;
+break;
+}
+dest += dec_size;
+data += enc_size;
+} while (data  data_end);
+
+LZ4_freeStreamDecode(stream);
+return surface;
+}
+#endif
+
 static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas,
  SpiceImage *image, int invers)
 {
@@ -1119,6 +1181,15 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage
 surface = canvas_get_jpeg_alpha(canvas, image, 0);
 break;
 }
+case SPICE_IMAGE_TYPE_LZ4: {
+#ifdef USE_LZ4
+surface = canvas_get_lz4(canvas, image, 0);
+#else
+spice_warning(Lz4 compression algorithm not supported.\n);
+surface = NULL;
+#endif
+break;
+}
 #if defined(SW_CANVAS_CACHE)
 case SPICE_IMAGE_TYPE_GLZ_RGB: {
 surface = canvas_get_glz(canvas, image, want_original);
diff --git a/common/draw.h b/common/draw.h
index 3704358..1155dc5 100644
--- a/common/draw.h
+++ b/common/draw.h
@@ -120,7 +120,7 @@ typedef struct SpiceSurface {
 typedef struct SpiceQUICData {
 uint32_t data_size;
 SpiceChunks *data;
-} SpiceQUICData, SpiceLZRGBData, SpiceJPEGData;
+} SpiceQUICData, SpiceLZRGBData, SpiceJPEGData, SpiceLZ4Data;
 
 typedef struct SpiceLZPLTData {
 uint8_t flags;
@@ -153,6 +153,7 @@ typedef struct SpiceImage {
 SpiceLZRGBData  lz_rgb;
 SpiceLZPLTData  lz_plt;
 SpiceJPEGData   jpeg;
+SpiceLZ4Datalz4;
 SpiceZlibGlzRGBData zlib_glz;
 SpiceJPEGAlphaData  jpeg_alpha;
 } u;
diff 

[Spice-devel] [PATCH spice-gtk v2 1/2] Support for keyboard description message

2014-11-05 Thread Pavel Grunt
This commit introduces function for sending the message to the agent.

RFE: https://bugs.freedesktop.org/show_bug.cgi?id=85332
---
depends on: 
http://lists.freedesktop.org/archives/spice-devel/2014-November/017821.html
v2:
 - spice_main_keyboard_description changed to 
spice_main_send_keyboard_description
 - removed unnecessary 'size' parameter
---
 gtk/channel-main.c | 29 +
 gtk/channel-main.h |  1 +
 gtk/map-file   |  1 +
 3 files changed, 31 insertions(+)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 1ad090f..4460c5a 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -187,6 +187,7 @@ static const char *agent_msg_types[] = {
 [ VD_AGENT_CLIPBOARD_GRAB  ] = clipboard grab,
 [ VD_AGENT_CLIPBOARD_REQUEST   ] = clipboard request,
 [ VD_AGENT_CLIPBOARD_RELEASE   ] = clipboard release,
+[ VD_AGENT_KEYBOARD_DESCRIPTION] = keyboard description,
 };
 
 static const char *agent_caps[] = {
@@ -1282,6 +1283,17 @@ static void agent_clipboard_release(SpiceMainChannel 
*channel, guint selection)
 agent_msg_queue(channel, VD_AGENT_CLIPBOARD_RELEASE, msgsize, msg);
 }
 
+/* any context: the message is not flushed immediately,
+   you can wakeup() the channel coroutine or send_msg_queue() */
+static void agent_send_keyboard_description(SpiceMainChannel *channel, const 
gchar *data)
+{
+SpiceMainChannelPrivate *c = channel-priv;
+
+g_return_if_fail(c-agent_connected);
+
+agent_msg_queue(channel, VD_AGENT_KEYBOARD_DESCRIPTION, strlen(data)+1, 
data);
+}
+
 /* main context*/
 static gboolean timer_set_display(gpointer data)
 {
@@ -2630,6 +2642,23 @@ void spice_main_set_display_enabled(SpiceMainChannel 
*channel, int id, gboolean
 update_display_timer(channel, 1);
 }
 
+/**
+ * spice_main_send_keyboard_description:
+ * @channel: a #SpiceMainChannel
+ * @data: keyboard description
+ *
+ * Send the keyboard description to the guest.
+ *
+ **/
+void spice_main_send_keyboard_description(SpiceMainChannel *channel, const 
gchar *data)
+{
+g_return_if_fail(channel != NULL);
+g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
+
+agent_send_keyboard_description(channel, data);
+spice_channel_wakeup(SPICE_CHANNEL(channel), FALSE);
+}
+
 static void file_xfer_completed(SpiceFileXferTask *task, GError *error)
 {
 /* In case of multiple errors we only report the first error */
diff --git a/gtk/channel-main.h b/gtk/channel-main.h
index 3e4fc42..cb239d6 100644
--- a/gtk/channel-main.h
+++ b/gtk/channel-main.h
@@ -93,6 +93,7 @@ gboolean spice_main_file_copy_finish(SpiceMainChannel 
*channel,
  GAsyncResult *result,
  GError **error);
 
+void spice_main_send_keyboard_description(SpiceMainChannel *channel, const 
gchar *data);
 #ifndef SPICE_DISABLE_DEPRECATED
 SPICE_DEPRECATED_FOR(spice_main_clipboard_selection_grab)
 void spice_main_clipboard_grab(SpiceMainChannel *channel, guint32 *types, int 
ntypes);
diff --git a/gtk/map-file b/gtk/map-file
index 9f8d04e..619b362 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -67,6 +67,7 @@ spice_main_clipboard_selection_release;
 spice_main_clipboard_selection_request;
 spice_main_file_copy_async;
 spice_main_file_copy_finish;
+spice_main_send_keyboard_description;
 spice_main_send_monitor_config;
 spice_main_set_display;
 spice_main_set_display_enabled;
-- 
1.9.3

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


[Spice-devel] [PATCH spice-gtk v2 2/2] Send keyboard description

2014-11-05 Thread Pavel Grunt
The keyboard description of the client will be sent to the guest
when the connection is established.

RFE: https://bugs.freedesktop.org/show_bug.cgi?id=85332
---
v2:
 - reduced indentation level
 - removed checking all the channels
---
 gtk/spice-gtk-session-priv.h |  1 +
 gtk/spice-gtk-session.c  | 62 
 2 files changed, 63 insertions(+)

diff --git a/gtk/spice-gtk-session-priv.h b/gtk/spice-gtk-session-priv.h
index 91304b2..571f91f 100644
--- a/gtk/spice-gtk-session-priv.h
+++ b/gtk/spice-gtk-session-priv.h
@@ -28,6 +28,7 @@ gboolean spice_gtk_session_get_read_only(SpiceGtkSession 
*self);
 void spice_gtk_session_sync_keyboard_modifiers(SpiceGtkSession *self);
 void spice_gtk_session_set_pointer_grabbed(SpiceGtkSession *self, gboolean 
grabbed);
 gboolean spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self);
+void spice_gtk_session_sync_keyboard_layout(SpiceGtkSession *self);
 
 G_END_DECLS
 
diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 52ad597..cc02ec8 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -178,6 +178,13 @@ static void 
spice_gtk_session_sync_keyboard_modifiers_for_channel(SpiceGtkSessio
 }
 }
 
+static void keymap_layout_changed(GdkKeymap *keymap, gpointer data)
+{
+SpiceGtkSession *self = data;
+
+spice_gtk_session_sync_keyboard_layout(self);
+}
+
 static void keymap_modifiers_changed(GdkKeymap *keymap, gpointer data)
 {
 SpiceGtkSession *self = data;
@@ -207,6 +214,8 @@ static void spice_gtk_session_init(SpiceGtkSession *self)
  G_CALLBACK(clipboard_owner_change), self);
 spice_g_signal_connect_object(keymap, state-changed,
   G_CALLBACK(keymap_modifiers_changed), self, 
0);
+spice_g_signal_connect_object(keymap, keys-changed,
+  G_CALLBACK(keymap_layout_changed), self, 0);
 }
 
 static GObject *
@@ -1001,6 +1010,15 @@ static void channel_new(SpiceSession *session, 
SpiceChannel *channel,
  G_CALLBACK(clipboard_request), self);
 g_signal_connect(channel, main-clipboard-selection-release,
  G_CALLBACK(clipboard_release), self);
+gboolean agent_connected;
+g_object_get(channel, agent-connected, agent_connected, NULL);
+if (agent_connected) {
+spice_gtk_session_sync_keyboard_layout(self);
+} else {
+g_signal_connect_swapped(channel, notify::agent-connected,
+ 
G_CALLBACK(spice_gtk_session_sync_keyboard_layout),
+ self);
+}
 }
 if (SPICE_IS_INPUTS_CHANNEL(channel)) {
 spice_g_signal_connect_object(channel, inputs-modifiers,
@@ -1195,3 +1213,47 @@ gboolean 
spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self)
 
 return self-priv-pointer_grabbed;
 }
+
+static gchar *get_keyboard_description(void)
+{
+gchar *keyboard_description = NULL;
+#ifdef HAVE_X11_XKBLIB_H
+Display *dpy;
+XkbDescPtr xkb;
+int major = XkbMajorVersion, minor = XkbMinorVersion;
+
+dpy = XkbOpenDisplay(NULL, NULL, NULL, major, minor, NULL);
+g_return_val_if_fail(dpy != NULL, NULL);
+
+xkb = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
+g_return_val_if_fail(xkb != NULL, NULL);
+
+keyboard_description = g_strdelimit(
+g_strdup_printf(%s, XGetAtomName(dpy, xkb-names-symbols)), 
_,'+');
+XkbFreeKeyboard(xkb, XkbAllComponentsMask, True);
+XCloseDisplay(dpy);
+#elif defined(G_OS_WIN32)
+gchar  *locale, *region;
+locale = g_win32_getlocale();
+region = g_ascii_strdown(g_strrstr(locale, _)+1, -1);
+g_free(locale);
+keyboard_description = g_strdup_printf(pc+%s, region);
+g_free(region);
+#endif
+return keyboard_description;
+}
+
+G_GNUC_INTERNAL
+void spice_gtk_session_sync_keyboard_layout(SpiceGtkSession *self)
+{
+SpiceGtkSessionPrivate *s = self-priv;
+gchar *keyboard_description = get_keyboard_description();
+gboolean agent_connected;
+
+if (keyboard_description == NULL)
+return;
+g_object_get(s-main, agent-connected, agent_connected, NULL);
+if (agent_connected)
+spice_main_send_keyboard_description(s-main, keyboard_description);
+g_free(keyboard_description);
+}
-- 
1.9.3

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


Re: [Spice-devel] [PATCH spice-gtk v2 1/2] Support for keyboard description message

2014-11-05 Thread Marc-André Lureau


- Original Message -
 This commit introduces function for sending the message to the agent.
 
 RFE: https://bugs.freedesktop.org/show_bug.cgi?id=85332
 ---
 depends on:
 http://lists.freedesktop.org/archives/spice-devel/2014-November/017821.html
 v2:
  - spice_main_keyboard_description changed to
  spice_main_send_keyboard_description
  - removed unnecessary 'size' parameter
 ---
  gtk/channel-main.c | 29 +
  gtk/channel-main.h |  1 +
  gtk/map-file   |  1 +
  3 files changed, 31 insertions(+)
 
 diff --git a/gtk/channel-main.c b/gtk/channel-main.c
 index 1ad090f..4460c5a 100644
 --- a/gtk/channel-main.c
 +++ b/gtk/channel-main.c
 @@ -187,6 +187,7 @@ static const char *agent_msg_types[] = {
  [ VD_AGENT_CLIPBOARD_GRAB  ] = clipboard grab,
  [ VD_AGENT_CLIPBOARD_REQUEST   ] = clipboard request,
  [ VD_AGENT_CLIPBOARD_RELEASE   ] = clipboard release,
 +[ VD_AGENT_KEYBOARD_DESCRIPTION] = keyboard description,
  };
  
  static const char *agent_caps[] = {
 @@ -1282,6 +1283,17 @@ static void agent_clipboard_release(SpiceMainChannel
 *channel, guint selection)
  agent_msg_queue(channel, VD_AGENT_CLIPBOARD_RELEASE, msgsize, msg);
  }
  
 +/* any context: the message is not flushed immediately,
 +   you can wakeup() the channel coroutine or send_msg_queue() */
 +static void agent_send_keyboard_description(SpiceMainChannel *channel, const
 gchar *data)
 +{
 +SpiceMainChannelPrivate *c = channel-priv;
 +
 +g_return_if_fail(c-agent_connected);
 +
 +agent_msg_queue(channel, VD_AGENT_KEYBOARD_DESCRIPTION, strlen(data)+1,
 data);
 +}
 +
  /* main context*/
  static gboolean timer_set_display(gpointer data)
  {
 @@ -2630,6 +2642,23 @@ void spice_main_set_display_enabled(SpiceMainChannel
 *channel, int id, gboolean
  update_display_timer(channel, 1);
  }
  
 +/**
 + * spice_main_send_keyboard_description:
 + * @channel: a #SpiceMainChannel
 + * @data: keyboard description
 + *
 + * Send the keyboard description to the guest.
 + *

Add a Since: 2.27 tag

You'll have to add the symbol to doc/reference/spice-gtk-sections.txt

 + **/
 +void spice_main_send_keyboard_description(SpiceMainChannel *channel, const
 gchar *data)
 +{
 +g_return_if_fail(channel != NULL);
 +g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));

missing g_return_if_fail(data != NULL);

(all arguments of public API must be checked)

 +
 +agent_send_keyboard_description(channel, data);
 +spice_channel_wakeup(SPICE_CHANNEL(channel), FALSE);
 +}
 +
  static void file_xfer_completed(SpiceFileXferTask *task, GError *error)
  {
  /* In case of multiple errors we only report the first error */
 diff --git a/gtk/channel-main.h b/gtk/channel-main.h
 index 3e4fc42..cb239d6 100644
 --- a/gtk/channel-main.h
 +++ b/gtk/channel-main.h
 @@ -93,6 +93,7 @@ gboolean spice_main_file_copy_finish(SpiceMainChannel
 *channel,
   GAsyncResult *result,
   GError **error);
  
 +void spice_main_send_keyboard_description(SpiceMainChannel *channel, const
 gchar *data);
  #ifndef SPICE_DISABLE_DEPRECATED
  SPICE_DEPRECATED_FOR(spice_main_clipboard_selection_grab)
  void spice_main_clipboard_grab(SpiceMainChannel *channel, guint32 *types,
  int ntypes);
 diff --git a/gtk/map-file b/gtk/map-file
 index 9f8d04e..619b362 100644
 --- a/gtk/map-file
 +++ b/gtk/map-file
 @@ -67,6 +67,7 @@ spice_main_clipboard_selection_release;
  spice_main_clipboard_selection_request;
  spice_main_file_copy_async;
  spice_main_file_copy_finish;
 +spice_main_send_keyboard_description;
  spice_main_send_monitor_config;
  spice_main_set_display;
  spice_main_set_display_enabled;
 --
 1.9.3
 
 ___
 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


[Spice-devel] Windows guest on windows 10 tech preview

2014-11-05 Thread Hans Nieuwenhuis
Hi,

I am testing windows 10 tech preview in a Gnome Virtual Box on a
CentOs 7 machine.

I would like to install spice-guest-tools-0.74.exe
http://www.spice-space.org/download/windows/spice-guest-tools/spice-guest-tools-0.74.exe
, but when doing so,
I get an error that this is a unknown windows version.

Is there a way around this ??

Regards,

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


Re: [Spice-devel] [PATCH spice-gtk v2 2/2] Send keyboard description

2014-11-05 Thread Marc-André Lureau


- Original Message -
 The keyboard description of the client will be sent to the guest
 when the connection is established.
 
 RFE: https://bugs.freedesktop.org/show_bug.cgi?id=85332
 ---
 v2:
  - reduced indentation level
  - removed checking all the channels
 ---
  gtk/spice-gtk-session-priv.h |  1 +
  gtk/spice-gtk-session.c  | 62
  
  2 files changed, 63 insertions(+)
 
 diff --git a/gtk/spice-gtk-session-priv.h b/gtk/spice-gtk-session-priv.h
 index 91304b2..571f91f 100644
 --- a/gtk/spice-gtk-session-priv.h
 +++ b/gtk/spice-gtk-session-priv.h
 @@ -28,6 +28,7 @@ gboolean spice_gtk_session_get_read_only(SpiceGtkSession
 *self);
  void spice_gtk_session_sync_keyboard_modifiers(SpiceGtkSession *self);
  void spice_gtk_session_set_pointer_grabbed(SpiceGtkSession *self, gboolean
  grabbed);
  gboolean spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self);
 +void spice_gtk_session_sync_keyboard_layout(SpiceGtkSession *self);
  
  G_END_DECLS
  
 diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
 index 52ad597..cc02ec8 100644
 --- a/gtk/spice-gtk-session.c
 +++ b/gtk/spice-gtk-session.c
 @@ -178,6 +178,13 @@ static void
 spice_gtk_session_sync_keyboard_modifiers_for_channel(SpiceGtkSessio
  }
  }
  
 +static void keymap_layout_changed(GdkKeymap *keymap, gpointer data)
 +{
 +SpiceGtkSession *self = data;
 +
 +spice_gtk_session_sync_keyboard_layout(self);
 +}
 +
  static void keymap_modifiers_changed(GdkKeymap *keymap, gpointer data)
  {
  SpiceGtkSession *self = data;
 @@ -207,6 +214,8 @@ static void spice_gtk_session_init(SpiceGtkSession *self)
   G_CALLBACK(clipboard_owner_change), self);
  spice_g_signal_connect_object(keymap, state-changed,
G_CALLBACK(keymap_modifiers_changed),
self, 0);
 +spice_g_signal_connect_object(keymap, keys-changed,
 +  G_CALLBACK(keymap_layout_changed), self,
 0);
  }
  
  static GObject *
 @@ -1001,6 +1010,15 @@ static void channel_new(SpiceSession *session,
 SpiceChannel *channel,
   G_CALLBACK(clipboard_request), self);
  g_signal_connect(channel, main-clipboard-selection-release,
   G_CALLBACK(clipboard_release), self);
 +gboolean agent_connected;
 +g_object_get(channel, agent-connected, agent_connected, NULL);
 +if (agent_connected) {
 +spice_gtk_session_sync_keyboard_layout(self);
 +} else {
 +g_signal_connect_swapped(channel, notify::agent-connected,
 +
 G_CALLBACK(spice_gtk_session_sync_keyboard_layout),
 + self);
 +}
  }
  if (SPICE_IS_INPUTS_CHANNEL(channel)) {
  spice_g_signal_connect_object(channel, inputs-modifiers,
 @@ -1195,3 +1213,47 @@ gboolean
 spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self)
  
  return self-priv-pointer_grabbed;
  }
 +
 +static gchar *get_keyboard_description(void)
 +{
 +gchar *keyboard_description = NULL;
 +#ifdef HAVE_X11_XKBLIB_H
 +Display *dpy;
 +XkbDescPtr xkb;
 +int major = XkbMajorVersion, minor = XkbMinorVersion;
 +
 +dpy = XkbOpenDisplay(NULL, NULL, NULL, major, minor, NULL);
 +g_return_val_if_fail(dpy != NULL, NULL);
 +
 +xkb = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
 +g_return_val_if_fail(xkb != NULL, NULL);

Actually here you must not return with g_return_val_if_fail(), so you should 
first g_warn_if_fail() and then cleanup the dpy and return.

 +
 +keyboard_description = g_strdelimit(
 +g_strdup_printf(%s, XGetAtomName(dpy, xkb-names-symbols)),
 _,'+');
 +XkbFreeKeyboard(xkb, XkbAllComponentsMask, True);
 +XCloseDisplay(dpy);
 +#elif defined(G_OS_WIN32)
 +gchar  *locale, *region;
 +locale = g_win32_getlocale();
 +region = g_ascii_strdown(g_strrstr(locale, _)+1, -1);
 +g_free(locale);
 +keyboard_description = g_strdup_printf(pc+%s, region);
 +g_free(region);
 +#endif
 +return keyboard_description;
 +}
 +
 +G_GNUC_INTERNAL
 +void spice_gtk_session_sync_keyboard_layout(SpiceGtkSession *self)
 +{
 +SpiceGtkSessionPrivate *s = self-priv;
 +gchar *keyboard_description = get_keyboard_description();
 +gboolean agent_connected;
 +
 +if (keyboard_description == NULL)
 +return;
 +g_object_get(s-main, agent-connected, agent_connected, NULL);
 +if (agent_connected)
 +spice_main_send_keyboard_description(s-main, keyboard_description);
 +g_free(keyboard_description);
 +}
 --
 1.9.3
 
 ___
 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

Re: [Spice-devel] Patch to support LZ4 compression algorithm

2014-11-05 Thread Marc-André Lureau
Hi

- Original Message -
 Hello
 
 My name is Javier Celaya and I work for Flexible Solutions [1]. We develop a
 virtualization product that includes a VDI module with Spice. As part of this
 module, we have included support for the LZ4 compression algorithm [2], and
 we
 would like to contribute it to the main project.

Great!

 
 The LZ4 algorithm focuses on speed sacrificing compression ratio. In our
 tests,
 we obtained a compression ratio of x1.75~x2, while QUIC obtained ~x4.
 However,
 LZ4 was around 4~5 times faster than QUIC or GLZ. The objective was to
 implement a Spice client for devices with limited CPU performance, like
 smartphones or ARM set-top-boxes.

Sounds reasonable

 
 We have tried to keep things simple. Our approach consists in replacing the
 LZ
 algorithm with LZ4 when Spice is built with the --enable-lz4 switch. Adding
 it
 as a new option would also require changes in the software that uses the
 server, like QEMU. Then, each image is compressed independently. Since the
 LZ4
 dictionary size is quite small (64KB), there is no improvement in compressing
 all the images as a stream.
 
 I send you three patches, for spice-common, spice and spice-gtk. The
 compression code is in spice, the decompression is in spice-common, and
 spice-gtk only contains the macros needed to find liblz4 during configure.

The patches look nice. However, I am not sure I understand why you chose not
to modify the protocol to declare the new image type. We also need a new
display capability before applying this patch, as the server needs to remain
compatible with older clients no matter before accepting this.

Would you be willing to do those changes to get your patch accepted?

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


Re: [Spice-devel] Patch to support LZ4 compression algorithm

2014-11-05 Thread Javier Celaya
Hello

El Miércoles, 5 de noviembre de 2014 08:58:25 Marc-André Lureau escribió:
 Hi
 
 - Original Message -
 
  Hello
  
  My name is Javier Celaya and I work for Flexible Solutions [1]. We develop
  a virtualization product that includes a VDI module with Spice. As part
  of this module, we have included support for the LZ4 compression
  algorithm [2], and we
  would like to contribute it to the main project.
 
 Great!
 
  The LZ4 algorithm focuses on speed sacrificing compression ratio. In our
  tests,
  we obtained a compression ratio of x1.75~x2, while QUIC obtained ~x4.
  However,
  LZ4 was around 4~5 times faster than QUIC or GLZ. The objective was to
  implement a Spice client for devices with limited CPU performance, like
  smartphones or ARM set-top-boxes.
 
 Sounds reasonable
 
  We have tried to keep things simple. Our approach consists in replacing
  the
  LZ
  algorithm with LZ4 when Spice is built with the --enable-lz4 switch.
  Adding
  it
  as a new option would also require changes in the software that uses the
  server, like QEMU. Then, each image is compressed independently. Since the
  LZ4
  dictionary size is quite small (64KB), there is no improvement in
  compressing all the images as a stream.
  
  I send you three patches, for spice-common, spice and spice-gtk. The
  compression code is in spice, the decompression is in spice-common, and
  spice-gtk only contains the macros needed to find liblz4 during configure.
 
 The patches look nice. However, I am not sure I understand why you chose not
 to modify the protocol to declare the new image type. We also need a new
 display capability before applying this patch, as the server needs to
 remain compatible with older clients no matter before accepting this.
 
 Would you be willing to do those changes to get your patch accepted?

Yes, I will do those changes and send the patches again.

Thanks

 
 thanks

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


[Spice-devel] [PATCH spice-gtk v3 1/2] Support for keyboard description message

2014-11-05 Thread Pavel Grunt
This commit introduces function for sending the message to the agent.

RFE: https://bugs.freedesktop.org/show_bug.cgi?id=85332
---
depends on: 
http://lists.freedesktop.org/archives/spice-devel/2014-November/017821.html
v3:
 - added 'Since: 0.27'
 - added check for 'data' parameter
 - updated spice-gtk-sections.txt
v2:
 - spice_main_keyboard_description changed to 
spice_main_send_keyboard_description
 - removed unnecessary 'size' parameter
---
 doc/reference/spice-gtk-sections.txt |  1 +
 gtk/channel-main.c   | 31 +++
 gtk/channel-main.h   |  1 +
 gtk/map-file |  1 +
 4 files changed, 34 insertions(+)

diff --git a/doc/reference/spice-gtk-sections.txt 
b/doc/reference/spice-gtk-sections.txt
index caaa92c..df317f9 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -62,6 +62,7 @@ SpiceMainChannelClass
 SUBSECTION
 spice_main_set_display
 spice_main_set_display_enabled
+spice_main_send_keyboard_description
 spice_main_send_monitor_config
 spice_main_agent_test_capability
 spice_main_clipboard_selection_grab
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 1ad090f..a434e29 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -187,6 +187,7 @@ static const char *agent_msg_types[] = {
 [ VD_AGENT_CLIPBOARD_GRAB  ] = clipboard grab,
 [ VD_AGENT_CLIPBOARD_REQUEST   ] = clipboard request,
 [ VD_AGENT_CLIPBOARD_RELEASE   ] = clipboard release,
+[ VD_AGENT_KEYBOARD_DESCRIPTION] = keyboard description,
 };
 
 static const char *agent_caps[] = {
@@ -1282,6 +1283,17 @@ static void agent_clipboard_release(SpiceMainChannel 
*channel, guint selection)
 agent_msg_queue(channel, VD_AGENT_CLIPBOARD_RELEASE, msgsize, msg);
 }
 
+/* any context: the message is not flushed immediately,
+   you can wakeup() the channel coroutine or send_msg_queue() */
+static void agent_send_keyboard_description(SpiceMainChannel *channel, const 
gchar *data)
+{
+SpiceMainChannelPrivate *c = channel-priv;
+
+g_return_if_fail(c-agent_connected);
+
+agent_msg_queue(channel, VD_AGENT_KEYBOARD_DESCRIPTION, strlen(data)+1, 
data);
+}
+
 /* main context*/
 static gboolean timer_set_display(gpointer data)
 {
@@ -2630,6 +2642,25 @@ void spice_main_set_display_enabled(SpiceMainChannel 
*channel, int id, gboolean
 update_display_timer(channel, 1);
 }
 
+/**
+ * spice_main_send_keyboard_description:
+ * @channel: a #SpiceMainChannel
+ * @data: keyboard description
+ *
+ * Send the keyboard description to the guest.
+ *
+ * Since: 0.27
+ **/
+void spice_main_send_keyboard_description(SpiceMainChannel *channel, const 
gchar *data)
+{
+g_return_if_fail(channel != NULL);
+g_return_if_fail(data != NULL);
+g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
+
+agent_send_keyboard_description(channel, data);
+spice_channel_wakeup(SPICE_CHANNEL(channel), FALSE);
+}
+
 static void file_xfer_completed(SpiceFileXferTask *task, GError *error)
 {
 /* In case of multiple errors we only report the first error */
diff --git a/gtk/channel-main.h b/gtk/channel-main.h
index 3e4fc42..cb239d6 100644
--- a/gtk/channel-main.h
+++ b/gtk/channel-main.h
@@ -93,6 +93,7 @@ gboolean spice_main_file_copy_finish(SpiceMainChannel 
*channel,
  GAsyncResult *result,
  GError **error);
 
+void spice_main_send_keyboard_description(SpiceMainChannel *channel, const 
gchar *data);
 #ifndef SPICE_DISABLE_DEPRECATED
 SPICE_DEPRECATED_FOR(spice_main_clipboard_selection_grab)
 void spice_main_clipboard_grab(SpiceMainChannel *channel, guint32 *types, int 
ntypes);
diff --git a/gtk/map-file b/gtk/map-file
index 9f8d04e..619b362 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -67,6 +67,7 @@ spice_main_clipboard_selection_release;
 spice_main_clipboard_selection_request;
 spice_main_file_copy_async;
 spice_main_file_copy_finish;
+spice_main_send_keyboard_description;
 spice_main_send_monitor_config;
 spice_main_set_display;
 spice_main_set_display_enabled;
-- 
1.9.3

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


Re: [Spice-devel] [PATCH spice-protocol v2] vdagent: add keyboard description message

2014-11-05 Thread Marc-André Lureau
Hi

- Original Message -
 The message will be used for transferring the keyboard layout
 from the client to the guest. When the agent receives this message,
 it tries to set the specified keyboard layout.
 

Your commit message is all we have as a reference for the protocol:
you need to give more details about the content of the message.

If possible examples too.


 RFE: https://bugs.freedesktop.org/show_bug.cgi?id=85332
 ---
 v2:
  - the message is a string which is based on xkb symbols or on windows locale
(eg pc+us+inet(evdev))
 ---
  spice/vd_agent.h | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/spice/vd_agent.h b/spice/vd_agent.h
 index 7464661..4dacb25 100644
 --- a/spice/vd_agent.h
 +++ b/spice/vd_agent.h
 @@ -77,6 +77,7 @@ enum {
  VD_AGENT_FILE_XFER_DATA,
  VD_AGENT_CLIENT_DISCONNECTED,
  VD_AGENT_MAX_CLIPBOARD,
 +VD_AGENT_KEYBOARD_DESCRIPTION,
  VD_AGENT_END_MESSAGE,
  };
  
 --
 1.9.3
 
 ___
 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


[Spice-devel] [PATCH spice-protocol v3] vdagent: add keyboard description message

2014-11-05 Thread Pavel Grunt
The goal of this message is to make the guest use the same keyboard
layout as the client. In other words to remove the necessity to manually
configure the keyboard layout on the guest.

We can achieve this functionality by informing the agent about
the keyboard layout used by the client. The agent then tries to set
the appropriate keyboard layout on the guest side.

The message is represented by a xkb symbols string (e.g. pc+us,
basically it contains an abbreviation of the country name
and some other options). Linux agent can use this string directly,
windows agent has to find a keyboard layout for the specified country name.

RFE: https://bugs.freedesktop.org/show_bug.cgi?id=85332
---
v3:
 - commit log changed
v2:
 - the message is a string which is based on xkb symbols or on windows locale
   (eg pc+us+inet(evdev))
---
 spice/vd_agent.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/spice/vd_agent.h b/spice/vd_agent.h
index 7464661..4dacb25 100644
--- a/spice/vd_agent.h
+++ b/spice/vd_agent.h
@@ -77,6 +77,7 @@ enum {
 VD_AGENT_FILE_XFER_DATA,
 VD_AGENT_CLIENT_DISCONNECTED,
 VD_AGENT_MAX_CLIPBOARD,
+VD_AGENT_KEYBOARD_DESCRIPTION,
 VD_AGENT_END_MESSAGE,
 };
 
-- 
1.9.3

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